Skip to content

About

Raspberry PI5 running Hailo model with a FastAPI server.

Resources

Stars

2 stars

Watchers

1 watching

Forks

Latest commit

 

History

60 Commits

Folders and files

Repository files navigation

Raspberry Pi 5 Running Hailo Model with a FastAPI Server

I’m using a Raspberry Pi 5 with a Hailo AI chip to detect objects in a video and stream the results live to a web page. All processing is done locally on the device using a Raspberry Pi 5 with the Hailo8L AI accelerator

My latest project raspberry_PI5_hailo_web_app, where I trained a custom YOLO 11 nano object detection model and deployed it on a Raspberry Pi 5 equipped with a Hailo AI accelerator. The system performs real-time object detection on video streams and broadcasts the annotated output to a web page via FastAPI.

I load all model, compiled for the Hailo-8L accelerator, using the DeGirum SDK.

If you find a mistake, feel free to drop a comment or open an issue on GitHub. Thanks!

Video demonstration Wep_app:

In brief:
The browser capture camera frames and streams them to the server using WebRTC. The server runs object detection and streams the annotated video back to the user.

alt text

Demo 1 using Hailo Yolo11 nano model

alt text

Demo 2 using Hailo Yolo8 nano model

alt text

Repository Structure

Here’s the revised Repository Structure section with your added detail about the training guide:

  • HTTP directory – HTTP Streaming: Streams processed video frames to clients using the MJPEG format via FastAPI routes.
  • WebSocket directory – WebSocket Streaming: Streams processed video frames to clients over WebSocket via FastAPI routes.
  • Webcam directory – Webcam Streaming: Captures video from a webcam, processes it, and streams the annotated frames to clients over WebSocket via FastAPI routes.
  • Wep_app directory – User-friendly real-time video loop web application.
  • raspberry_PI5_hailo_web_app directory – Contains the custom-trained YOLO 11 nano object detection model with a guide on how to train your own, along with a complete front-end interface for interacting with the streaming server and viewing AI detection results live.

Functionality Overview

  1. Initialize the AI Model:

    • Load the YOLOv8n/YOLOv11n Hailo model tailored for the Hailo8L device using the DeGirum SDK.
    • Configure the model with appropriate parameters such as inference host address and device types using the DeGirum SDK.
  2. Process Video Input:

    • Open a video file or stream as the input source.
    • Read frames sequentially, perform object detection inference on each frame, and overlay the detection results on bounding boxes and labels using DeGirum SDK.
  3. Stream Processed Video:

    • Serve the processed frames over HTTP or WebSocket using FastAPI.
    • Implement an endpoint in order to view the real-time video stream with inference results.

Setting Up and Running the Application

To set up and run the application:

  1. Install DeGirum SDK:

  2. Activate the virtual environment:

    source degirum_env/bin/activate
  3. Install requirements dependencies

    pip install fastapi uvicorn degirum degirum_tools
  4. Clone my repo:

    git clone https://github.com/PiWebswiss/raspberry_PI5_hailo.git
    cd raspberry_PI5_hailo

    Then, go to the file directory Webcam ,WebSocket or HTTP using cd <path>.

  5. Run the FastAPI Server:

    uvicorn main:app --host 0.0.0.0 --port 8000
  6. Access the Video Stream:

    • Open a web browser and navigate to http://127.0.0.1:8001/ to view the AI-processed video stream.

Additional Notes

  • Hardware Requirements:
    • A Raspberry Pi 5 with the Hailo8L AI accelerator.

About

Raspberry PI5 running Hailo model with a FastAPI server.

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages