How exmorgan-alter/afafsgd works
1. Project purpose
- This repository implements the method from the paper *“Anchor-Aware Similarity Cohesion in Target Frames Enables Predicting Temporal Moment Boundaries in 2D”*.
- Architecturally, it is a PyTorch temporal moment boundary localization system: it takes prepared video/query data, predicts temporal boundaries, and evaluates them on the QHV benchmark.
2. Top-level execution flow
- main.py is the main entry point for training and/or validation.
- warm_up.py suggests a separate startup phase for learning-rate warmup or early training scheduling.
- The typical flow is: dataset loading → model forward pass → loss computation → optimizer update → checkpointing/evaluation.
3. Dataset boundary
- dataset/ contains the data access layer, with QHVdata.py likely implementing the dataset-specific loader and base.py providing shared dataset behavior.
- The README says to prepare data according to Moment-DETR, so the repository likely consumes preprocessed features and annotations rather than raw video decoding.
- This is an important architectural boundary: data preparation happens outside the repo, while this repo focuses on training and inference over the prepared tensors/metadata.
4. Model composition
- model/ is split into reusable components and task-specific detectors.
- model/model.py, model/base.py, and model/detect.py appear to define the overall model wrapper and inference-facing interfaces.
- This separation suggests the project is modular: backbone/feature encoding is decoupled from the boundary-prediction head.
5. Backbone / feature encoders
- model/CNNs/ contains CNN options such as resnet.py, mknet.py, and vanilla.py.
- These are likely interchangeable visual encoders or feature transformation blocks.
- From an architecture-diagram perspective, this is the feature extraction stage before temporal reasoning.
6. Temporal and detection modules
- model/temporal.py handles temporal aggregation or sequence modeling across frames/clips.
- model/Det/ contains the detection stack:
- Conv.py for convolutional processing,
- attention.py for attention-based interaction,
- detr.py for DETR-style temporal set prediction,
- tan.py for temporal anchor-based localization.
- This directory is the core of the paper’s method: it likely converts encoded video/query features into boundary predictions on a temporal grid or set of candidate moments.
7. Algorithmic focus
- The paper title indicates anchor-aware similarity cohesion and 2D target-frame boundary prediction.
- In architectural terms, the system likely builds a 2D temporal representation of candidate segments or frame pairs, then scores boundary coherence using anchor-aware mechanisms.
- That means the main computation is not just classification, but structured temporal localization with boundary-sensitive prediction.
8. Loss and supervision
- loss.py centralizes training objectives.
- Given the task, this likely combines localization losses for start/end boundaries with auxiliary matching or classification terms from the detector head.
- Keeping losses separate from model code makes it easier to swap detector variants while preserving the same training objective.
9. Evaluation path
- eval/eval_qhv.py handles benchmark-specific evaluation for QHV.
- This is likely where predicted moments are converted into metrics such as IoU-based accuracy, recall, or mAP-style scores depending on the benchmark protocol.
- Evaluation is isolated from training, which helps keep the inference contract stable.
10. Utilities and shared helpers
- utilize.py likely contains miscellaneous helpers such as tensor/device utilities, logging, metrics, or checkpoint support.
- model/__init__.py, dataset/__init__.py, and eval/__init__.py indicate package-level exports for cleaner imports.
- Overall, the repo is organized around a clean pipeline: prepared dataset → modular encoder/detector model → localization losses → QHV evaluation.
Main entry points: detect.py detect.py · model.py model.py · main.py main.py · loss.py loss.py
Components 18
Training
Entry points, optimization, and shared utilities
- main.py · Main training and validation driver
main.py - warm_up.py · Warmup or early-stage training routine
warm_up.py - loss.py · Training objectives for boundary localization
loss.py - utilize.py · Shared utility functions
utilize.py
Data
Prepared dataset loaders and access layer
- QHVdata.py · QHV-specific prepared data loader
dataset/QHVdata.py - base.py · Common dataset behavior and shared access logic
dataset/base.py
Model
Encoder, temporal reasoning, and detection stack
- model.py · Top-level model assembly and forward interface
model/model.py - base.py · Shared model components and abstractions
model/base.py - detect.py · Detection-facing model interface
model/detect.py - temporal.py · Temporal aggregation and sequence reasoning
model/temporal.py - resnet.py · ResNet-based feature encoder
model/CNNs/resnet.py - mknet.py · MKNet-style feature encoder
model/CNNs/mknet.py - vanilla.py · Baseline feature encoder
model/CNNs/vanilla.py - Conv.py · Convolutional detection block
model/Det/Conv.py - attention.py · Attention-based interaction block
model/Det/attention.py - detr.py · DETR-style temporal set prediction
model/Det/detr.py - tan.py · Temporal anchor-based localization head
model/Det/tan.py
Evaluation
Benchmark-specific scoring
- eval_qhv.py · QHV benchmark metrics and scoring
eval/eval_qhv.py
Connections 20
- main.py → QHVdata.py: loads · Training and validation data pipeline
- main.py → model.py: runs · Builds and executes the localization model
- main.py → loss.py: optimizes · Applies task losses during training
- main.py → eval_qhv.py: validates · Evaluates predictions on QHV
- main.py → warm_up.py: schedules · Optional warmup phase
- main.py → utilize.py: uses · Logging, device, or checkpoint helpers
- QHVdata.py → base.py: extends · Dataset-specific loader built on shared base behavior
- model.py → base.py: composes · Top-level model relies on shared base abstractions
- model.py → detect.py: exposes · Inference-facing detection interface
- model.py → temporal.py: includes · Temporal reasoning stage
- model.py → resnet.py: encodes · Visual feature extraction option
- model.py → mknet.py: encodes · Alternative visual feature extraction option
- model.py → vanilla.py: encodes · Baseline visual feature extraction option
- detect.py → Conv.py: uses · Convolutional detector processing
- detect.py → attention.py: uses · Attention-based detector interaction
- detect.py → detr.py: uses · DETR-style boundary prediction
- detect.py → tan.py: uses · Anchor-based temporal localization
- detect.py → temporal.py: consumes · Detector consumes temporally aggregated features
- loss.py → detect.py: supervises · Losses are computed from detector outputs
- eval_qhv.py → detect.py: scores · Evaluation consumes predicted moments