This repository contains the implementation pipeline for the NNCV final assignment. The work is divided into two research tracks:
- Peak Performance
- Efficiency
Training is intended to run on an HPC cluster using Slurm. Final evaluation is performed through Docker challenge submissions.
NNCV_Final_Assignment/
├── models/
│ ├── peak_performance/ # SegFormer, UPerNet, Aux-Lovász UPerFormer
│ └── efficiency/ # Fast-SCNN and compressed Fast-SCNN variants
├── weights/ # Trained .pt checkpoints
├── local_data/ # Small local image folder for inference testing
├── local_output/ # Local prediction outputs
├── train_peak.py # Trainer for peak-performance models
├── train_efficiency.py # Trainer for efficiency and KD models
├── predict_peak.py # Inference for peak-performance models
├── predict_efficiency.py # Inference for efficiency models
├── jobscript_slurm.sh # Slurm job script
├── main.sh # HPC/Apptainer entry point
├── Dockerfile # Docker submission image definition
└── requirements.txt # Python dependencies
Detailed setup and submission instructions are kept in separate guide files:
SLURM_README.md # Running jobs on the Slurm HPC cluster
CHALLENGE_SUBMISSION.md # Building, testing, exporting, and submitting Docker images
This project uses Weights & Biases for logging. Before running training, you must set up your environment variables:
- Copy the template file:
cp .env.example .env - Open the new
.envfile and replaceyour_wandb_api_key_herewith your actual API key.
The training scripts expect the Cityscapes dataset to follow this structure:
data/cityscapes/
├── leftImg8bit/
│ ├── train/
│ └── val/
└── gtFine/
├── train/
└── val/
The dataset is downloaded and prepared on the HPC following the Slurm setup guide.
Before running local inference or submitting into the challenge server, build the Docker image from the root of the repository:
docker build -t nncv-inference .The Peak Performance track focuses on improving segmentation accuracy.
We start with the original Segformer-B5 and enhance it with various augmentantions (AugSegformer). Then, we couple the encoder of Segformer-B5 with an UPerNet decoder (UPerformer). In this new architecture, we attach an additional intermediate loss head and tweak the loss function (Aux-Lovász UPerFormer).
Model progression:
SegFormer-B5 (baseline) → AugSegformer → UPerFormer → Aux-Lovász UPerFormer
baseline
augsegformer
uperformer
auxlovasz_uperformer
This command is intended to be executed inside the HPC cluster through main.sh:
python train_peak.py --variant auxlovasz_uperformer --experiment-id final-peak-runTo run inference locally, we mount the local_data and local_output directories into the container so the model can read the inputs and save the predictions back to your host machine.
docker run --rm --gpus all \
-v "$(pwd)/local_data:/app/local_data" \
-v "$(pwd)/local_output:/app/local_output" \
nncv-inference predict_peak.py \
--variant auxlovasz_uperformer \
--weights_path ./weights/best_peak.pt \
--input_dir ./local_data \
--output_dir ./local_outputpython predict_peak.py \
--variant auxlovasz_uperformer \
--weights_path ./weights/best_peak.pt \
--input_dir ./local_data \
--output_dir ./local_outputThe Efficiency track focuses on real-time semantic segmentation.
We use a Fast-SCNN as baseline and then stick with a compressed Fast-SCNN variant architecture (C-FastSCNN). To this compressed variant, we perform Knowledge Distillation from a SegFormer-B5 teacher (KD-C-FastSCNN).
Model progression:
Fast-SCNN (baseline) → C-FastSCNN → KD-C-FastSCNN
fastscnn
c_fastscnn
kd_c_fastscnn
This command is intended to be executed inside the HPC cluster through main.sh:
python train_efficiency.py --variant kd_c_fastscnn --teacher-weights ./weights/segformer_teacher.ptdocker run --rm --gpus all \
-v "$(pwd)/local_data:/app/local_data" \
-v "$(pwd)/local_output:/app/local_output" \
nncv-inference predict_efficiency.py \
--variant kd_c_fastscnn \
--weights_path ./weights/best_efficiency.pt \
--input_dir ./local_data \
--output_dir ./local_outputpython predict_efficiency.py \
--variant kd_c_fastscnn \
--weights_path ./weights/best_efficiency.pt \
--input_dir ./local_data \
--output_dir ./local_outputtrain_peak.py # Peak-performance training
train_efficiency.py # Efficiency/KD training
predict_peak.py # Peak-performance inference
predict_efficiency.py # Efficiency inference
main.sh # HPC command router
jobscript_slurm.sh # Slurm submission script
Dockerfile # Submission image
- TU/e email: l.lanaras@student.tue.nl
| Model | Challenge Server Name |
|---|---|
| SegFormer baseline | LaNet_PP_v1 |
| AugSegFormer | LaNet_PP_v3 |
| UPerFormer | LaNet_Lovasz_Uper |
| Aux-Lovász UPerFormer | AuxLovászUperFormer |
| Model | Challenge Server Name |
|---|---|
| Fast-SCNN baseline | LaNet_RT_v2.6 |
| C-FastSCNN | LaNet_t4_no_kd |
| KD-C-FastSCNN | LaNet_t4_kd_0.2_0.9 |
Our KD-C-FastSCNN model ranked the highest in the 'Efficiency' benchmark:
LaNet_t4_kd_0.2_0.9 🏆