Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with trained YOLOv5 model from latest version #1

Open
m-ali-awan opened this issue Apr 24, 2022 · 9 comments
Open

Error with trained YOLOv5 model from latest version #1

m-ali-awan opened this issue Apr 24, 2022 · 9 comments

Comments

@m-ali-awan
Copy link

I am getting this error:

RuntimeError: The size of tensor a (80) must match the size of tensor b (84) at non-singleton dimension 3

I am not sure, whether this is due to the latest version or not, but that's what I think. Because similar issues are there in Roboflow Zero-Shot-tracking.
So kindly help me with this.
Thanks

@sithu31296
Copy link
Owner

Can you show me the detail error? like line number? where did the error occur?

@m-ali-awan
Copy link
Author

Yes sure.
Thanks for getting back to me.

Traceback (most recent call last):
  File "track.py", line 144, in <module>
    output = tracking.predict(frame.numpy())
  File "/usr/local/lib/python3.7/dist-packages/torch/autograd/grad_mode.py", line 28, in decorate_context
    return func(*args, **kwargs)
  File "track.py", line 89, in predict
    pred = self.model(img)[0]  
  File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "yolov5/models/yolo.py", line 123, in forward
    return self.forward_once(x, profile, visualize)  # single-scale inference, train
  File "yolov5/models/yolo.py", line 155, in forward_once
    x = m(x)  # run
  File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "yolov5/models/yolo.py", line 64, in forward
    y[..., 2:4] = (y[..., 2:4] * 2) ** 2 * self.anchor_grid[i]  # wh
RuntimeError: The size of tensor a (80) must match the size of tensor b (84) at non-singleton dimension 3

@m-ali-awan
Copy link
Author

Also I used following command:

!python track.py --source $VIDEO_PATH --yolo-model /content/drive/MyDrive/ClientsWork/YepiWork/Fall\ Zone\ Detection\ Work/ModelsDir/15April_yolov5_large_640_24_500_coco_0.807.pt --reid-model CLIP-RN50

And it is taking too much RAM, around 20 GB, I think. Is this normal?

@sithu31296
Copy link
Owner

sithu31296 commented Apr 24, 2022

The above error is not related with tracking part. Are you sure you can run the model fine with detection code alone in latest yolov5 code? If you can run fine, you need to clone the new version and change the yolov5 model loading part in track.py. They might update it. So, I am not sure if it is the same.

@sithu31296
Copy link
Owner

If you inference on video and the video is taking too long, the RAM usage will be high. Because the processed frame will be accumulated until the video's end to be able to write the output video with torchvision.io. You can also change the video reading and writing function. I chose the torchvision as it is easier to read and no need to install other tool just for read/write function.

@m-ali-awan
Copy link
Author

But I have done the detections with YOLOv5, they is no problem with that.

@BarRozenman
Copy link

I found that the latest version of YOLO is not compatible with this project and you should download the YOLO weights from here "https://github.com/ultralytics/yolov5/releases/tag/v5.0" for example you can use this link "https://github.com/ultralytics/yolov5/releases/download/v5.0/yolov5l.pt"

@sithu31296
Copy link
Owner

I forgot to include the version of the yolo model. At the time of my testing, there is only v4.0. So, you can use v4 weights or just edit the code in track.py to be compatible with v5.

@hasibzunair
Copy link

@BarRozenman works fine with weights from https://github.com/ultralytics/yolov5/releases/tag/v4.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants