已安装facenet_pytorch但无法导入InceptionResNetV1求助
解决
ImportError: cannot import name 'InceptionResNetV1' from 'facenet_pytorch' 的方法 以下是几个可行的解决方案,按优先级尝试:
修改导入路径
新版本的facenet_pytorch调整了模块结构,模型类被移到了models子模块中,直接从子模块导入即可:from facenet_pytorch import MTCNN from facenet_pytorch.models import InceptionResNetV1安装指定兼容版本
如果你依赖的代码是基于旧版本facenet_pytorch编写的,可以卸载当前版本,安装0.5.2版本(该版本支持顶层导入InceptionResNetV1):pip uninstall -y facenet_pytorch pip install facenet_pytorch==0.5.2重新安装并升级
有时候Colab中的安装可能存在缓存或不完整的情况,重新安装并升级模块:pip install --upgrade --force-reinstall facenet_pytorch
内容的提问来源于stack exchange,提问作者Beryl Amend
相关产品推荐
相关产品推荐

