Skip to content

Commit c9abeeb

Browse files
committed
add vlm_models
1 parent 00aeb7c commit c9abeeb

20 files changed

Lines changed: 3697 additions & 0 deletions
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# V-JEPA2 Constraint Prediction with Temporal Windowing
2+
3+
Complete pipeline for training V-JEPA2 to predict child constraint status from videos using temporal windowing and majority voting.
4+
5+
## Overview
6+
7+
This package predicts:
8+
1. **Constraint Status**: y (constrained) / n (not constrained) / partial
9+
2. **Constraint Type**: highchair, carseat, stroller, etc. (only if constrained)
10+
11+
**Method**: Temporal windowing with majority voting
12+
- Divides video into N windows
13+
- Samples frames from each window
14+
- Gets prediction for each window
15+
- Final prediction = majority vote across windows
16+
17+
### Prerequisites
18+
- Python 3.10+
19+
- Your CSV file with columns: `BidsProcessed`, `Child_constrained`, `Constraint_type`
20+
21+
22+
23+
### **Step 1: Prepare Data**
24+
25+
```bash
26+
python prepare_data.py \
27+
--csv your_data.csv \
28+
--video_col BidsProcessed \
29+
--constrained_col Child_constrained \
30+
--type_col Constraint_type \
31+
--val_split 0.3 \
32+
--test_split 0.3 \
33+
--output prepared_data.pkl
34+
```
35+
36+
**Output:**
37+
- `prepared_data.pkl` with train/val/test splits
38+
39+
---
40+
41+
### **Step 2: Train Model**
42+
43+
#### **Option A: Without Windowing (Faster)**
44+
```bash
45+
python finetune_vjepa_windowing.py \
46+
--data prepared_data.pkl \
47+
--model_cache ./models \
48+
--output ./finetuned_vjepa \
49+
--epochs 5 \
50+
--batch_size 32 \
51+
--lr 1e-4 \
52+
--num_workers 8
53+
```
54+
55+
#### **Option B: With Windowing (More Accurate)**
56+
```bash
57+
python finetune_vjepa_windowing.py \
58+
--data prepared_data.pkl \
59+
--model_cache ./models \
60+
--output ./finetuned_vjepa \
61+
--epochs 5 \
62+
--batch_size 16 \
63+
--lr 1e-4 \
64+
--num_workers 8 \
65+
--use_windowing \
66+
--num_windows 3
67+
```
68+
69+
**Output:**
70+
- `./finetuned_vjepa/best_model.pt` - Trained model
71+
- `./finetuned_vjepa/training_history.json` - Training metrics
72+
73+
---
74+
75+
### **Step 3: Evaluate on Test Set**
76+
77+
```bash
78+
python evaluate_vjepa_windowing.py \
79+
--data prepared_data.pkl \
80+
--model ./finetuned_vjepa \
81+
--split test \
82+
--output ./test_results
83+
```
84+
85+
**Output:**
86+
- `./test_results/test_predictions.csv` - All predictions
87+
- `./test_results/test_metrics.json` - Accuracy, F1, confusion matrix
88+
89+
---
90+

0 commit comments

Comments
 (0)