av-savchenko / face-emotion-recognition

Efficient face emotion recognition in photos and videos
Apache License 2.0
686 stars 127 forks source link

Error on CPU with enet_b2_8_best model #19

Closed ioctl-user closed 2 years ago

ioctl-user commented 2 years ago

There is following error while running enet_b2_8_best model on CPU with the latest git hse package:

...
    fer = HSEmotionRecognizer(model_name = model_name)
  File "/home/build/.local/lib/python3.10/site-packages/hsemotion/facial_emotions.py", line 49, in __init__
    model=torch.load(path)
  File "/home/build/.local/lib/python3.10/site-packages/torch/serialization.py", line 712, in load
    return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args)
  File "/home/build/.local/lib/python3.10/site-packages/torch/serialization.py", line 1049, in _load
    result = unpickler.load()
  File "/home/build/.local/lib/python3.10/site-packages/torch/serialization.py", line 1019, in persistent_load
    load_tensor(dtype, nbytes, key, _maybe_decode_ascii(location))
  File "/home/build/.local/lib/python3.10/site-packages/torch/serialization.py", line 1001, in load_tensor
    wrap_storage=restore_location(storage, location),
  File "/home/build/.local/lib/python3.10/site-packages/torch/serialization.py", line 175, in default_restore_location
    result = fn(storage, location)
  File "/home/build/.local/lib/python3.10/site-packages/torch/serialization.py", line 152, in _cuda_deserialize
    device = validate_cuda_device(location)
  File "/home/build/.local/lib/python3.10/site-packages/torch/serialization.py", line 136, in validate_cuda_device
    raise RuntimeError('Attempting to deserialize object on a CUDA '
RuntimeError: Attempting to deserialize object on a CUDA device but torch.cuda.is_available() is False. If you are running on a CPU-only machine, please use torch.load with map_location=torch.device('cpu') to map your storages to the CPU.

At that, model enet_b0_8_best_afew works fine with the same script on the same CPU.

av-savchenko commented 2 years ago

Thanks for letting me know. I fixed the issue and updated the latest code in the main branch. Please, kindly verify that it works now

ioctl-user commented 2 years ago

Fix works, thank you!