This repository extends the TrajICL pipeline with a centroid-based example-pool construction path for dense crowd trajectory modeling. The objective is to preserve the original TrajICL training and inference interface while enabling an alternative preprocessing mode where individual pedestrian trajectories are transformed into dynamically maintained cluster-centroid trajectories.
The centroid construction follows the dynamic clustering framework from Efficient Dense Crowd Trajectory Prediction Via Dynamic Clustering: nested direction/location agglomerative clustering, periodic LOF-based reassignment, temporary-pool reclustering, and delta-based centroid trajectory propagation under membership changes.
- Adds a centroid preprocessing entry point:
preprocess_centroids.py - Keeps the original raw workflow intact (
preprocess.py, raw pool training/evaluation) - Supports runtime switching between:
dataset.example_pool_type=rawdataset.example_pool_type=centroid
- Stores checkpoints separately for clean comparison:
outputs/TrajICL/raw/outputs/TrajICL/centroid/
Expected dataset location for MOTSynth annotations:
dataset/mot_annotations/<scene_id>/gt/gt.txt
The code resolves dataset roots automatically from repository-local dataset structure.
cd ~/Projects/TrajICL
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtpython preprocess.py --name motsynth --stage allpython preprocess_centroids.py --name motsynth --stage allFor fair raw-vs-centroid validation (same val query anchors), enable raw-query matching:
python preprocess_centroids.py --name motsynth --stage all --match_raw_queriesWhen enabled, query matching is applied on val split by default, producing one centroid query per raw validation query window when a valid centroid match exists.
Paper-aligned defaults used by centroid preprocessing:
- direction threshold:
50degrees - location threshold:
120pixels - LOF contamination:
0.2 - LOF neighbor ratio:
0.8 - cluster re-evaluation interval:
10frames - temporary recluster minimum size:
10 - centroid delta update interval:
10frames
python train.py -m dataset.name=motsynth dataset.example_pool_type=rawPrimary checkpoint target:
outputs/TrajICL/raw/best_val_checkpoint.pth.tar
python train.py -m dataset.name=motsynth dataset.example_pool_type=centroidPrimary checkpoint target:
outputs/TrajICL/centroid/best_val_checkpoint.pth.tar
Raw:
python eval.py \
--model_path outputs/TrajICL/raw/best_val_checkpoint.pth.tar \
--dataset_name motsynth \
--example_pool_type rawCentroid:
python eval.py \
--model_path outputs/TrajICL/centroid/best_val_checkpoint.pth.tar \
--dataset_name motsynth \
--example_pool_type centroidpython compare_checkpoints.py \
--baseline_model_path outputs/TrajICL/raw/best_val_checkpoint.pth.tar \
--candidate_model_path outputs/TrajICL/centroid/best_val_checkpoint.pth.tar \
--baseline_label original_trained \
--candidate_label centroid_trained \
--dataset_name motsynth \
--prompting_method sim \
--pools raw,centroid \
--shots 0,2,4,8 \
--device cudaoutputs/processed_data/motsynth/-> raw processed pooloutputs/processed_data/motsynth_centroid/-> centroid processed poolclustered_dataset/motsynth_centroid/<split>/{scene_num}.csv-> per-scene clustered centroid trajectoriesoutputs/TrajICL/raw/-> raw-model checkpointsoutputs/TrajICL/centroid/-> centroid-model checkpointsoutputs/comparison/-> benchmark reportsoutputs/logs/-> captured run logs
- If centroid preprocessing logic changes, regenerate centroid processed data before training/evaluation.
- For strict raw-vs-centroid validation fairness, preprocess centroid data with
--match_raw_queries. - Raw and centroid checkpoints should be trained/evaluated with matched hyperparameters for fair comparison.
- If runs are terminated by OOM (
Killed), reduce worker count and batch size.
- TrajICL foundation: Towards Predicting Any Human Trajectory In Context (NeurIPS 2025)
- Dynamic clustering reference: Efficient Dense Crowd Trajectory Prediction Via Dynamic Clustering