Home > Software engineering >  Can't initialize object of Detector class from py-feat
Can't initialize object of Detector class from py-feat

Time:03-20

I try to detecting FEX from videos according to this instruction: https://py-feat.org/content/detector.html#detecting-fex-from-videos

But I can't initialize object of Detector class. Code that I use:

from feat import Detector

face_model = "retinaface"
landmark_model = "mobilenet"
au_model = "rf"
emotion_model = "resmasknet"
detector = Detector(face_model=face_model, landmark_model=landmark_model, au_model=au_model,
                    emotion_model=emotion_model)

if __name__ == '__main__':
    pass

And I get the following errors:

C:\Users\User\AppData\Roaming\Python\Python39\site-packages\nilearn\input_data\__init__.py:27: FutureWarning: The import path 'nilearn.input_data' is deprecated in version 0.9. Importing from 'nilearn.input_data' will be possible at least until release 0.13.0. Please import from 'nilearn.maskers' instead.
  warnings.warn(message, FutureWarning)
Loading Face Detection model:  retinaface
Using downloaded and verified file: C:\Users\User\AppData\Roaming\Python\Python39\site-packages\feat\resources\mobilenet0.25_Final.pth
Using downloaded and verified file: C:\Users\User\AppData\Roaming\Python\Python39\site-packages\feat\resources\mobilenet_224_model_best_gdconv_external.pth.tar
Using downloaded and verified file: C:\Users\User\AppData\Roaming\Python\Python39\site-packages\feat\resources\hog_pca_all_emotio.joblib
Using downloaded and verified file: C:\Users\User\AppData\Roaming\Python\Python39\site-packages\feat\resources\hog_pca_all_emotio.joblib
Using downloaded and verified file: C:\Users\User\AppData\Roaming\Python\Python39\site-packages\feat\resources\hog_scalar_aus.joblib
Using downloaded and verified file: C:\Users\User\AppData\Roaming\Python\Python39\site-packages\feat\resources\RF_568.joblib
Using downloaded and verified file: C:\Users\User\AppData\Roaming\Python\Python39\site-packages\feat\resources\hog_pca_all_emotio.joblib
Using downloaded and verified file: C:\Users\User\AppData\Roaming\Python\Python39\site-packages\feat\resources\hog_scalar_aus.joblib
Using downloaded and verified file: C:\Users\User\AppData\Roaming\Python\Python39\site-packages\feat\resources\ResMaskNet_Z_resmasking_dropout1_rot30.pth
Loading Face Landmark model:  mobilenet
Loading au model:  rf
Loading emotion model:  resmasknet
Traceback (most recent call last):
  File "C:\Users\User\Desktop\DetectFEXFromVideos\main.py", line 7, in <module>
    detector = Detector(face_model=face_model, landmark_model=landmark_model, au_model=au_model,
  File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\feat\detector.py", line 227, in __init__
    self.emotion_model = ResMaskNet()
  File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\feat\emo_detectors\ResMaskNet\resmasknet_test.py", line 748, in __init__
    torch.load(
  File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\torch\serialization.py", line 713, in load
    return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
  File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\torch\serialization.py", line 938, in _legacy_load
    typed_storage._storage._set_from_file(
RuntimeError: unexpected EOF, expected 32606425 more bytes. The file might be corrupted.

Process finished with exit code 1

I'm new to Python, that's why I didn't change any arguments in object initialize. Don't understand what each means.

P.S. And maybe anyone know, how to fix problem in 2 first rows?

CodePudding user response:

It looks like one of your files was corrupted.

You can try to solve the problem by opening the directory C:\Users\User\AppData\Roaming\Python\Python39\site-packages\feat\resources\ and deleting the file ResMaskNet_Z_resmasking_dropout1_rot30.pth.

Then run again the code and it should redownload the deleted file.

The warning in the first two lines is just a warning, it's saying that some of the code in the library nilearn is deprecated. Most of the times you would just ignore this line, this will be probably fixed by the coders of nilearn in a future patch.

  • Related