| --- |
| title: StrokeSense |
| emoji: πΎ |
| colorFrom: green |
| colorTo: gray |
| sdk: gradio |
| sdk_version: "5.35.0" |
| python_version: "3.12" |
| app_file: app.py |
| pinned: false |
| tags: |
| - best-minicpm-build |
| - llama-cpp |
| - backyard-ai |
| - track:backyard |
| - sponsor:openbmb |
| - achievement:offgrid |
| - achievement:llama |
| - achievement:sharing |
| --- |
| # Tennis Stroke Analyser |
|
|
| A tennis stroke analyser that detects shots from video and scores mechanics using a local vision-language model β no cloud API required. Designed to analyse close-up shots from a drill, it identifies each groundstroke (forehand or backhand), then generates scores and notes using vision capabilities. |
|
|
| Built for the **Build Small Hackathon** Β· Track: **Backyard AI** |
|
|
| <img src="images/ai_tennis_coach_picture.png" width="700" alt="Demo"> |
|
|
| <video width="640" controls> |
| <source src="https://huggingface.co/spaces/build-small-hackathon/StrokeSense/resolve/main/data/ai_tennis_coach_720.mp4" type="video/mp4"> |
| </video> |
|
|
| ## Social Media Post |
|
|
| [](https://discord.com/channels/879548962464493619/1515506816069668914) |
|
|
| ## Motivation |
|
|
| I build this for my tennis buddy that want feedback from coach when he do not have access to coach to assess his technique. I also add simple coach ai to chat to interaction, to give more detail explanation and discuss about training recommendation. |
|
|
| ## How it works |
|
|
| 1. **Shot detection** β MoveNet (TFLite) extracts pose keypoints per frame. A sliding-window RNN classifies each window as forehand, backhand, serve, or neutral. |
| 2. **Clip extraction** β A short clip is cut around each detected shot. |
| 3. **Stroke analysis** β Clip frames are sent to a local **MiniCPM-V-4.6** server (running via **llama.cpp**). The model scores four mechanics dimensions (preparation, contact point, swing/follow-through, and balance/stance) and returns structured JSON. |
| 4. **Coach recommendation** β Chat with a coach agent powered by **MiniCPM-V-4.6** to get recommendations and discuss your stroke analysis further. |
|
|
| ``` |
| βββββββββββββββββββββββββββββββββββββββ |
| β StrokeSense Pipeline β |
| βββββββββββββββββββββββββββββββββββββββ |
| |
| βββββββββββββββββββββββββββββββββββββββ |
| β 1. Read MP4 files β |
| β Load video input β |
| ββββββββββββββββββββ¬βββββββββββββββββββ |
| β |
| βΌ |
| βββββββββββββββββββββββββββββββββββββββ |
| β 2. Classify every stroke β |
| β Forehand, backhand, serve... β |
| ββββββββββββββββββββ¬βββββββββββββββββββ |
| β |
| βΌ |
| βββββββββββββββββββββββββββββββββββββββ |
| β 3. Cut video per stroke β |
| β Trim segment per stroke β |
| ββββββββββββββββββββ¬βββββββββββββββββββ |
| β |
| βΌ |
| βββββββββββββββββββββββββββββββββββββββ |
| β 4. Analyze with MiniCPM-V-4.6 β |
| β VLM inference per segment β |
| ββββββββββββββββββββ¬βββββββββββββββββββ |
| β |
| βΌ |
| βββββββββββββββββββββββββββββββββββββββ |
| β 5. Insert to coach AI agent β |
| β Feed results for coaching β |
| βββββββββββββββββββββββββββββββββββββββ |
| ``` |
|
|
| ## Future Improvement |
|
|
| * Add tool calling and deeper tennis references to ai tennis coach agent |
| * Decrease processing time for video analysis |
|
|
|
|
| **Model files needed**: |
|
|
| | File | Purpose | |
| |---|---| |
| | `models/movenet.tflite` | Shot detection | |
| | MiniCPM-V-4.6-GGUF | VLM stroke analysis | |
|
|
| Download MiniCPM-V-4.6-GGUF from [Hugging Face](https://huggingface.co/ggml-org/MiniCPM-V-4.6-GGUF) and set the path in `start_server.sh`. |
|
|