Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

export.py error #19

Open
dani3l125 opened this issue Mar 16, 2023 · 2 comments
Open

export.py error #19

dani3l125 opened this issue Mar 16, 2023 · 2 comments

Comments

@dani3l125
Copy link

Hello,
Thank you for the useful repository!
I am trying to export a model quantized and pretrained by deepsparse into onnx and getting an error.
The model: yolov5n6

The command: python yolov5-train/export.py --weights yolov5n_sparse.pt --include onnx tflite --imgsz 480 640 --simplify --dynamic

The error:
Traceback (most recent call last): File "yolov5-train/export.py", line 715, in <module> main(opt) File "yolov5-train/export.py", line 704, in main run(**vars(opt)) File "/home/daniel/miniconda3/envs/torch2onnx/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 28, in decorate_context return func(*args, **kwargs) File "yolov5-train/export.py", line 593, in run model, extras = load_checkpoint(type_='ensemble', weights=weights, device=device) # load FP32 model File "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 "yolov5-train/export.py", line 553, in load_state_dict model.load_state_dict(state_dict, strict=not run_mode) # load File "/home/daniel/miniconda3/envs/torch2onnx/lib/python3.8/site-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.weight", "model.0.bn.weight", "model.0.bn.bias", "model.0.bn.running_mean", "model.0.bn.running_var", "model.1.conv.weight", "model.1.bn.weight", "model.1.bn.bias", "model.1.bn.running_mean", "model.1.bn.running_var", "model.2.cv1.conv.weight", ...

Any support would be much appreciated (:

@dnth
Copy link
Owner

dnth commented Mar 18, 2023

What about the older version on yolov5n ? Can you export those?

@dani3l125
Copy link
Author

The original yolov5n.pt and yolov5n6.pt the exports are successful.
The sparsified version of the older version - yolov5n - returns similar error.

It seems like the export file expects only a dictionary that matches the original model's layers and is not compatible with the quantized layers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants