av-savchenko / hsemotion

HSEmotion Python library for facial expression recognition
Apache License 2.0
25 stars 7 forks source link

ModuleNotFoundError: No module named 'timm.models.layers.conv2d_same' #4

Open aldemards opened 1 year ago

aldemards commented 1 year ago

ModuleNotFoundError Traceback (most recent call last) Cell In[14], line 7 2 model_name='enet_b0_8_best_afew' 3 #model_name='enet_b0_8_best_vgaf' 4 #model_name='enet_b0_8_va_mtl' 5 #model_name='enet_b2_8' ----> 7 fer=HSEmotionRecognizer(model_name=model_name,device=device)

File ~\Documents\code\hsemotion\env\lib\site-packages\hsemotion\facial_emotions.py:49, in HSEmotionRecognizer.init(self, model_name, device) 39 self.test_transforms = transforms.Compose( 40 [ 41 transforms.Resize((self.img_size,self.img_size)), (...) 45 ] 46 ) 48 path=get_model_path(model_name) ---> 49 model=torch.load(path) 50 if isinstance(model.classifier,torch.nn.Sequential): 51 self.classifier_weights=model.classifier[0].weight.cpu().data.numpy()

File ~\Documents\code\hsemotion\env\lib\site-packages\torch\serialization.py:809, in load(f, map_location, pickle_module, weights_only, pickle_load_args) 807 except RuntimeError as e: 808 raise pickle.UnpicklingError(UNSAFE_MESSAGE + str(e)) from None --> 809 return _load(opened_zipfile, map_location, pickle_module, pickle_load_args) 810 if weights_only: 811 try:

File ~\Documents\code\hsemotion\env\lib\site-packages\torch\serialization.py:1172, in _load(zip_file, map_location, pickle_module, pickle_file, pickle_load_args) 1170 unpickler = UnpicklerWrapper(data_file, pickle_load_args) 1171 unpickler.persistent_load = persistent_load -> 1172 result = unpickler.load() 1174 torch._utils._validate_loaded_sparse_tensors() 1176 return result

File ~\Documents\code\hsemotion\env\lib\site-packages\torch\serialization.py:1165, in _load..UnpicklerWrapper.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)

ModuleNotFoundError: No module named 'timm.models.layers.conv2d_same'

av-savchenko commented 1 year ago

Hello! Thanks for your interest! The problem was caused by modifications of efficientnet structure in timm library. I converted my models to the new format suitable for timm 0.9.7. You can test it now. Please, do not forget to remove cached models in your ~/.hsemotion forlder