Skip to content

Commit

Permalink
Merge pull request #362 from ajsanjoaquin/master
Browse files Browse the repository at this point in the history
update demo.py and darknet2pytorch.py
  • Loading branch information
Tianxiaomo authored Dec 12, 2021
2 parents 267a040 + dbc10cd commit fa24033
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 7 additions & 1 deletion demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from tool.utils import *
from tool.torch_utils import *
from tool.darknet2pytorch import Darknet
import torch
import argparse

"""hyper parameters"""
Expand Down Expand Up @@ -61,7 +62,10 @@ def detect_cv2_camera(cfgfile, weightfile):
m = Darknet(cfgfile)

m.print_network()
m.load_weights(weightfile)
if args.torch:
m.load_state_dict(torch.load(weightfile))
else:
m.load_weights(weightfile)
print('Loading weights from %s... Done!' % (weightfile))

if use_cuda:
Expand Down Expand Up @@ -144,6 +148,8 @@ def get_args():
parser.add_argument('-imgfile', type=str,
default='./data/mscoco2017/train2017/190109_180343_00154162.jpg',
help='path of your image file.', dest='imgfile')
parser.add_argument('-torch', type=bool, default=false,
help='use torch weights')
args = parser.parse_args()

return args
Expand Down
4 changes: 3 additions & 1 deletion tool/darknet2pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,12 @@ def create_network(self, blocks):
model.add_module('relu{0}'.format(conv_id), nn.ReLU(inplace=True))
elif activation == 'mish':
model.add_module('mish{0}'.format(conv_id), Mish())
elif activation == 'linear':
pass
elif activation == 'logistic':
model.add_module('sigmoid{0}'.format(conv_id), nn.Sigmoid())
else:
print("convalution havn't activate {}".format(activation))
print("No convolutional activation named {}".format(activation))

prev_filters = filters
out_filters.append(prev_filters)
Expand Down

0 comments on commit fa24033

Please sign in to comment.