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

Resurrection of the YOLO example #108

Merged
merged 3 commits into from
May 1, 2024
Merged

Resurrection of the YOLO example #108

merged 3 commits into from
May 1, 2024

Conversation

edwardalee
Copy link
Contributor

This PR resurrects the YOLO example in examples/python, which now work for me on Mac. It would be great if someone else could try them out, particularly on a machine with a CUDA-compatible GPU (although it works fine without it).

@lhstrh lhstrh changed the title Working Resurrection of the YOLO example Apr 14, 2024
@lhstrh
Copy link
Member

lhstrh commented Apr 14, 2024

I tried it, but it didn't work for me. I'm using Python 3.10 or ArchLinux.

---- System clock resolution: 1 nsec
Using cache found in /home/marten/.cache/torch/hub/ultralytics_yolov5_master
Downloading https://ultralytics.com/assets/Arial.ttf to /home/marten/.config/Ultralytics/Arial.ttf...
YOLOv5 🚀 2021-10-4 torch 2.2.2+cu121 CPU

Downloading https://github.com/ultralytics/yolov5/releases/download/v7.0/yolov5s.pt to /home/marten/.cache/torch/hub/ultralytics_yolov5_master/yolov5s.pt...
100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 14.1M/14.1M [00:02<00:00, 5.71MB/s]

Fusing layers... 
/home/marten/.local/lib/python3.10/site-packages/torch/functional.py:507: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at ../aten/src/ATen/native/TensorShape.cpp:3549.)
  return _VF.meshgrid(tensors, **kwargs)  # type: ignore[attr-defined]
Model Summary: 213 layers, 7225885 parameters, 0 gradients
Adding AutoShape... 

******* Press 'q' in the video window to exit *******

ERROR: FATAL: Calling reaction _dnn.reaction_function_1 failed.
Traceback (most recent call last):
  File "/home/marten/lf-lang/playground-lingua-franca/examples/Python/src-gen/YOLOv5/YOLOv5_Webcam/YOLOv5_Webcam.py", line 267, in reaction_function_1
    results = self._model(fr)
  File "/home/marten/.local/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1511, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "/home/marten/.local/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1520, in _call_impl
    return forward_call(*args, **kwargs)
  File "/home/marten/.local/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
    return func(*args, **kwargs)
  File "/home/marten/.cache/torch/hub/ultralytics_yolov5_master/models/common.py", line 337, in forward
    y = self.model(x, augment, profile)[0]  # forward
  File "/home/marten/.local/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1511, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "/home/marten/.local/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1520, in _call_impl
    return forward_call(*args, **kwargs)
  File "/home/marten/.cache/torch/hub/ultralytics_yolov5_master/models/yolo.py", line 124, in forward
    return self._forward_once(x, profile, visualize)  # single-scale inference, train
  File "/home/marten/.cache/torch/hub/ultralytics_yolov5_master/models/yolo.py", line 147, in _forward_once
    x = m(x)  # run
  File "/home/marten/.local/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1511, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "/home/marten/.local/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1520, in _call_impl
    return forward_call(*args, **kwargs)
  File "/home/marten/.cache/torch/hub/ultralytics_yolov5_master/models/yolo.py", line 67, 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 (56) at non-singleton dimension 3
../../bin/YOLOv5_Webcam: line 2: 2649161 Segmentation fault      (core dumped) /usr/bin/python3.10 /home/marten/lf-lang/playground-lingua-franca/examples/Python/src-gen/YOLOv5/YOLOv5_Webcam/YOLOv5_Webcam.py "$@"

@edwardalee
Copy link
Contributor Author

Do the video examples work for you?
I wonder this tensor size mismatch is because of some assumptions about the camera...

@lhstrh
Copy link
Member

lhstrh commented Apr 14, 2024

The video examples do work.

@edwardalee
Copy link
Contributor Author

Does it work in the main branch?

@lhstrh
Copy link
Member

lhstrh commented Apr 15, 2024

Does it work in the main branch?

Assuming that you mean main of this repository, no, I get the same error.

@lf-lang lf-lang deleted a comment from lhstrh Apr 22, 2024
@lf-lang lf-lang deleted a comment from lhstrh Apr 22, 2024
Copy link
Member

@lhstrh lhstrh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These look like good improvements!

@lhstrh lhstrh merged commit 2fd32be into main May 1, 2024
5 checks passed
@lhstrh lhstrh deleted the working branch May 1, 2024 21:53
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

Successfully merging this pull request may close these issues.

2 participants