Skip to content

Commit f53031d

Browse files
authored
Merge pull request #14 from sensein/action_models
Organize repo
2 parents 09f42d9 + 071e870 commit f53031d

235 files changed

Lines changed: 13165 additions & 4779 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 87 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
This repository contains action classification and statistical analysis for
44
locomotion and repetitive motor movement behaviors in the SAILS video dataset.
55

6-
The project is organized as a research pipeline:
6+
The project is organized as:
77

88
1. Detect people and estimate whole-body pose from videos.
99
2. Track people across frames and identify the target child.
@@ -40,7 +40,9 @@ The project is organized as a research pipeline:
4040
Code: `src/sailsprep/id_tracking_model/`
4141

4242
This part of the repository generates detection and pose caches, tracks people
43-
across frames, and selects the target child track.
43+
across frames, and selects the target child track. See
44+
[`src/sailsprep/id_tracking_model/README.md`](src/sailsprep/id_tracking_model/README.md)
45+
for the full pipeline and command reference.
4446

4547
Important modules:
4648

@@ -57,7 +59,10 @@ Important modules:
5759
Code: `src/sailsprep/tracking_pose_model_testing/`
5860

5961
This directory contains scripts for testing or wrapping individual tracking and
60-
pose-estimation methods:
62+
pose-estimation methods. See
63+
[`src/sailsprep/tracking_pose_model_testing/README.md`](src/sailsprep/tracking_pose_model_testing/README.md)
64+
for which scripts are single-video demos versus CSV/SLURM batch pipelines,
65+
and the corresponding install groups:
6166

6267
- YOLO pose
6368
- HRNet
@@ -76,29 +81,37 @@ and visualized outputs.
7681
Code: `src/sailsprep/action_model_testing/`
7782

7883
This directory contains the model-training and inference scripts used for action
79-
classification experiments.
84+
classification experiments. See
85+
[`src/sailsprep/action_model_testing/README.md`](src/sailsprep/action_model_testing/README.md)
86+
for the full list of model folders, and each model folder's own README for
87+
setup and usage specific to that model.
8088

8189
Included model families:
8290

83-
- `Video_Swin/` - clip-based, binary sliding-window, full-video sliding-window,
91+
- `video_swin/` - clip-based, binary sliding-window, full-video sliding-window,
8492
and two-stage Video Swin pipelines.
85-
- `Videomaev2/` - VideoMAE v2 finetuning and sliding-window variants.
86-
- `InternVideo_v2/` - InternVideo2 finetuning and inference.
93+
- `videomae2/` - VideoMAE v2 finetuning and sliding-window variants.
94+
- `internvideo2/` - InternVideo2 finetuning and inference.
8795
- `slow_fast/` - SlowFast finetuning.
8896
- `motionbert/` - MotionBERT pose/action pipeline.
8997
- `mstcn2/` - MS-TCN++ sequence model over extracted features.
90-
- `OpenTAD/` - temporal action detection experiments.
91-
- `pyskl/` - PySKL config/logit utilities.
92-
- `vlm_models/` - Qwen/Ovis vision-language model classifiers.
93-
- `feature_extraction/` - I3D/R(2+1)D and V-JEPA feature extraction.
94-
- `vjepa/` - vjepa model variants.
95-
- `dlc_action/` - DLC2Action data preparation workflow.
98+
- `open_tad/` - temporal action detection experiments (requires the OpenTAD
99+
codebase).
100+
- `pyskl/` - PySKL config generation, training helpers, and logit fusion
101+
(requires the PySKL codebase).
102+
- `vlm_models/` - Qwen2.5-VL/Ovis2 vision-language model classifiers.
103+
- `feature_extraction/` - I3D/R(2+1)D and V-JEPA2 feature extraction.
104+
- `vjepa/` - V-JEPA2 feature extraction, probe training, and fine-tuning
105+
variants.
106+
- `dlc_action/` - DLC2Action data preparation and training pipeline.
96107

97108
### Fusion Models
98109

99110
Code: `src/sailsprep/fusion_model/`
100111

101-
Fusion scripts combine predictions from multiple model families.
112+
Fusion scripts combine predictions from multiple model families. See
113+
[`src/sailsprep/fusion_model/README.md`](src/sailsprep/fusion_model/README.md)
114+
for full usage.
102115

103116
- `late_fusion/two_model.py` - late fusion between two prediction sources.
104117
- `late_fusion/three_model.py` - late fusion among three prediction sources.
@@ -111,7 +124,9 @@ Fusion scripts combine predictions from multiple model families.
111124
Code: `src/sailsprep/analysis/`
112125

113126
Behavior-specific analysis scripts extract kinematic features from pose tracks
114-
and run statistical analyses. Behaviors include:
127+
and run statistical analyses. See
128+
[`src/sailsprep/analysis/README.md`](src/sailsprep/analysis/README.md) for
129+
run order, inputs, and outputs. Behaviors include:
115130

116131
- walking
117132
- running
@@ -133,7 +148,9 @@ leave-one-subject-out classification.
133148
Code: `src/sailsprep/annotation/`
134149

135150
The annotation tool is a FastAPI application with a browser UI for reviewing
136-
videos and assigning frame-level behavior labels.
151+
videos and assigning frame-level behavior labels. See
152+
[`src/sailsprep/annotation/README.md`](src/sailsprep/annotation/README.md)
153+
for the API endpoints and label set.
137154

138155
```bash
139156
uvicorn sailsprep.annotation.annotation:app --reload
@@ -159,40 +176,54 @@ poetry install --with dev
159176
poetry run pytest
160177
```
161178

162-
Many model pipelines require optional heavy dependencies. Install only the
163-
groups needed for the experiment you want to reproduce.
164-
165-
Examples:
179+
Many model pipelines require optional heavy dependencies. `pyproject.toml`
180+
defines the following optional Poetry groups; install only the ones needed
181+
for the experiment you want to reproduce.
166182

167183
```bash
168184
# Pose/tracking experiments
169185
poetry install --with dev,pose-estimation,tracking
170186

187+
# EntitySAM
188+
poetry install --with dev,entity-sam
189+
190+
# ViTPose
191+
poetry install --with dev,vitpose
192+
193+
# Clip-level tracker (MMDetection/MMPose-based)
194+
poetry install --with dev,clip_tracker
195+
196+
# DLC2Action
197+
poetry install --with dev,dlc2action
198+
171199
# Video Swin experiments
172-
poetry install --with dev,Video_Swin
200+
poetry install --with dev,video_swin
173201

174-
# VideoMAE / feature extraction style experiments
202+
# I3D / R(2+1)D / V-JEPA2 feature extraction
175203
poetry install --with dev,feature-extraction
176204

177-
# Vision-language model experiments
205+
# Vision-language model experiments (Qwen2.5-VL / Ovis2)
178206
poetry install --with dev,vlm
179207

180208
# OpenTAD experiments
181209
poetry install --with dev,opentad
182210

211+
# Statistical analysis (statsmodels, optionally rpy2/pymc/arviz)
212+
poetry install --with dev,stats-analysis
213+
183214
# Documentation
184215
poetry install --with docs
185216
```
186217

187-
Some third-party model stacks, especially PySKL, OpenTAD, MMDetection, MMPose,
188-
and CUDA-specific video libraries, may require separate environment setup on an
189-
HPC system. The job scripts in `jobs/` show the environments used for the
190-
original experiments.
218+
There is no Poetry group for VideoMAE2, InternVideo2, SlowFast, MotionBERT,
219+
MS-TCN++, or PySKL — those model folders list their own dependencies to
220+
`pip install` directly in their README. Some third-party model stacks,
221+
especially PySKL, OpenTAD, MMDetection, MMPose, and CUDA-specific video
222+
libraries, may require separate environment setup.
191223

192224
## Data Requirements
193225

194-
The SAILS videos and derived data are not included in this repository. To
195-
reproduce the full results, prepare the following inputs:
226+
To reproduce the full results, prepare the following inputs:
196227

197228
1. Raw or standardized SAILS videos (this repo used videos from bids preprocessed folder).
198229
2. A split CSV with train/validation/test assignments.
@@ -314,40 +345,35 @@ need to be generated.
314345

315346
### 5. Train Action Models
316347

317-
Representative examples:
348+
The scripts in `action_model_testing/` mostly import their shared helpers with
349+
bare imports (e.g. `from common.utils import ...`, `from utils.bbox import
350+
...`), so each script is meant to be run with its own folder as the current
351+
directory, not as a `python -m` module. See the model's own README (linked
352+
from
353+
[`src/sailsprep/action_model_testing/README.md`](src/sailsprep/action_model_testing/README.md))
354+
for exact commands. Representative examples:
318355

319356
```bash
320357
# Video Swin full-video sliding-window classifier
321-
python -m sailsprep.action_model_testing.Video_Swin.sliding_window.video_swin_fullvideo_sliding \
322-
--task loco \
323-
--seed 42
358+
cd src/sailsprep/action_model_testing/video_swin/sliding_window
359+
python video_swin_fullvideo_sliding.py --task loco --seed 42
324360

325361
# Video Swin binary N/A vs non-N/A classifier
326-
python -m sailsprep.action_model_testing.Video_Swin.sliding_window.video_swin_binary_sliding \
327-
--task rmm \
328-
--seed 42
362+
python video_swin_binary_sliding.py --task rmm --seed 42
329363

330364
# Video Swin two-stage classifier
331-
python -m sailsprep.action_model_testing.Video_Swin.sliding_window.video_swin_twostage_joint \
332-
--task loco \
333-
--seed 42
365+
python video_swin_twostage_joint.py --task loco --seed 42
334366

335367
# VideoMAE2 full-video sliding-window classifier
336-
python -m sailsprep.action_model_testing.Videomaev2.videomae2_fullvideo_sliding \
337-
--task loco \
338-
--seed 42
368+
cd ../../videomae2
369+
python videomae2_fullvideo_sliding.py --task loco --seed 42
339370

340371
# VideoMAE2 two-stage classifier
341-
python -m sailsprep.action_model_testing.Videomaev2.videomae2_twostage_sliding \
342-
--task rmm \
343-
--seed 42
372+
python videomae2_twostage_sliding.py --task rmm --seed 42
344373

345374
# MS-TCN++ over extracted features
346-
python -m sailsprep.action_model_testing.mstcn2.mstcn2 \
347-
--label loco \
348-
--feature_type i3d \
349-
--action train \
350-
--seed 42
375+
cd ../mstcn2
376+
python mstcn2.py --label loco --feature_type i3d --action train --seed 42
351377
```
352378

353379
Most reported model experiments are run over three seeds:
@@ -451,14 +477,22 @@ Common edits:
451477

452478
Representative job scripts:
453479

454-
- `jobs/action_model_testing/Video_Swin/sliding_window/Video_Swin_full_video_multi_job.sh`
455-
- `jobs/action_model_testing/Video_Swin/sliding_window/Video_Swin_full_video_multi_job_twostage.sh`
480+
- `jobs/action_model_testing/Video_Swin/sliding_window/video_swin_full_video_multi_job.sh`
481+
- `jobs/action_model_testing/Video_Swin/sliding_window/video_swin_full_video_multi_job_twostage.sh`
456482
- `jobs/action_model_testing/Video_Swin/sliding_window/full_video_window_job_video_swin.sh`
457-
- `jobs/action_model_testing/Videomaev2/Videomaev2_submit_all.sh`
483+
- `jobs/action_model_testing/videomae2/videomae2_job.sh`
484+
- `jobs/action_model_testing/videomae2/videomae2_submit_all.sh`
485+
- `jobs/action_model_testing/internvideo2/internvideo2_finetune.sh`
486+
- `jobs/action_model_testing/motionbert/motionbert.sh`
458487
- `jobs/action_model_testing/mstcn2/mstcn2.sh`
459488
- `jobs/action_model_testing/slow_fast/slow_fast.sh`
489+
- `jobs/action_model_testing/slow_fast/ablation/slowfast_ablation_job.sh`
490+
- `jobs/action_model_testing/feature_extraction/i3d_r2p1d_feature_extracion.sh`
491+
- `jobs/action_model_testing/feature_extraction/vjepa_feature_extracion.sh`
460492
- `jobs/action_model_testing/vlm_models/clips/submit_qwen_clip.sh`
461493
- `jobs/action_model_testing/vlm_models/clips/submit_ovis_clip.sh`
494+
- `jobs/action_model_testing/pyskl/pyskl_job.sh`
495+
- `jobs/action_model_testing/pyskl/test_job.sh`
462496
- `jobs/fusion_model/pyskl/train_pyskl_sw.sh`
463497
- `jobs/fusion_model/pyskl/test_pyskl_sw.sh`
464498
- `jobs/analysis/analysis_job.sh`

jobs/action_model_testing/InternVideo_v2/internvideo2_finetune.sh renamed to jobs/action_model_testing/internvideo2/internvideo2_finetune.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
#SBATCH --mem=200G
88
#SBATCH --time=24:00:00
99
#SBATCH --gres=gpu:h100:1
10-
#SBATCH --output=/src/sailsprep/action_model_testing/InternVideo_v2/logs/IV2_%A_%a_%x.out
11-
#SBATCH --error=/src/sailsprep/action_model_testing/InternVideo_v2/logs/IV2_%A_%a_%x.err
10+
#SBATCH --output=/src/sailsprep/action_model_testing/internvideo2/logs/IV2_%A_%a_%x.out
11+
#SBATCH --error=/src/sailsprep/action_model_testing/internvideo2/logs/IV2_%A_%a_%x.err
1212
#SBATCH --array=0-2
1313
# ==========================================================================
1414
# Multi-seed fine-tuning for a single task.
@@ -33,7 +33,7 @@ fi
3333
SEEDS=(42 123 456)
3434
SEED=${SEEDS[$SLURM_ARRAY_TASK_ID]}
3535

36-
SCRIPT_DIR=/src/sailsprep/action_model_testing/InternVideo_v2
36+
SCRIPT_DIR=/src/sailsprep/action_model_testing/internvideo2
3737
LOG_DIR="${SCRIPT_DIR}/logs"
3838
mkdir -p "${LOG_DIR}"
3939

@@ -75,7 +75,7 @@ cd "${SCRIPT_DIR}"
7575
torchrun \
7676
--standalone \
7777
--nproc_per_node="${NUM_GPUS}" \
78-
InternVideo.py \
78+
internvideo2_finetune.py \
7979
--task "${LABEL}" \
8080
--seed "${SEED}" \
8181
--gpus "${NUM_GPUS}"

jobs/action_model_testing/OpenTAD/submit_tad_array.sh renamed to jobs/action_model_testing/open_tad/submit_tad_array.sh

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/bin/bash
22
#SBATCH --partition=mit_normal_gpu
33
#SBATCH --job-name=tad_loco
4-
#SBATCH --output=/src/sailsprep/action_model_testing/OpenTAD/logs/tad_%A_%a.out
5-
#SBATCH --error=/src/sailsprep/action_model_testing/OpenTAD/logs/tad_%A_%a.err
4+
#SBATCH --output=/src/sailsprep/action_model_testing/open_tad/logs/tad_%A_%a.out
5+
#SBATCH --error=/src/sailsprep/action_model_testing/open_tad/logs/tad_%A_%a.err
66
#SBATCH --time=6:00:00
77
#SBATCH --gres=gpu:l40s:1
88
#SBATCH --cpus-per-task=8
@@ -58,7 +58,7 @@ conda activate opentad
5858
export PYTHONNOUSERSITE=1
5959
TORCH_LIB_PATH="${TORCH_LIB_PATH:-/orcd/pool/007/aparnabg/miniconda3/envs/opentad/lib/python3.10/site-packages/torch/lib}"
6060
export LD_LIBRARY_PATH="${TORCH_LIB_PATH}:$LD_LIBRARY_PATH"
61-
cd /src/sailsprep/action_model_testing/OpenTAD
61+
cd /src/sailsprep/action_model_testing/open_tad
6262
mkdir -p logs
6363

6464
echo "LD_LIBRARY_PATH : ${LD_LIBRARY_PATH}"
@@ -74,49 +74,23 @@ echo "Node : ${SLURMD_NODENAME}"
7474
echo "Start time : $(date)"
7575
echo "=========================================="
7676
# Generate config for this seed
77-
python run_locomotion.py \
77+
python run/run.py \
7878
--task ${TASK} \
7979
--model ${MODEL} \
8080
--seed ${SEED} \
8181
--mode generate_config
8282

8383
# Train then test
84-
python run_locomotion.py \
84+
python run/run.py \
8585
--task ${TASK} \
8686
--model ${MODEL} \
8787
--seed ${SEED} \
8888
--mode train_test \
8989
--gpus 1 \
9090
--port ${PORT}
91-
# Generate config for this seed
92-
9391

9492
TRAIN_EXIT=$?
9593

96-
# ---- Frame-level metrics ----
97-
EXP_DIR="exps/${TASK}/${MODEL}_${BACKBONE}/seed_${SEED}"
98-
PRED_JSON=""
99-
100-
if [ -d "${EXP_DIR}" ]; then
101-
PRED_JSON=$(find ${EXP_DIR} -name "test_results.json" -type f 2>/dev/null | head -1)
102-
fi
103-
104-
if [ -n "${PRED_JSON}" ]; then
105-
METRICS_DIR="$(dirname ${PRED_JSON})/frame_metrics"
106-
echo ""
107-
echo "=========================================="
108-
echo "Running frame-level metrics..."
109-
echo " Predictions : ${PRED_JSON}"
110-
echo " Output : ${METRICS_DIR}"
111-
echo "=========================================="
112-
python eval_frame_metrics.py \
113-
--task ${TASK} \
114-
--pred_json ${PRED_JSON} \
115-
--output_dir ${METRICS_DIR}
116-
else
117-
echo "WARNING: No test_results.json found in ${EXP_DIR}"
118-
fi
119-
12094
echo "=========================================="
12195
echo "Done: ${TASK} / ${MODEL} + ${BACKBONE} / seed=${SEED}"
12296
echo "Exit code : ${TRAIN_EXIT}"

0 commit comments

Comments
 (0)