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

YOLOv5s Custom Model Inference in Raspberry Pi 4 Model B #13087

Open
1 task done
unraxesy opened this issue Jun 13, 2024 · 2 comments
Open
1 task done

YOLOv5s Custom Model Inference in Raspberry Pi 4 Model B #13087

unraxesy opened this issue Jun 13, 2024 · 2 comments
Labels
question Further information is requested

Comments

@unraxesy
Copy link

Search before asking

Question

Hi everyone and @glenn-jocher !
I have my own custom model best.pt that have been trained with my custom dataset. The dataset is done using Roboflow and the model is trained with Google Colab (local). All the data after training was saved on my PC. Now, I want to try inference on my Raspberry Pi, but I got some questions.

QUESTIONS

  1. Should I use local YOLOv5 repository that I used for training (copy the YOLOv5 local directory from my PC to Raspberry), or should I do YOLOv5 git clone (GitHub repo) on my Raspberry Pi?
  2. If copying local repository is the answer (since it contains crucial files including best.pt (custom model), data.yaml (dataset yaml), and etc), what if it isn't the latest one? How do I update the local repository?
  3. Should I use model = torch.hub.load("ultralytics/yolov5", "custom", path="path/to/best.pt") or model = torch.hub.load("path/to/yolov5", "custom", path="path/to/best.pt", source="local") if I want to try inference on Raspberry Pi? What is the difference between using local resource and ultralytics/yolov5?
  4. There are some unique files including data.yaml (/yolov5/datasets/data.yaml) and custom_yolov5s.yaml (/yolov5/models/custom_yolov5s.yaml). Is YOLOv5 automatically called them? Because we don't define them unlike best.pt.

Thank you!

Additional

No response

@unraxesy unraxesy added the question Further information is requested label Jun 13, 2024
Copy link
Contributor

👋 Hello @unraxesy, thank you for your interest in YOLOv5 🚀! Please visit our ⭐️ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution.

If this is a 🐛 Bug Report, please provide a minimum reproducible example to help us debug it.

If this is a custom training ❓ Question, please provide as much information as possible, including dataset image examples and training logs, and verify you are following our Tips for Best Training Results.

Requirements

Python>=3.8.0 with all requirements.txt installed including PyTorch>=1.8. To get started:

git clone https://github.com/ultralytics/yolov5  # clone
cd yolov5
pip install -r requirements.txt  # install

Environments

YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

Status

YOLOv5 CI

If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training, validation, inference, export and benchmarks on macOS, Windows, and Ubuntu every 24 hours and on every commit.

Introducing YOLOv8 🚀

We're excited to announce the launch of our latest state-of-the-art (SOTA) object detection model for 2023 - YOLOv8 🚀!

Designed to be fast, accurate, and easy to use, YOLOv8 is an ideal choice for a wide range of object detection, image segmentation and image classification tasks. With YOLOv8, you'll be able to quickly and accurately detect objects in real-time, streamline your workflows, and achieve new levels of accuracy in your projects.

Check out our YOLOv8 Docs for details and get started with:

pip install ultralytics

@glenn-jocher
Copy link
Member

@unraxesy hello!

Thank you for your detailed questions regarding running YOLOv5 inference on a Raspberry Pi 4 Model B. Let's address each of your queries:

  1. Repository Setup on Raspberry Pi:

    • It is generally recommended to clone the YOLOv5 repository directly on your Raspberry Pi using the command:
      git clone https://github.com/ultralytics/yolov5
      cd yolov5
      pip install -r requirements.txt
      This ensures you have the latest version of YOLOv5 and all necessary dependencies. You can then copy your custom model (best.pt), data.yaml, and any other custom files to the appropriate directories within this cloned repository.
  2. Updating Local Repository:

    • If you decide to copy your local repository, you can update it by navigating to the repository directory and running:
      git pull origin master
      pip install -r requirements.txt
      This will fetch and integrate the latest changes from the YOLOv5 GitHub repository.
  3. Model Loading for Inference:

    • For inference, you can use either of the following commands:
      model = torch.hub.load("ultralytics/yolov5", "custom", path="path/to/best.pt")
      or
      model = torch.hub.load("path/to/yolov5", "custom", path="path/to/best.pt", source="local")
      The first command loads the model from the Ultralytics GitHub repository, while the second command loads it from your local repository. If you have made custom modifications to the YOLOv5 code, you should use the local source option.
  4. Handling Custom Files (data.yaml and custom_yolov5s.yaml):

    • YOLOv5 does not automatically load data.yaml or custom model configuration files unless explicitly specified in your training or inference commands. Ensure that your data.yaml and custom model configuration files are correctly referenced in your scripts. For example, during training, you would specify the path to data.yaml:
      python train.py --data path/to/data.yaml --cfg path/to/custom_yolov5s.yaml --weights path/to/best.pt

For more detailed guidance on exporting and using YOLOv5 models, you can refer to the YOLOv5 Model Export Tutorial.

If you encounter any issues or have further questions, please provide a minimum reproducible example as outlined here. This will help us better understand and address your concerns.

Best of luck with your project on the Raspberry Pi! 😊

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

No branches or pull requests

2 participants