dnth / yolov5-deepsparse-blogpost

By the end of this post, you will learn how to: Train a SOTA YOLOv5 model on your own data. Sparsify the model using SparseML quantization aware training, sparse transfer learning, and one-shot quantization. Export the sparsified model and run it using the DeepSparse engine at insane speeds. P/S: The end result - YOLOv5 on CPU at 180+ FPS using on
https://dicksonneoh.com/portfolio/supercharging_yolov5_180_fps_cpu/
53 stars 13 forks source link

Failed to load the checkpoint after completion of model training in Google Colab #15

Open abirsince92 opened 1 year ago

abirsince92 commented 1 year ago

Respected Sir, The code is fine!!! but when I write the in Colab by training using pruned and quantized YoloV5s version. Kindly solve this issue pls.

!cd yolov5-deepsparse-blogpost/yolov5-train/ && python train.py \ --cfg ./models_v5.0/yolov5s.yaml \ --recipe ../recipes/yolov5s.pruned_quantized.md \ --data hand_gesture.yaml --hyp data/hyps/hyp.scratch.yaml \ --weights yolov5s.pt --img 640 --batch-size 32 --epochs 30 --optimizer Adam

61 epochs completed in 3.229 hours. Optimizer stripped from runs/train/exp2/weights/last.pt, 14.6MB Optimizer stripped from runs/train/exp2/weights/best.pt, 14.6MB

Validating runs/train/exp2/weights/best.pt... Fusing layers... YOLOv5s summary: 224 layers, 7091668 parameters, 0 gradients, 16.4 GFLOPs 2023-02-07 19:12:35 sparseml.optim.manager INFO Created recipe manager with metadata: { "metadata": null } Created recipe manager with metadata: { "metadata": null } Traceback (most recent call last): File "train.py", line 745, in main(opt) File "train.py", line 641, in main train(opt.hyp, opt, device, callbacks) File "train.py", line 514, in train model=loadcheckpoint(type='ensemble', weights=best, device=device)[0], File "/content/yolov5-deepsparse-blogpost/yolov5-train/export.py", line 529, in load_checkpoint state_dict = load_state_dict(model, state_dict, run_mode=not ensemble_type, exclude_anchors=exclude_anchors) File "/content/yolov5-deepsparse-blogpost/yolov5-train/export.py", line 553, in load_state_dict model.load_state_dict(state_dict, strict=not run_mode) # load File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1406, in load_state_dict raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format( RuntimeError: Error(s) in loading state_dict for Model: Missing key(s) in state_dict: "model.0.conv.conv.quant.activation_post_process.scale", "model.0.conv.conv.quant.activation_post_process.zero_point", "model.0.conv.conv.quant.activation_post_process.fake_quant_enabled", "model.0.conv.conv.quant.activation_post_process.observer_enabled", "model.0.conv.conv.quant.activation_post_process.scale", "model.0.conv.conv.quant.activation_post_process.zero_point",