我尝试根据以下说明从视频中检测FEX:https://py-feat.org/content/detector.html#detecting-fex-from-videos
但我无法初始化Detector类的对象。我使用的代码如下:
from feat import Detectorface_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
我得到了以下错误:
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: retinafaceUsing downloaded and verified file: C:\Users\User\AppData\Roaming\Python\Python39\site-packages\feat\resources\mobilenet0.25_Final.pthUsing downloaded and verified file: C:\Users\User\AppData\Roaming\Python\Python39\site-packages\feat\resources\mobilenet_224_model_best_gdconv_external.pth.tarUsing downloaded and verified file: C:\Users\User\AppData\Roaming\Python\Python39\site-packages\feat\resources\hog_pca_all_emotio.joblibUsing downloaded and verified file: C:\Users\User\AppData\Roaming\Python\Python39\site-packages\feat\resources\hog_pca_all_emotio.joblibUsing downloaded and verified file: C:\Users\User\AppData\Roaming\Python\Python39\site-packages\feat\resources\hog_scalar_aus.joblibUsing downloaded and verified file: C:\Users\User\AppData\Roaming\Python\Python39\site-packages\feat\resources\RF_568.joblibUsing downloaded and verified file: C:\Users\User\AppData\Roaming\Python\Python39\site-packages\feat\resources\hog_pca_all_emotio.joblibUsing downloaded and verified file: C:\Users\User\AppData\Roaming\Python\Python39\site-packages\feat\resources\hog_scalar_aus.joblibUsing downloaded and verified file: C:\Users\User\AppData\Roaming\Python\Python39\site-packages\feat\resources\ResMaskNet_Z_resmasking_dropout1_rot30.pthLoading Face Landmark model: mobilenetLoading au model: rfLoading emotion model: resmasknetTraceback (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
我是Python新手,所以我没有更改对象初始化的任何参数。我不明白每个参数的含义。
P.S. 还有人知道如何解决前两行的错误吗?
回答:
看起来你的一个文件可能已经损坏了。
你可以尝试通过打开目录C:\Users\User\AppData\Roaming\Python\Python39\site-packages\feat\resources\
并删除文件ResMaskNet_Z_resmasking_dropout1_rot30.pth
来解决这个问题。
然后再次运行代码,它应该会重新下载被删除的文件。
前两行的警告只是一个警告,它表示库nilearn
中的一些代码已被弃用。大多数情况下你可以忽略这一行,这可能会在nilearn
的未来补丁中由开发者修复。