sparseml icon indicating copy to clipboard operation
sparseml copied to clipboard

The Trained yolov5 Weights didn't Load to Model

Open miladlink opened this issue 3 years ago • 3 comments

image

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.

miladlink avatar Sep 19 '22 07:09 miladlink

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

bfineran avatar Sep 22 '22 20:09 bfineran

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

miladlink avatar Sep 24 '22 08:09 miladlink

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.

KSGulin avatar Sep 26 '22 17:09 KSGulin

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

bbreton3 avatar Nov 07 '22 16:11 bbreton3

This issue is now resolved. Closing out the ticket, but if the issue persists feel free to re-open the issue.

KSGulin avatar Feb 02 '23 13:02 KSGulin