sparseml
sparseml copied to clipboard
The Trained yolov5 Weights didn't Load to Model

Hi, After training, the trained weights didn't load to model in validating process as you see in picture. This action accrued in export_onnx process too.
thanks to neuralmagic team.
Hi @miladlink could you provide the command used to run the export command? It looks like the model is not getting quantized before weight reload, passing the recipe you used to train could help if not already
Hi @bfineran
Here is my command
sparseml.yolov5.train \
--data dataset.yaml \
--cfg models_v5.0/yolov5s.yaml \
--weights zoo:cv/detection/yolov5-s/pytorch/ultralytics/coco/pruned_quant-aggressive_94?recipe_type=transfer \
--hyp data/hyps/hyp.finetune.yaml \
--recipe zoo:cv/detection/yolov5-s/pytorch/ultralytics/coco/pruned_quant-aggressive_94
Hi @miladlink this was an issue with an earlier version of our yolov5 fork, where the best model was loaded for validation, but best may not fall within the range of quantization. This was solved 12 days ago. If your version is older than that, I recommend updating it. The easiest way to do so is to run pip uninstall yolov5 and then re-run your sparseml command. The latest version of our yolov5 fork will automatically install on call.
Same issue here at the end fo the train, or the export, I got:
sparseml.yolov5.export_onnx \
--data data/datasets/dataset.yaml --weights yolov5_runs/train/exp14/weights/best.pt
And I got the error
Missing key(s) in state_dict: "model.0.conv.conv.weight", ...
Unexpected key(s) in state_dict: "model.0.conv.conv.quant.activation_post_process.fake_quant_enabled", ...
I have already uninstalled yolo5 and reinstalled sparseml[yolo] as well as installing manually the version of yolov5 from neurlalmagic
Tested with: torch==1.9.0 and 1.9.1 sparseml==1.2.0
This issue is now resolved. Closing out the ticket, but if the issue persists feel free to re-open the issue.