Imported from danielperebinos/slowfast-thesis (
AGENTS.md). Install upstream withnpx skills add danielperebinos/slowfast-thesis. Copyright stays with the author.
AGENTS.md
Project map for AI agents. Keep this file up-to-date as the project evolves.
Project Overview
Thesis codebase for action anticipation on video using four SlowFast variants (baseline, attention, YOLO-ROI guidance, hybrid), trained on AVA and tracked with MLflow. See .ai-factory/DESCRIPTION.md for details.
Tech Stack
- Language: Python 3.10 (managed with
uv, lint withruff) - Framework: PyTorch 2.0.1 (CUDA 11.8) + PyTorchVideo 0.1.5
- Detection: Ultralytics YOLOv8 (
yolov8n.pt) - Database: PostgreSQL 15 (MLflow backend only — not a project DB)
- Artifact store: MinIO (S3-compatible)
- Experiment tracking: MLflow ≥ 3.9
Project Structure
slowfast-thesis/
├── AVA/ # local .mp4 training clips (gitignored via *.mp4)
├── AGENTS.md # this file — AI agent project map
├── README.md # Romanian-language thesis scope document
├── compose.experiments.yml # MLflow stack: postgres + minio + mlflow server
├── dashboard/ # Inference-only Streamlit demo (port 8501)
│ ├── app.py # Streamlit entry (variant + stream picker, live inference)
│ ├── config.py # variant registry + preprocessing constants (mirror of core/data_loader)
│ ├── inference/ # preprocess, model_loader, engine (CUDA-sync timing), metrics (TTA + latency)
│ ├── ui/ # Streamlit components + session-state helpers
│ ├── tests/ # CPU smoke tests (label-map parity, preprocess shapes, per-variant forward)
│ ├── Dockerfile # CUDA 11.8 + Python 3.10 + Streamlit
│ ├── compose.yml # slowfast-dashboard stack — read-only bind mounts of ../experiments & ../AVA
│ ├── Makefile # install / run / smoke / up / down / logs (no destructive targets)
│ └── pyproject.toml # own deps: streamlit + opencv-headless + pinned torch/pytorchvideo
├── deployment/
│ └── docker/
│ └── Dockerfile.mlflow # MLflow server image (psycopg2 + boto3)
├── experiments/
│ ├── core/ # shared primitives used by every variant
│ │ ├── data_loader.py # AvaAnticipationDataset + PackPathway + factory
│ │ ├── loss.py # ActionAnticipationLoss (BCE + temporal penalty)
│ │ └── metrics.py # multilabel/topk accuracy, AverageMeter, TTA
│ ├── dataset/ # data prep and download helpers
│ │ ├── build_splits.py # AVA → train.csv / test.csv by video_id
│ │ ├── download_all.py # yt-dlp batch fetch
│ │ └── fetch.py # single-video fetch helper
│ ├── experiment_01/ # Baseline SlowFast R50
│ ├── experiment_02/ # + Non-Local / Self-Attention
│ ├── experiment_03/ # + YOLOv8 ROI mask on Fast pathway
│ ├── experiment_04/ # Hybrid ROI + local attention
│ ├── experiments.md # one-pager registry of variants
│ ├── verify_setup.py # environment sanity check
│ └── yolov8n.pt # YOLO checkpoint (shared by experiments 03/04)
├── volumes/ # Docker volumes: postgres + minio data (DO NOT DELETE)
├── volumes.zip # archived snapshot of the above (DO NOT DELETE)
├── mlruns/ # legacy local MLflow runs (pre-server switchover)
├── main.py # placeholder PyCharm entry point (not used)
├── pyproject.toml # uv / ruff config, dependency list
├── uv.lock # locked dependency graph
├── .python-version # 3.10
├── .env # Postgres / MinIO / MLflow env (gitignored)
├── Makefile # wraps uv, compose, ruff, experiments (see `make help`)
├── .github/
│ └── workflows/
│ └── lint.yml # GitHub Actions: ruff check + ruff format --check
└── .ai-factory/ # AI agent context layer
├── DESCRIPTION.md # project spec & tech stack (authoritative)
├── ARCHITECTURE.md # architecture decisions (generated by /aif-architecture)
├── config.yaml # AIF config: language, paths, git, workflow
└── rules/
└── base.md # project conventions for AI agents
Key Entry Points
| File | Purpose |
|---|---|
experiments/experiment_01/train.py |
Baseline SlowFast R50 training loop (CE loss only template). |
experiments/experiment_02/train.py |
Attention variant training loop. |
experiments/experiment_03/train.py |
YOLO-ROI guided training loop. |
experiments/experiment_04/train.py |
Hybrid variant training loop. |
experiments/core/data_loader.py |
AvaAnticipationDataset, SlowFast transforms, make_ava_dataset factory. |
experiments/core/loss.py |
ActionAnticipationLoss (BCE + exp temporal penalty). |
experiments/core/metrics.py |
multilabel_accuracy, topk_accuracy, AverageMeter, calculate_tta. |
experiments/dataset/build_splits.py |
Builds train.csv / test.csv from AVA CSV + local videos. |
compose.experiments.yml |
Brings up Postgres + MinIO + MLflow stack. |
dashboard/app.py |
Streamlit inference dashboard: live variant+stream demo with latency and TTA. |
dashboard/compose.yml |
Brings up the dashboard container (port 8501, GPU, RO bind mounts of experiments/ and AVA/). |
pyproject.toml |
Dependencies (PyTorch cu118, pytorchvideo, ultralytics, mlflow) and ruff config. |
.env |
Credentials for Postgres / MinIO / MLflow (not committed). |
Documentation
| Document | Path | Description |
|---|---|---|
| Landing page | README.md |
Thesis scope (Romanian) + pointer to docs/. |
| Getting Started | docs/getting-started.md |
Install, stack up, prepare data, first experiment. |
| Architecture | docs/architecture.md |
Module boundaries and dependency rules (developer view). |
| Experiments | docs/experiments.md |
Variants registry, hyperparameters, how to add a new variant. |
| MLflow Stack | docs/mlflow-stack.md |
Postgres + MinIO + MLflow server, env vars, volume safety. |
| Dashboard | docs/dashboard.md |
Streamlit inference demo: live variant + stream + latency + TTA. |
| Experiments registry (short) | experiments/experiments.md |
One-pager variant summary + run commands. |
| Project spec | .ai-factory/DESCRIPTION.md |
Full tech-stack and feature spec (authoritative). |
| Architecture (full) | .ai-factory/ARCHITECTURE.md |
Complete architecture decisions with examples. |
AI Context Files
| File | Purpose |
|---|---|
AGENTS.md |
This file — project structure map. |
.ai-factory/DESCRIPTION.md |
Project specification and tech stack. |
.ai-factory/ARCHITECTURE.md |
Architecture decisions and guidelines. |
.ai-factory/config.yaml |
AIF config (language, paths, git, workflow). |
.ai-factory/rules/base.md |
Project-wide conventions for AI agents. |
.ai-factory.json |
Installed AIF skills and sub-agents registry. |
Common Commands (Makefile)
| Command | Purpose |
|---|---|
make help |
List all Make targets. |
make install |
uv sync dependencies. |
make lint / make fmt |
Run ruff check / format. |
make stack-up / make stack-down |
MLflow stack lifecycle. Never pass -v. |
make stack-logs |
Tail MLflow logs (override: SVC=postgres). |
make data-download |
Fetch AVA clips via experiments/dataset/download_all.py. |
make data-splits |
Build train.csv / test.csv for $(OUT_DIR). |
make experiment-01..04 |
Run a single variant. |
make experiments-all |
Run all four variants sequentially. |
make verify |
Dummy-data smoke test for all four models. |
make ci |
install + lint + fmt-check + verify (no training). |
Not provided on purpose: no clean-volumes, no stack-wipe, no down -v. See rules below.
Critical Project Rules
- Never delete Docker volumes (
./volumes/postgres,./volumes/minio) — they hold the MLflow tracking DB and trained-model artifacts. Usedocker compose downwithout-v. Never usedocker volume rm,docker system prune --volumes, or deletevolumes//volumes.zip. - Training checkpoints in
experiments/experiment_0*/(checkpoint.pth,best_*.pth) are also protected — they are expensive to regenerate. - See
.ai-factory/rules/base.mdfor the full rule set (naming, training-loop template, MLflow conventions, reproducibility, data handling).
Agent Rules
- Never combine shell commands with
&&,||, or;— execute each command as a separate Bash tool call. This applies even when a skill, plan, or instruction provides a combined command — always decompose it into individual calls.- ❌ Wrong:
git checkout master && git pull - ✅ Right: Two separate Bash tool calls — first
git checkout master, thengit pull origin master
- ❌ Wrong: