feiyuhuahuo / Yolact_minimal

Minimal PyTorch implementation of YOLACT.
237 stars 70 forks source link

detec.py出错,出错信息如下 #32

Closed clannadcl closed 3 years ago

clannadcl commented 3 years ago

Traceback (most recent call last):
File "detect.py", line 73, in
ids_p, class_p, box_p, coef_p, proto_p = nms(class_p, box_p, coef_p, proto_p, net.anchors, cfg)
File "/root/paddlejob/workspace/env_run/video_tag/code/yolact/utils/output_utils.py", line 153, in nms
box_thre = torch.clip(box_thre, min=0., max=1.)
AttributeError: module 'torch' has no attribute 'clip'

feiyuhuahuo commented 3 years ago

What is your PyTorch version?

JianJingGao commented 3 years ago

@feiyuhuahuo i have same error,pytorch 1.6

JianJingGao commented 3 years ago

change version to pytorch 1.9, i's ok

Zhang-Jing-Xuan commented 3 years ago

Don't need to change the version of pytorch. Just change

box_thre = torch.clip(box_thre, min=0., max=1.) # Yolact_minimal/utils/output_utils.py line 150+

to

box_thre = torch.clamp(box_thre, min=0., max=1.) # pytorch 1.5.0

or to

tmp = np.clip(box_thre.cpu().numpy(),a_min=0., a_max=1.) # numpy 1.21.1
box_thre =torch.from_numpy(tmp).cuda()
# box_thre = torch.clip(box_thre, min=0., max=1.)