How oucyy361/ouc-cge works
1. This repository is a video-recognition training/evaluation framework built on Facebook’s SlowFast codebase, adapted for the OUC-CGE classroom group engagement dataset. The core task is clip-level classification from visual input, with labels for high/medium/low engagement.
2. The architecture is organized around a pipeline: dataset manifests and video clips feed a configurable data loader, the loader produces sampled clip tensors, models compute logits, and training/test utilities handle optimization, checkpointing, metrics, and reporting.
3. The dataset boundary is explicit. train.csv, val.csv, and test.csv define the OUC-CGE splits, while slowfast/datasets/ contains the dataset adapters and video decoding/transformation logic. This layer abstracts away whether the input comes from Kinetics-style datasets or the classroom dataset, so the rest of the stack sees standardized tensors and labels.
4. Data ingestion is handled by slowfast/datasets/loader.py, build.py, decoder.py, and transform modules such as transform.py, cv2_transform.py, rand_augment.py, mixup.py, and random_erasing.py. This subsystem is responsible for clip sampling, frame decoding, augmentation, and batch assembly, which is the main preprocessing boundary before model execution.
5. Model construction lives in slowfast/models/. The repo includes multiple video backbones and heads: SlowFast, Slow, C2D, I3D, X3D, MViT/MViTv2, reversible MViT, plus supporting blocks like stems, residual helpers, non-local blocks, attention, and classification heads. The design is modular: a builder selects a backbone from configuration, and a head converts spatiotemporal features into class predictions.
6. Configuration is centralized in slowfast/config/ and the many YAML files under configs/Kinetics/. These configs define model family, depth, input sampling rate, crop strategy, training schedule, and dataset-specific parameters. The presence of Kinetics-oriented configs indicates the codebase is largely reused from generic action-recognition settings, with OUC-CGE using the same framework but different data manifests.
7. The training/evaluation entrypoints are in tools/. train_net.py runs the optimization loop, test_net.py performs validation/test inference, run_net.py is the general launcher, benchmark.py measures throughput or runtime, and demo_net.py/visualization.py support interactive or qualitative inference. These scripts are the operational boundary between the framework and user-facing experiments.
8. Optimization and learning-rate behavior are implemented in slowfast/models/optimizer.py and slowfast/utils/lr_policy.py, while losses and metric computation are in slowfast/models/losses.py, slowfast/utils/metrics.py, and cal_metrics.py. This is where classification performance is computed and where the project’s reported accuracy results are derived.
9. Experiment management is handled by slowfast/utils/. This includes checkpoint save/load, distributed training support, logging, environment setup, multiprocessing, multigrid scheduling, and meter tracking. These utilities make the training pipeline scalable and reproducible across single- and multi-GPU environments.
10. The repo also contains visualization and demo infrastructure in slowfast/visualization/, including prediction overlays, Grad-CAM utilities, async prediction, TensorBoard visualization, and AVA-style demo helpers. This subsystem is separate from training: it consumes trained checkpoints and video inputs to inspect model behavior and produce qualitative outputs.
11. The main external boundary is the source dataset: OUC-CGE provides classroom videos and labels, while the codebase inherits action-recognition model families from SlowFast. The README’s reported accuracies compare several of those families on the same dataset, so the repo serves both as a dataset benchmark package and as a reusable video-classification framework.
12. In diagram terms, the key flow is: CSV split files and video clips -> dataset/decoder/augmentation layer -> model builder/backbone/head -> optimizer/loss/metrics -> checkpoints and evaluation outputs, with visualization/demos branching off from trained checkpoints. The main architectural separation is between data preparation, model execution, experiment orchestration, and qualitative analysis.
Main entry points: defaults.py Config system · train_net.py Train · test_net.py Test · loader.py Data loader
Components 18
Data pipeline
Dataset manifests, decoding, sampling, and augmentation before model execution.
- CSV splits · Train/val/test split files for the OUC-CGE engagement dataset.
train.csv - Dataset layer · Dataset-specific adapters and loaders for Kinetics, AVA, Charades, SSv2, and the classroom dataset.
slowfast/datasets/kinetics.py - Decode & aug · Clip sampling, video decoding, transforms, mixup, rand augment, and random erasing.
slowfast/datasets/decoder.py - Data loader · Builds iterable batches from dataset samples and preprocessing pipelines.
slowfast/datasets/loader.py
Models
Video backbones, heads, losses, and optimization components.
- Model build · Selects and constructs the configured video architecture.
slowfast/models/build.py - Backbones · SlowFast, Slow, C2D, I3D, X3D, MViT/MViTv2, reversible MViT, and related builders.
slowfast/models/video_model_builder.py - Core blocks · Stems, residual helpers, attention, non-local blocks, operators, and shared model utilities.
slowfast/models/resnet_helper.py - Head/Loss/Opt · Classification heads, losses, optimizer construction, and learning-rate policy.
slowfast/models/head_helper.py
Runtime
Training, evaluation, benchmarking, and orchestration entrypoints.
- Config system · Central defaults and custom config extensions plus Kinetics-oriented YAML recipes.
slowfast/config/defaults.py - Train · Main optimization entrypoint for supervised video classification.
tools/train_net.py - Test · Validation and test-time inference entrypoint.
tools/test_net.py - Runner · General experiment launcher that wires config, data, model, and runtime components.
tools/run_net.py - Benchmark · Measures runtime or input pipeline performance.
tools/benchmark.py
Utilities
Shared infrastructure for checkpoints, distributed execution, logging, and metrics.
- Metrics · Accuracy and reporting utilities, including dataset-specific metric computation.
slowfast/utils/metrics.py - Checkpoints · Save/load model states and restore experiment progress.
slowfast/utils/checkpoint.py - Runtime utils · Distributed execution, environment setup, logging, multiprocessing, meters, and multigrid support.
slowfast/utils/distributed.py
Visualization
Qualitative inference, CAMs, and demo tooling built on trained checkpoints.
- Viz tools · Prediction overlays, Grad-CAM, async predictors, demo loaders, and TensorBoard visualization.
slowfast/visualization/predictor.py - Demo entrypoints · User-facing demo and visualization scripts that consume trained checkpoints and video inputs.
tools/demo_net.py
Connections 21
- CSV splits → Dataset layer: define splits · CSV manifests specify the dataset partitions consumed by adapters.
- Dataset layer → Decode & aug: sample clips · Dataset adapters request frame decoding and preprocessing.
- Decode & aug → Data loader: assemble batches · Transformed samples are packaged into minibatches.
- Config system → Dataset layer: select dataset · Configuration chooses the dataset implementation and input settings.
- Config system → Model build: select model · Configuration determines the backbone family and head behavior.
- Config system → Train: drive run · Training entrypoint consumes experiment configuration.
- Config system → Test: drive eval · Evaluation entrypoint consumes experiment configuration.
- Config system → Benchmark: drive benchmark · Benchmarking uses the same experiment settings.
- Data loader → Train: feed batches · Training consumes sampled clip tensors and labels.
- Data loader → Test: feed batches · Evaluation consumes the same standardized batches.
- Model build → Backbones: instantiate · The builder selects a specific video architecture.
- Backbones → Core blocks: compose blocks · Backbones are assembled from reusable stems, residual, and attention components.
- Backbones → Head/Loss/Opt: emit logits · Backbones connect to task heads for classification outputs.
- Head/Loss/Opt → Train: optimize · Training uses the head, loss, optimizer, and LR policy.
- Train → Checkpoints: save state · Training writes checkpoints for recovery and later inference.
- Test → Metrics: score results · Evaluation computes reported accuracy and other metrics.
- Train → Runtime utils: orchestrate · Training relies on distributed, logging, and meter utilities.
- Test → Runtime utils: orchestrate · Evaluation reuses the shared runtime infrastructure.
- Benchmark → Runtime utils: measure · Benchmarking exercises the same execution scaffolding.
- Checkpoints → Viz tools: load weights · Visualization and demos consume trained checkpoints.
- Viz tools → Demo entrypoints: serve demos · Visualization components back the demo entrypoints.