Talented-Q / POSTER_V2

MIT License
112 stars 20 forks source link

not able to load model using torch #18

Closed NeoDhirendra closed 11 months ago

NeoDhirendra commented 12 months ago

i am loading the model and trying to convert the model into onnx , but i was getting this error. could you please tell me what's issue here?

pytorch version = 1.9.0+cu111 python version = 3.8.16 checkpoint = torch.load("/home/neoastra/Downloads/raf-db-model_best.pth") File "/home/neoastra/miniconda3/envs/yoga_val/lib/python3.8/site-packages/torch/serialization.py", line 607, in load return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args) File "/home/neoastra/miniconda3/envs/yoga_val/lib/python3.8/site-packages/torch/serialization.py", line 882, in _load result = unpickler.load() File "/home/neoastra/miniconda3/envs/yoga_val/lib/python3.8/site-packages/torch/serialization.py", line 875, in find_class return super().find_class(mod_name, name) AttributeError: Can't get attribute 'RecorderMeter1' on <module '__main__' from 'onnx_conversion.py'>

behradkhadem commented 11 months ago

I get the same error. Can you elaborate on the solution?

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
[<ipython-input-3-14510c58e132>](https://localhost:8080/#) in <cell line: 1>()
----> 1 model = torch.load('/content/affectnet-7-model_best.pth')

2 frames
[/usr/local/lib/python3.10/dist-packages/torch/serialization.py](https://localhost:8080/#) in find_class(self, mod_name, name)
   1163                     pass
   1164             mod_name = load_module_mapping.get(mod_name, mod_name)
-> 1165             return super().find_class(mod_name, name)
   1166 
   1167     # Load the data (which may in turn use `persistent_load` to load tensors)

AttributeError: Can't get attribute 'RecorderMeter1' on <module '__main__'>