Skip to content

Commit 4697890

Browse files
authored
Fix error when using yolov5-v6 custom mode (wang-xinyu#782)
1 parent 4686140 commit 4697890

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

yolov5/gen_wts.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ def parse_args():
2828
device = select_device('cpu')
2929
# Load model
3030
model = torch.load(pt_file, map_location=device)['model'].float() # load to FP32
31+
delattr(model.model[-1], 'anchor_grid') # model.model[-1] is detect layer
32+
model.model[-1].register_buffer("anchor_grid",torch.Tensor(model.yaml['anchors'])) #The parameters are saved in the OrderDict through the "register_buffer" method, and then saved to the weight.
3133
model.to(device).eval()
3234

3335
with open(wts_file, 'w') as f:

0 commit comments

Comments
 (0)