Skip to main content

๐Ÿค– Backend / AI Developer Quickstart

:::note Audit scope (2026-07-23) This guide targets the excluded GPU backend. It was inventoried but not reverified, so its last_verified date is intentionally unchanged. :::

You're improving the AI video analysis pipeline (RunPod GPU backend).

:::tip TL;DR

  • Repo: acesense-gpu-backend (Python 3.11 โ€” strict)
  • Stack: YOLO v8 โ€ข TrackNet โ€ข MediaPipe โ€ข CatBoost โ€ข OpenCV โ€ข PyTorch
  • Runs on: RunPod RTX 4090 serverless (prod) โ€ข local CPU/MPS/CUDA (dev) :::

๐Ÿš€ Get Running in 5 Minutesโ€‹

# 1. Clone
git clone git@github.com:Acesense/acesense-gpu-backend.git
cd acesense-gpu-backend

# 2. Create Python 3.11 venv (REQUIRED โ€” not 3.12+)
python3.11 -m venv venv
source venv/bin/activate

# 3. Install deps
pip install -r requirements/requirements.txt

# 4. Run a local clip
python main.py --path_input_video input_videos/sample.mp4 --dev

:::warning Python 3.11.x only CatBoost + MediaPipe do not ship wheels for Python 3.12+. Using a newer version will silently fail or install broken builds. :::


๐ŸŽ๏ธ Dev Cache (96% Faster Iteration)โ€‹

The --dev flag caches intermediate ML inference so you can iterate on downstream logic without re-running expensive models:

# First run โ€” ~90s for a 30s video (builds cache)
python main.py --path_input_video input_videos/sample.mp4 --dev

# Subsequent runs โ€” ~3s (cached)
python main.py --path_input_video input_videos/sample.mp4 --dev

# Clear cache when models change
rm -rf .dev/cache/

Cache lives in .dev/cache/<video_hash>/ with one pickle per stage (ball tracking, court, players, bounces, shots).


๐Ÿ“‚ Pipeline Structureโ€‹

src/
โ”œโ”€โ”€ core/ # GameProcessor โ€” the orchestrator
โ”œโ”€โ”€ tracking/ # Ball tracking (TrackNet)
โ”œโ”€โ”€ surface/ # Court detection (CourtDetectorNet)
โ”œโ”€โ”€ players/ # Player detection (FasterRCNN + MediaPipe)
โ”œโ”€โ”€ events/ # Bounce detection (CatBoost)
โ”œโ”€โ”€ classification/ # Shot classification
โ”œโ”€โ”€ analysis/ # Game stats + recommendations
โ”œโ”€โ”€ export/ # PDF/JSON/video reports
โ”œโ”€โ”€ io/ # Video I/O, Firebase upload
โ”œโ”€โ”€ render/ # Overlay visualization
โ””โ”€โ”€ utils/ # Dev cache, helpers

๐Ÿงญ Common Workflowsโ€‹

Run against Firebase (cloud mode)โ€‹

python main.py \
--path_input_video video.mp4 \
--cloud \
--firebase_bucket acesense-prod.firebasestorage.app \
--firebase_credentials firebasecred/firebase-admin.json

Test on a real RunPod-style invocationโ€‹

python runpod_handler.py # simulates the serverless handler locally

Ship a new model versionโ€‹

  1. Drop the new weights into games/tennis/models/
  2. Bump the version in Dockerfile
  3. Build + push: docker build -t akshaysarode/acesense:vNN . && docker push akshaysarode/acesense:vNN
  4. Update the RunPod endpoint image tag in the RunPod Console

See the Deployment Guide for the full flow.


๐Ÿงช Testsโ€‹

pytest tests/ -v

๐ŸŽฏ Next Stepsโ€‹