CTAD++ (Causal Temporal Action Detection++) is a multi-modal deep learning system for human action recognition on the JHMDB dataset (21 classes), fusing RGB, optical flow, and pose via Cross-Modal Causal Attention (CMCA) within a causal temporal architecture.
Designed as an end-to-end pipeline, it simultaneously performs action classification, spatial localization, and temporal prediction, while leveraging uncertainty estimation to produce reliable, confidence-aware outputs.
Note: Trained weights (
.pth), JHMDB videos, and the MediaPipe pose model are not included in this repository (see .gitignore). After cloning, you must prepare the data and run training before evaluation or inference will work.
- OS: Windows 10/11 or Linux
- Python: 3.10+
- GPU: NVIDIA GPU + CUDA strongly recommended (training on CPU is impractical)
- Disk: ~5 GB+ for videos/cache/checkpoints (videos are the largest part)
cd path\to\PROJECT
python -m venv .venv
.\.venv\Scripts\Activate.ps1 # Linux/macOS: source .venv/bin/activate
python -m pip install --upgrade pip
# Install PyTorch for your CUDA version: https://pytorch.org
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu124
pip install -r requirements.txt
pip install -e .Sanity check:
python -c "from ctad.config import config; print('videos:', config.JHMDB_VIDEOS_DIR)"-
Download / extract JHMDB clips as MP4 files.
-
Place them under:
data/videos/<action_name>/<clip_id>.mp4(21 action folders, e.g.
data/videos/golf/...) -
Ensure these repo files are present (they are tracked in git):
data/jhmdb/splits/train.csv,test.csvdata/jhmdb/JHMDB-GT.pkl
-
Optional quick test clip:
data/samples/golf.mp4(small demo; other samples may be local-only).
See data/README.md for layout details.
The pose stream needs MediaPipe’s heavy landmarker (not in git):
-
Download
pose_landmarker_heavy.taskfrom MediaPipe Pose Landmarker. -
Save it as:
assets/pose_landmarker_heavy.task
See assets/README.md.
This builds the feature cache and saves the stage-1 checkpoint. Expect several hours on a GPU.
# Recommended: train on official train.csv only (no test leakage)
$env:CTAD_TRAINING_SPLIT = "official" # default if unset
python scripts/train.pyOutputs:
outputs/feature_cache/feature_cache_224x16_v3_uniform_sampling/outputs/checkpoints/jhmdb_cmca.pth
python scripts/finetune.pyOutput: outputs/checkpoints/jhmdb_cmca_finetuned.pth (used by default for eval/infer)
Verify:
python -c "from ctad.config import config; import os; print(os.path.isfile(config.checkpoint_path('jhmdb_cmca_finetuned.pth')))"Should print True.
After training, run metrics and demos:
# Official test split + confusion matrix
python scripts/evaluate.py --split test --plot-confusion
# Compare stage-1 vs finetuned
python scripts/compare_checkpoints.py
# Single video (use any MP4 you have)
python scripts/infer.py --video data\samples\golf.mp4
# Or run the full post-training pipeline (eval/plots/report; no training)
python scripts/run_pipeline.pyResults go under outputs/results/ and outputs/figures/.
Train all five variants (GPU, many hours):
python scripts/ablation.py --variants 1,2,3,4,5 --epochs 120Then evaluate on the official test split (uses saved variant_*.pth, no extra training):
python scripts/evaluate_ablation.py
python scripts/plot_ablation.py| Variant | Description |
|---|---|
| V1 — RGB Baseline | ResNet-50 frames only, standard Transformer encoder. No optical flow, pose, CMCA, or causal temporal stack. |
| V2 — Late Concatenation | RGB + motion (flow CNN) + pose fused by concatenation, then a standard Transformer. Multimodal but no cross-modal attention and no causal temporal blocks. |
| V3 — CMCA + Causal (proposed) | Full CTAD: cross-modal fusion (CMCA), causal + anti-causal temporal attention, uncertainty head, bbox and temporal auxiliary heads. |
| V4 — No Uncertainty | Same as V3 but uses a deterministic classifier (no MC-dropout epistemic branch). Tests the value of uncertainty estimation. |
| V5 — No Skeleton | Same as V3 without the pose stream (RGB + motion only). Tests whether skeleton landmarks help beyond appearance and flow. |
Weights after training: outputs/ablation/variant_1.pth … variant_5.pth
| Path | Description |
|---|---|
outputs/checkpoints/jhmdb_cmca.pth |
Stage-1 best weights |
outputs/checkpoints/jhmdb_cmca_finetuned.pth |
Stage-2 weights (default for scripts) |
outputs/feature_cache/... |
Precomputed RGB / flow / pose .npy per clip |
outputs/results/eval_test.json |
Test metrics (after evaluate.py) |
outputs/figures/ |
Confusion matrix, ablation plots, etc. |
More detail: docs/CHECKPOINTS.md
PROJECT/
├── src/ctad/ # Package (models, data, training, inference, eval)
├── scripts/ # CLI entry points
├── tests/ # Smoke tests (pytest)
├── configs/default.yaml # Reference hyperparameters (runtime: config.py)
├── data/
│ ├── videos/ # JHMDB MP4s (you provide; not in git)
│ ├── jhmdb/splits/ # train.csv, test.csv (in git)
│ └── samples/ # Demo clips (golf.mp4 in git)
├── assets/ # pose_landmarker_heavy.task (you download)
├── outputs/ # Created when you train (gitignored)
└── docs/
├── RUN.md
├── METHODOLOGY.md
└── CHECKPOINTS.md
| Script | When to use |
|---|---|
train.py |
Required — stage 1 training |
finetune.py |
Required — stage 2 fine-tuning |
evaluate.py |
After training — test/train metrics |
infer.py |
After training — one video + annotated MP4 |
batch_infer.py |
After training — many videos |
run_pipeline.py |
After training — eval, plots, report (no training unless --train) |
compare_checkpoints.py |
After training — stage-1 vs finetuned on test |
evaluate_ablation.py |
After ablation weights exist |
ablation.py |
Optional — train V1–V5 (hours) |
plot_ablation.py / plot_confusion.py |
After eval — figures |
generate_report.py |
Writes docs/PROJECT_STATUS.md |
Full runbook: docs/RUN.md
pip install pytest
pytest tests/ -q| In git | Not in git (you provide locally) |
|---|---|
Source, scripts, docs, CSV splits, JHMDB-GT.pkl |
data/videos/, outputs/, *.pth |
data/samples/golf.mp4 |
Large sample MP4s, pose .task file |
See .gitignore.
- docs/RUN.md — detailed commands and troubleshooting
- docs/METHODOLOGY.md — train/test splits and evaluation protocol
- docs/CHECKPOINTS.md — checkpoint paths after training
Safe to delete to save disk: jhmdb-gulprgb/gulp_rgb/, jhmdb-gulprgb/.cache/ (see jhmdb-gulprgb/README.md).