We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ea5d8ca commit dd8f7eeCopy full SHA for dd8f7ee
yolov3/gen_wts.py
@@ -0,0 +1,24 @@
1
+import struct
2
+import sys
3
+from models import *
4
+from utils.utils import *
5
+
6
+model = Darknet('cfg/yolov3.cfg', (608, 608))
7
+weights = sys.argv[1]
8
+dev = '0'
9
+if weights.endswith('.pt'): # pytorch format
10
+ model.load_state_dict(torch.load(weights, map_location=device)['model'])
11
+else: # darknet format
12
+ load_darknet_weights(model, weights)
13
+model = model.eval()
14
15
+f = open('yolov3.wts', 'w')
16
+f.write('{}\n'.format(len(model.state_dict().keys())))
17
+for k, v in model.state_dict().items():
18
+ vr = v.reshape(-1).cpu().numpy()
19
+ f.write('{} {} '.format(k, len(vr)))
20
+ for vv in vr:
21
+ f.write(' ')
22
+ f.write(struct.pack('>f',float(vv)).hex())
23
+ f.write('\n')
24
0 commit comments