WongKinYiu / yolov7

Implementation of paper - YOLOv7: Trainable bag-of-freebies sets new state-of-the-art for real-time object detectors
GNU General Public License v3.0
13.36k stars 4.21k forks source link

use “python detect.py --weights yolov7-mask.pt --conf 0.25 --img-size 640 --source video.mp4” to check the effects of segmentation, error pops: #661

Open grace2015 opened 2 years ago

grace2015 commented 2 years ago

detect.py --weights yolov7-mask.pt --conf 0.25 --img-size 640 --source video_shu.mp4 Namespace(agnostic_nms=False, augment=False, classes=None, conf_thres=0.25, device='', exist_ok=False, img_size=640, iou_thres=0.45, name='exp', no_trace=False, nosave=False, project='runs/detect', save_conf=False, save_txt=False, source='video_shu.mp4', update=False, view_img=False, weights=['yolov7-mask.pt']) YOLOR 🚀 2022-8-23 torch 1.12.1+cu102 CUDA:0 (TITAN Xp, 12196.0625MB) CUDA:1 (TITAN Xp, 12196.0625MB) CUDA:2 (TITAN Xp, 12196.0625MB) CUDA:3 (TITAN Xp, 12196.0625MB) CUDA:4 (TITAN Xp, 12196.0625MB) CUDA:5 (TITAN Xp, 12196.0625MB) CUDA:6 (TITAN Xp, 12196.0625MB) CUDA:7 (TITAN Xp, 12196.0625MB)

Traceback (most recent call last): File "/opt/share1/renliyun/Segmentation/yolov7-main/detect.py", line 195, in detect() File "/opt/share1/renliyun/Segmentation/yolov7-main/detect.py", line 34, in detect model = attempt_load(weights, map_location=device) # load FP32 model File "/opt/share1/renliyun/Segmentation/yolov7-main/models/experimental.py", line 242, in attempt_load ckpt = torch.load(w, map_location=map_location) # load File "/opt/share1/renliyun/miniconda3/envs/yolov7/lib/python3.7/site-packages/torch/serialization.py", line 712, in load return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args) File "/opt/share1/renliyun/miniconda3/envs/yolov7/lib/python3.7/site-packages/torch/serialization.py", line 1049, in _load result = unpickler.load() File "/opt/share1/renliyun/miniconda3/envs/yolov7/lib/python3.7/site-packages/torch/serialization.py", line 1042, in find_class return super().find_class(mod_name, name) AttributeError: Can't get attribute 'Merge' on <module 'models.common' from '/opt/share1/renliyun/Segmentation/yolov7-main/models/common.py'>

Process finished with exit code 1

ghost commented 2 years ago

Same error for me. Did you got any solution for it? Or can someone help us out??

meloRinkusu commented 2 years ago

Hello, Did you clone the main branch or the mask branch? https://github.com/WongKinYiu/yolov7/tree/mask I had the same issue as the common.py file from the main branch is indeed missing the Merge class, but switching to the mask branch for instance segmentation resolved it.