from maskrcnn_benchmark.layers import Conv2d File "D:\Anacoda\envs\maskrcnn\lib\site-packages\maskrcnn_benc_error t">
赞
踩
运行maskrcnn的demo时报错:
File "D:\Anacoda\envs\maskrcnn\lib\site-packages\maskrcnn_benchmark\modeling\make_layers.py", line 10, in <module>
from maskrcnn_benchmark.layers import Conv2d
File "D:\Anacoda\envs\maskrcnn\lib\site-packages\maskrcnn_benchmark\layers\__init__.py", line 13, in <module>
from .roi_pool import ROIPool
File "D:\Anacoda\envs\maskrcnn\lib\site-packages\maskrcnn_benchmark\layers\roi_pool.py", line 10, in <module>
from apex import amp
File "D:\Anacoda\envs\maskrcnn\lib\site-packages\apex-0.1-py3.6-win-amd64.egg\apex\__init__.py", line 5, in <module>
from . import parallel
File "D:\Anacoda\envs\maskrcnn\lib\site-packages\apex-0.1-py3.6-win-amd64.egg\apex\parallel\__init__.py", line 8, in <module>
ReduceOp = torch.distributed.deprecated.reduce_op
AttributeError: module 'torch.distributed' has no attribute 'deprecated'
找到报错中定位的apex文件位置,如
from .roi_pool import ROIPool
File "D:\Anacoda\envs\maskrcnn\lib\site-packages\maskrcnn_benchmark\layers\roi_pool.py", line 10, in <module>
点击进入roi_pool和roi_align.py文件,注释掉
from maskrcnn_benchmark import _C
# from apex import amp
# @amp.float_function
def forward(self, input, rois):
return roi_pool(input, rois, self.output_size, self.spatial_scale)
将nms.py文件
from maskrcnn_benchmark import _C
from apex import amp
# Only valid with fp32 inputs - give AMP the hint
nms = amp.float_function(_C.nms)
更改为
rom maskrcnn_benchmark import _C
# from apex import amp
# Only valid with fp32 inputs - give AMP the hint
# nms = amp.float_function(_C.nms)
nms=_C.nms
之后使用命令
python webcam.py --min-image-size 224
就可以不依赖apex运行 demo
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。