This GitHub repository show real-time object detection using a Raspberry Pi, MobileNetSSDv2 TensorFlow Lite model, LED indicators, and an LCD display. the feature of this project include:
- Show fps for each detection
- Output the class using LED for each class (there is 5 classes: car, person, truck, bus, motorbike)
- Show CPU and temperature of raspberry pi using LCD 16x02.
Below is the following demo video showcasing the Raspberry Pi in action. When real-time object detection processed, video frames show the fps, LED indicators will trun on based on detected classes, and CPU usage and temperature information displayed on the LCD screen.
- Raspberry Pi 4 (I'm using 8 GB version)
- Raspberry Pi OS 11 Bulleyes 64-bit
- Pi Camera v2/v1/Web-Camera
- PCB or PCB Dot
- LCD 16x2 Biru/Blue 1602 SPI I2C
- ✨ Wiring cable ✨
Follow this organized table to establish the proper connections, you can also read the reference here GPIO on Raspberry Pi4.
LED Wiring - Raspberry Pi
| Wire Color | GPIO Pin |
|---|---|
| Red | GPIO 17 |
| Green | GPIO 18 |
| Yellow | GPIO 23 |
| Cyan | GPIO 27 |
| White | GPIO 22 |
| Black (GND) | GND |
I2C Wiring - Raspberry Pi
| Wire Color | Connection |
|---|---|
| Red | 5V |
| Black | GND |
| Purple | SDA |
| Brown | SCL |
To run this project, you need Python 3.5 or higher installed on your system. Follow these steps to get started:
- Clone the repository and navigate to the project directory: :
git clone https://github.com/kiena-dev/Raspberry-PI-MobileNetSSDv2-tflite-LED.git
cd Raspberry-PI-MobileNetSSDv2-tflite-LED- Create a Python virtual environment (optional but recommended):
python3 -m venv venv- Activate the virtual environment:
source venv/bin/activate- Install the required dependencies using pip3:
pip3 install -r get_requirement.txtNow you have successfully installed the project and its dependencies.
Video Usage
Default (without LED/LCD):
python3 RPI_detect_video.py --modeldir=mobilenetssd_320 --video=video_test.mp4 --graph=detect.tfliteWith LED/LCD:
python3 RPI_detect_video_led.py --modeldir=mobilenetssd_320 --video=video_test.mp4 --graph=detect.tfliteImage Usage
python3 RPI_detect_image.py --modeldir=mobilenetssd_320 --graph=detect.tflite --imagedir=image --save_resultsRemove --save_results if you don't want to save images and change --graph to switch the model.
Webcam Usage
Default (without LED/LCD):
python3 RPI_detect_webcam.py --modeldir=mobilenetssd_320 --graph=detect.tfliteWith LED/LCD:
python3 RPI_detect_webcam_led.py --modeldir=mobilenetssd_320 --graph=detect.tfliteChange --modeldir to modify the model file location as needed.
If you want to train your own model, you can utilize the resource provided below:
Reference Jupyter Notebook File:
Dataset from Roboflow:
Be sure to make use of these resources to train your model and achieve optimal results!
Special thanks to the following resources that inspired and contributed to this project:

