CourtSense
AI tennis analysis. Five swappable neural networks behind one interface.
- Role
- ML engineering and app
- Team
- Group project, Universidad San Jorge
- When
- Mar 2026 – Jun 2026
- Stack
- PythonPyTorchtorchvisionOpenCVStreamlitOllama
Demo video coming soon
- classifier validation accuracy
- 99.8%
- classifier validation accuracy
- court keypoint validation error
- 0.04 px
- court keypoint validation error
- player detector F1
- 0.894
- player detector F1
Upload a match photo or video, or point a webcam at a court, and CourtSense runs five models over it.
You can try it live. The hosted demo runs image mode on my home server, without the VLM chat, which needs a local model too large to serve publicly.
The models
| Module | What it does | Result |
|---|---|---|
| CNN classifier | Player, ball or background for each image crop | 99.8% val accuracy |
| Keypoint detector | 15 court landmarks, used to map positions onto a 2D court | 0.04 px avg val error |
| Faster R-CNN detector | Player and ball bounding boxes with confidence | F1 0.894 (P 0.879, R 0.910) |
| LSTM | Predicts the next ball position from the last 8 | ~12 px avg error at 1280×720 |
| VLM (Gemma via Ollama) | Answers natural-language questions about the scene | Pretrained |
An MLP baseline runs on the same crops so the CNN's gains can be measured, not assumed.
The app
A Streamlit interface with image, video and camera modes. Video runs detection and tracking on every third frame and plays back with bounding boxes and trajectory trails. A Court View tab maps players and the ball onto a top-down court, and a Chat tab sends a representative frame to the VLM. Any model can be retrained from inside the app, and the new weights hot-reload.
Engineering
Every module has the same train and load interface, so models can be retrained and swapped independently. The training code is written from scratch, including custom loss functions. Device selection picks Apple Silicon (MPS), CUDA or CPU automatically. Coordinates stay normalized to 0, 1 everywhere and are only converted to pixels at render time.