tensorturtle / classy-sort-yolov5

Ready-to-use realtime multi-object tracker that works for any object category. YOLOv5 + SORT implementation.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error when place newest yolo5 code

pangafu opened this issue · comments

python classy_track.py --source ../videoes/cctv1.avi --view-img --save-img
WARNING: --img-size 1080 must be multiple of max stride 32, updating to 1088
Namespace(agnostic_nms=False, augment=False, classes=[0], conf_thres=0.3, device='', fourcc='mp4v', img_size=1088, iou_thres=0.4, output='inference/output', save_img=True, save_txt=False, sort_iou_thresh=0.2, sort_max_age=5, sort_min_hits=2, source='../videoes/cctv1.avi', view_img=True, weights='yolov5/weights/yolov5x.pt')
Traceback (most recent call last):
File "classy_track.py", line 306, in
detect(args)
File "classy_track.py", line 152, in detect
_ = model(img.half() if half else img) if device.type != 'cpu' else None
File "/home/yuanquan/anaconda3/envs/py38/lib/python3.8/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
result = self.forward(*input, **kwargs)
File "/home/yuanquan/human/classy-sort-yolov5/./yolov5/models/yolo.py", line 117, in forward
return self.forward_once(x, profile) # single-scale inference, train
File "/home/yuanquan/human/classy-sort-yolov5/./yolov5/models/yolo.py", line 148, in forward_once
x = m(x) # run
File "/home/yuanquan/anaconda3/envs/py38/lib/python3.8/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
result = self.forward(*input, **kwargs)
File "/home/yuanquan/human/classy-sort-yolov5/./yolov5/models/yolo.py", line 55, in forward
if self.inplace:
File "/home/yuanquan/anaconda3/envs/py38/lib/python3.8/site-packages/torch/nn/modules/module.py", line 947, in getattr
raise AttributeError("'{}' object has no attribute '{}'".format(
AttributeError: 'Detect' object has no attribute 'inplace'

Hi @pangafu , thank you for your interest.

According to this link describing a similar problem
You should download the newest weights from the YOLOv5 official repo
Copy the new weights to the models folder and see if you still get the error.

I think that the explanation is: Ultralytics often updates the YOLOv5 model with new kinds of activation functions and neural network layer types, and so you have to make sure to download the correct pretrained models for that specific architecture.