今天在运行pytorch 的时候,出现了下面的错误:

Traceback (most recent call last):
File "train.py", line 14, in <module>
from models.retinaface import RetinaFace
File "/media/data/projects/faceDetect/Face-Detector-1MB-with-landmark/models/retinaface.py", line 3, in <module>
import torchvision.models.detection.backbone_utils as backbone_utils
ModuleNotFoundError: No module named 'torchvision.models.detection'

解决方法

pip install torchvision==0.4

参考文献

[1].from torchvision.models.detection.faster_rcnn import FastRCNNPredictor builtins.ModuleNotFoundError: No module named 'torchvision.models'; 'torchvision' is not a package. ​​https://github.com/pytorch/vision/issues/1414​