-
Notifications
You must be signed in to change notification settings - Fork 202
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
Quantizing Yolov7 #627
Comments
Hi, torch.save(model.state_dict(), wdir / 'init.pt') at line 306 of We are aware that QuantModules might be incompatible with pickling, however the cases where you need to save your model like that are rare, while it's more common to save only the state dict of a torch model. There should not be any issue in saving the state dict of a model quantized with Brevitas. Please let me know if that fixes your issue. Giuseppe |
Hi, Sorry for being to late to respond to this issue, it works fine while saving and loading state_dict, I currently tried it on Yolov5 and it is perfect. Thank you very much for your help |
Sorry for the bothering. @IsmailAM1999 When the training phase have done, the error involves the
Have you encounter this problem? How do you solve it? Best regards, thanks for your time and your interest in my request. |
Hi @TCGoingW , Exactly I got the same error at this point, I do not have the code right now but I can tell you the steps : You need to change few things on the function , instead of load an Ensemble, load directly the Model first, then load your weights with load_state_dict function. then extract the keys you need (ema,model...). I also advise you to clean every weights transformation(.half( ) ) it can bug your code. I hope this can be useful and keep me in touch if it does work or not. Good luck ! |
Hi! @IsmailAM1999 Can you please be more specific about the parts that removing the Ensemble, loading weights with load_state_dict function and extracting the keys I need? I'm a little clueless :( If you can provide code to explain, I would be very grateful! Sincerely, |
Sorry for bothering again. @IsmailAM1999
The
I don't know the modify code is meet your suggestions or not. Sincerely, |
Hi @TCGoingW , Sorry for not being available these days, since you saved model state dict , you need to load the model first then load state dict, Here is my version of the function attempt_load, I hope it could help you to better understand : Code`def attempt_load(weights, cfg, device=None, inplace=True, fuse=True):
No bothers, Ask whenever you want. Good luck ! |
Update with good news!!
|
Hi @TCGoingW , Sorry for my late response, when you use quant layers, try with "return_quant_tensor=False", I think it will solve the problem. I am also interested with your results (mainly mAP values ). We can discuss this more in private if you want. You can contact me here : [email protected] Edit : I used the same implemented method by the way |
Hi @IsmailAM1999, @TCGoingW, |
Dear readers,
Thank you for your hard work and for providing such an interesting library.
Actually, I am working on quantization, especially on the YOLOv7 module. I made a small change in the 'Conv' class in common.py. I replaced Conv2d with QuantConv2d without changing any parameters. Here is the modified code:
However, when I try to train the model, I encounter the following error:
Has anyone experienced this kind of pickle error in YOLOv7 or any other object detection model?
Thank you very much for your time and your interest in my request.
The text was updated successfully, but these errors were encountered: