AttributeError: module 'torchvision' has no attribute 'transforms'

代码:maskrcnn-benchmark

Python 3.6.13 |Anaconda, Inc

Traceback (most recent call last):
File "tools/train_net.py", line 18, in <module>
from maskrcnn_benchmark.engine.inference import inference
File "/home/Github/maskrcnn-benchmark/maskrcnn_benchmark/engine/inference.py", line 14, in <module>
from .bbox_aug import im_detect_bbox_aug
File "/home/Github/maskrcnn-benchmark/maskrcnn_benchmark/engine/bbox_aug.py", line 3, in <module>
import torchvision.transforms as TT
AttributeError: module 'torchvision' has no attribute 'transforms'

修改:

将import torchvision.transforms as TT修改为 from torchvision import transforms as TT,再次运行正常

过去已逝,未来太远,只争今朝
原文地址:https://www.cnblogs.com/BlogLwc/p/15663233.html