无法从 py-feat 初始化检测器 class 的对象
Can't initialize object of Detector class from py-feat
我尝试根据以下说明从视频中检测 FEX:
https://py-feat.org/content/detector.html#detecting-fex-from-videos
但是我无法初始化 Detector class 的对象。我使用的代码:
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
我收到以下错误:
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
我是 Python 的新手,这就是为什么我没有更改对象初始化中的任何参数的原因。没看懂分别是什么意思
P.S。也许有人知道,如何解决前 2 行的问题?
您的某个文件似乎已损坏。
您可以尝试打开目录C:\Users\User\AppData\Roaming\Python\Python39\site-packages\feat\resources\
解决问题
并删除文件 ResMaskNet_Z_resmasking_dropout1_rot30.pth
.
然后 运行 再次输入代码,它应该会重新下载已删除的文件。
前两行的警告只是一个警告,它表示库 nilearn
中的某些代码已被弃用。大多数时候你会忽略这一行,这可能会在未来的补丁中被 nilearn
的编码人员修复。
我尝试根据以下说明从视频中检测 FEX: https://py-feat.org/content/detector.html#detecting-fex-from-videos
但是我无法初始化 Detector class 的对象。我使用的代码:
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
我收到以下错误:
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
我是 Python 的新手,这就是为什么我没有更改对象初始化中的任何参数的原因。没看懂分别是什么意思
P.S。也许有人知道,如何解决前 2 行的问题?
您的某个文件似乎已损坏。
您可以尝试打开目录C:\Users\User\AppData\Roaming\Python\Python39\site-packages\feat\resources\
解决问题
并删除文件 ResMaskNet_Z_resmasking_dropout1_rot30.pth
.
然后 运行 再次输入代码,它应该会重新下载已删除的文件。
前两行的警告只是一个警告,它表示库 nilearn
中的某些代码已被弃用。大多数时候你会忽略这一行,这可能会在未来的补丁中被 nilearn
的编码人员修复。