Giter Club home page Giter Club logo

yolov5-export-to-raspberry-pi's Introduction

Yolov5 export to Raspberry Pi

img

It is a two step process:

  1. Convert model weights to tflite
  2. Run the inference on Raspberry Pi

Convert Model Weights to tflite

If you don't want to install anything on your system then use this Google Colab (Recommended). Open In Colab

And if you want to perform the conversion on your system then follow bellow instructions:

I recommend create a new conda environment for this as we need python==3.7.0 for this:

conda create -n yolov5_env python==3.7.0
conda activate yolov5_env

Then run below commands and replace yolov5s.pt with your own model path and also change yolov5s.yaml accordingly.

git clone https://github.com/ultralytics/yolov5.git
cd yolov5
pip3 install tensorflow==2.3.1
pip install -r requirements.txt
python3 export.py --weights yolov5s.pt --img 418 --batch 1 --include onnx tflite

Run the inference on Raspberry Pi

Just clone this repository and we are good to go:

git clone https://github.com/karanjakhar/yolov5-export-to-raspberry-pi.git
cd yolov5-export-to-raspberry-pi
chmod +x setup.sh
./setup.sh
python3 yolov5_tflite_folder_of_images_inference.py --weights yolov5s-fp16.tflite --folder_path images/ 

Move your own model tflite file to raspberry pi and use that with above command.

yolov5_tflite_inference.py this file contains main inference code which you can use with your own project.

Other files show examples how to use it. I have placed a tflite file and some sample images to run a quick test.

To Run Examples:

For webcam:

python3 yolov5_tflite_webcam_inference.py -w yolov5s-fp16.tflite

For image:

python3 yolov5_tflite_image_inference.py -w yolov5s-fp16.tflite -i images/bus.jpg

For video:

python3 yolov5_tflite_video_inference.py -w yolov5s-fp16.tflite -v <your video path>

For folder of images:

python3 yolov5_tflite_folder_of_images_inference.py -w yolov5s-fp16.tflite -f images/

yolov5-export-to-raspberry-pi's People

Contributors

karanjakhar avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.