FitAI: Raspberry Pi Fitness Assistant Using YOLOv8
39 Views, 0 Favorites, 0 Comments
FitAI: Raspberry Pi Fitness Assistant Using YOLOv8

FitAI is a smart fitness assistant powered by AI and Raspberry Pi. It detects whether your biceps or quads are strong or weak using an image, video, or webcam feed. But it doesn't stop at detection. It also helps you train and improve.
When the system detects, for example, a Weak Bicep, it:
- Displays “Weak Bicep” on a 16x2 I²C LCD.
- Plays a specific training video on a 7-inch touchscreen showing how to strengthen that muscle.
You get instant AI feedback + personalized fitness advice in one compact setup!
Supplies




Raspberry Pi 5: Hosts the LCD screen and 7-inch video display. Receives detection labels from the PC and plays the correct workout video.
USB Webcam: Captures live video of the user for muscle detection.
I²C LCD Display (16x2): Displays detection output (e.g., "Weak Bicep") based on YOLOv8 results sent from the PC.
7-inch Touchscreen: Shows a full-screen workout video (e.g., how to strengthen weak biceps) based on the detected label.
PC or Laptop: Runs the Gradio interface and YOLOv8 detection model. It handles image/video/webcam input and sends muscle labels (like "strong quad") to the Raspberry Pi via HTTP.
Python + YOLOv8: Python is used to write all backend logic. YOLOv8 is the object detection model that classifies the muscles as strong or weak.
Gradio: Provides a user interface for uploading an image, video, or using the webcam live. Displays the detection label before sending it to the Raspberry Pi.
Flask (on Raspberry Pi): Receives the detection label from the PC and plays the corresponding video using ffplay.
ffplay (part of ffmpeg): Lightweight video player used on the Raspberry Pi to show videos in fullscreen on the touchscreen.
Total estimated cost: €309,42. Full Bill of Materials with links and sources is included in the attached BOM PDF.
Downloads
Take Photos & Record Videos




Take multiple photos of your arms and legs.
Vary the backgrounds and maintain a consistent pose.
Create 4 exercise videos, one for each category:
- Weak Bicep
- Strong Bicep
- Weak Quad
- Strong Quad
Upload to Roboflow
Create a new Instance Segmentation project in Roboflow.
Upload your photos.
Annotate Your Dataset
Use Roboflow’s segmentation tool to label each image accurately.
Create a Version
Go to the Versions tab → click Create New Version.
In Preprocessing, enable:
- Grayscale
In Augmentations, enable:
- Flip, Crop, Rotation, Shear, Brightness, Exposure, Blur
Click Create Version.
Export Your Dataset

Choose YOLOv8 format.
Click Show Download Code and copy it.
Download Dataset in Python
Paste the code into a Python script in VS Code.
Run the script to download your dataset locally.
Train Your Model
Start with:
- Model: yolov8n-seg.pt (nano version)
- Epochs: 50
After successful testing, switch to:
- Model: yolov8m-seg.pt (medium version)
Test the Model

Write a script to:
- Open your webcam.
- Run real-time predictions using the trained YOLOv8 model.
Set Up Raspberry Pi Hardware

Required:
- Raspberry Pi 5
- 16x2 I²C LCD
- 7-inch HDMI Touchscreen
- Freenove GPIO expansion board (optional for easier connections)
Write Raspberry Pi Scripts
Create the following Python files:
- lcd_server.py – Displays the detected label (e.g., “Strong Quad”) on the LCD.
- video_server.py – Plays the correct training video based on the label.
- client_pi.py – Streams the Pi’s webcam over HTTP.
All these use Flask to receive requests from the PC.
Create the Gradio UI (on PC)



- Your Gradio app has 3 tabs:
- Image – Upload and detect from a photo.
- Video – Upload and process a video (first frame triggers feedback).
- Webcam – View live detection and press "Take Photo" to trigger feedback.
Each mode:
- Sends the label to the LCD and
- Plays the matching training video on the Pi touchscreen.
Connect the 7-inch Display

Plug:
- USB power cable into the Pi
- HDMI (or micro HDMI) from Pi to screen
- USB-C for touchscreen capability
Connect the I²C LCD Screen

- Connect the pins:
- GND → Ground
- VCC → 5V or 3.3V
- SDA/SCL → to correct GPIO pins
Use a library like smbus.
Auto-Start on Boot
Create these systemd service files:
- client_pi.service
- lcd_server.service
- video_server.service
This makes the Pi start everything automatically on boot—no manual scripts needed!
Build a Wooden Enclosure (Maker Skills)







I built a custom wooden enclosure using planks cut to the following size:
- 30 cm (width) x 25 cm (depth) x 9 cm (height)
Assembly Instructions:
- Cut your wooden panels to form a box with those iner dimensions.
- The top panel should be the same size (30x25 cm), but:
- Cut out ~75% of it (leaving a hingeable flap).
- Attach this movable top section with hinges so it can open and close like a lid.
- On the inside, attach a small support stick to prop the lid open when needed.
Mounting the Touchscreen:
- Mount the 7-inch HDMI touchscreen on the movable top panel.
- Use small screws to secure it firmly in place.
- The screen will tilt open when the top is lifted, making it easy to interact with or inspect.
Cutouts and Openings:
- Webcam opening:
- Cut a small hole on the front bottom panel.
- This allows the webcam (mounted below it) to see straight out the front.
- LCD screen opening:
- Cut a rectangular hole in the front panel in one of the corners.
- Align it with your mounted 16x2 I²C LCD, so the result text (e.g., “Weak Bicep”) is visible from the outside.
📦 Final Look & Functionality:
- From the front the webcam can see you and you can see the lcd and the 7-inch display.
Final Testing


- Boot the Raspberry Pi (services start automatically).
- Run the Python detection app on your PC.
- Open Gradio in your browser.
- Try all 3 tabs and verify:
- LCD shows label
- Correct video plays
- Webcam stream + "Take Photo" works
You now have a working AI-powered fitness assistant!