I have followed the document: NN Example (Yolov7_tiny) — AmebaPro2's Documentation v0.1 documentation to do the reparam on my trained yolov7-tiny weights.
But, found that there is one wrong code in the code: ameba-arduino-pro2/Arduino_package/hardware/libraries/NeuralNetwork/src/Yolov7_reparam_scripts/reparam_yolov7-tiny.py at dev · Ameba-AIoT/ameba-arduino-pro2 · GitHub
model = Model(args.custom_yaml, ch=3, nc=2).to(device)
should be:
# model = Model(args.custom_yaml, ch=3, nc=2).to(device)
# Number of classes should not be fixed to 2, but match the trained model
model = Model(args.custom_yaml, ch=3, nc=ckpt['model'].nc).to(device)
Otherwise, there would be error:
Traceback (most recent call last):
File "/mnt/sdc/02_Workspace/rt_yolov7/yolov7/reparam_yolov7-tiny.py", line 41, in <module>
model.state_dict()['model.77.m.0.bias'].data += state_dict['model.77.m.0.weight'].mul(state_dict['model.77.ia.0.implicit']).sum(1).squeeze()
RuntimeError: The size of tensor a (21) must match the size of tensor b (18) at non-singleton dimension 0
Thanks