This repository contains the codebase for the CSC_43M04_EP - Modal d'informatique - Deep Learning in Computer Vision Challenge "What_Happens_Next?"
The codebase allows to train a video classifier on folders of extracted frames. Each video is a directory of JPG frames; the model sees a fixed number of frames per clip and predicts one class among 33 action categories.
- Download the prepared dataset from Google Drive: frames.zip.
- Unzip it so that you have a
processed_datafolder at the root of this project (next tosrc/), with at least:processed_data/train/— class subfolders, each containingvideo_<id>/frame_*.jpgprocessed_data/val/— same layout for validationprocessed_data/test/— video subfolders, used for submission The exact subfolder names underprocessed_datamust match what you set in the Hydra config (see below). The default configuration expects paths likeprocessed_data/train,processed_data/val, andprocessed_data/test(seesrc/configs/data/default.yaml).
If your zip uses a different folder name than val2, either rename it or override the paths on the command line (examples below).
Use Python 3.10+ and uv:
uv syncRun training and evaluation from the src/ directory so Hydra finds configs/:
cd srcOr from the repo root:
python src/train.py experiment=cnn_lstm| Piece | Role |
|---|---|
dataset/video_dataset.py |
Loads T frames per video folder, applies image transforms, returns tensors (batch, time, channels, height, width) and integer labels. |
models/ |
Neural networks: each model maps a batch of shape (B, T, C, H, W) to logits (B, num_classes). |
utils.py |
Image transforms, train/val split helper, seeds. |
train.py |
Training loop; saves the best checkpoint by validation accuracy (full Hydra config + weights). |
evaluate.py |
Rebuilds the model from the checkpoint config and reports top-1 and top-5 on the full validation directory (dataset.val_dir). |
create_submission.py |
Loads a checkpoint, runs inference on the test split, writes video_name,predicted_class. |
configs/ |
Hydra YAML: experiment/ (choose a preset), model/, data/, train/. |
The main composition file is configs/config.yaml. Global values such as num_classes: 33 apply across model configs.
An experiment selects which model and other settings (learning rate, optimizer, data augmentation) to use without editing Python. Defaults live in configs/experiment/:
baseline_from_scratch— ResNet18 backbone, average pooling over time (Track 1 - Closed World)baseline_pretrained— pretrained ResNet18 backbone, average pooling over time (Track 2 - Open World)
Run:
python src/train.py experiment=baseline_from_scratchThis sets the active model group (via Hydra override /model: ...). You can still override any field:
python train.py experiment=baseline_from_scratch model.pretrained=false dataset.train_dir=/path/to/train
python train.py training.epochs=10 training.batch_size=16 training.lr=0.0001The best checkpoint is written to training.checkpoint_path (see printed path). It always stores the full merged Hydra config, so evaluation and submission reload the same architecture automatically.
Hydra may create an outputs/ folder with logs for each run.
Evaluation uses the entire validation set under dataset.val_dir (no random split). The checkpoint must have been produced by the current train.py (it needs the saved config inside the .pt file).
python evaluate.py training.checkpoint_path=best_model.ptpython evaluate.py training.checkpoint_path=/path/to/ckpt.pt dataset.val_dir=/path/to/valReads test frames from dataset.test_dir, clip order from dataset.test_manifest, writes dataset.submission_output.
python create_submission.py training.checkpoint_path=best_model.ptpython create_submission.py \
training.checkpoint_path=best_model.pt \
dataset.submission_output=../my_submission.csvCSV format:
video_name,predicted_class
video_12345,7
-
Implement
torch.nn.Moduleinsrc/models/your_model.py.- Input:
(B, T, C, H, W) - Output: logits
(B, num_classes).
- Input:
-
Register once in
train.pyinsidebuild_model(): add a branch forcfg.model.name == "your_model_name"and return your module. -
Add
src/configs/model/your_model.yaml:# @package _global_ model: name: your_model_name pretrained: true num_classes: ${num_classes} # your hyperparameters
-
Add an experiment
src/configs/experiment/your_experiment.yamlthat points Hydra at that model:# @package _global_ defaults: - override /model: your_model
Optionally add more
defaultslines or same-level keys to override data or training for that experiment only. -
Train:
python train.py experiment=your_experiment
evaluate.py and create_submission.py do not need edits: they call build_model with the config saved in your checkpoint.
- Set
training.device=cudawhen a GPU is available; usecpuotherwise. - Keep
num_classesinconfigs/config.yamlaligned with the dataset (default 33). dataset.seedcontrols the internal train/val split during training only.
If something fails, check that processed_data paths in configs/data/default.yaml (or your CLI overrides) match the folder you downloaded.