Console/terminal pipeline for training and running a RegNetY-3.2GF image classifier with PyTorch on the Facebook pycls engine, supporting Windows 11 and Ubuntu Linux 24.04. The engine lives under src/regnet/ and is configured by a yacs yaml file. The example dataset plate holds steel-plate surface defect images in 6 classes (CR, IN, PA, PS, RS and SC) and ships with the ImageNet-pretrained RegNetY-3.2GF weights and a trained checkpoint.
GPU required: the pycls engine moves the model to CUDA unconditionally, which is the upstream design. The wrappers therefore check for CUDA and exit with a clear message on CPU-only machines. Install the torch build matching your NVIDIA driver as described in the GPU section.
[Folder Structure]
- CLAUDE.md / AGENT.md: program specification (identical content).
- CHANGELOG.md: change log.
- copyright.txt: copyright notice.
- 2003.13678.pdf: RegNet reference paper.
- data/{dataset}/: RegNetY-3.2GF_dds_1gpu.yaml (the pycls config), labels_map.txt, and the train/, val/ and test/ folders (ImageFolder layout).
- model/{dataset}/: RegNetY-3.2GF_dds_8gpu.pyth (ImageNet pretrained), model_epoch_XXXX.pyth (the checkpoints), config.yaml (the config dump) and logs/ (TensorBoard).
- src/regnet/: the pycls engine, with train_net.py, the inference scripts, pycls/, configs/ and docs/.
- tool/tools.py: shared helpers.
- src/: the wrapper entry points, the launcher scripts and this document.
- venv/: Python virtual environment, created by step 01.
[Instructions]
1. 01_venv_create.bat / 01_venv_create.sh
Delete the old venv/, create a fresh one and install src/requirements.txt. Aborts loudly if pip fails.
2. 01_venv_create_gpu.bat / 01_venv_create_gpu.sh
The same as step 01, then swaps torch for the CUDA 12.8 (cu128) build, for machines with an NVIDIA GPU whose driver CUDA version is 12.8 or newer (check with nvidia-smi).
3. 02_venv_activate.bat / 02_venv_activate.sh
Activate the virtual environment. On Linux use source src/02_venv_activate.sh.
4. 03_train.bat / 03_train.sh
Train the classifier starting from the ImageNet RegNetY weights; the learning rate, epoch count and batch size all come from the yaml config.
5. 04_tensorboard.bat / 04_tensorboard.sh
Open TensorBoard on model/{dataset}/logs. Positional arguments: [dataset] [port], default plate and 6066.
6. 05_inference.bat / 05_inference.sh
Classify a single image; the default is data/plate/test/CR/CR-1.png.
7. 06_inference_folder.bat / 06_inference_folder.sh
Evaluate the whole folder given by --split (test by default) and report the top-1 and top-5 error.
8. 07_inference_folder_topk.bat / 07_inference_folder_topk.sh
The split-evaluation variant that reports underkill, overkill and right-rate statistics.
9. 99_venv_clear.bat / 99_venv_clear.sh
Delete the venv/ folder.
[Python Entry Points]
src/train.py
- --dataset plate: dataset name
- --cfg: path to the pycls yaml config (optional)
- --weights: the starting weights; pass an empty string to load none (optional)
- --workers 1: number of data-loading workers
The config defaults are IM_SIZE 512, batch size 16, cosine learning rate 0.1 and 300 epochs; edit the yaml to change them. Training starts from model/{dataset}/RegNetY-3.2GF_dds_8gpu.pyth; checkpoints land in model/{dataset}/ and the TensorBoard logs in model/{dataset}/logs/.
src/inference.py
- --dataset plate: dataset name
- --source: path to a single image (optional)
- --split test: the split folder to evaluate
- --weights: path to the weights file (optional)
- --topk-right: report the underkill, overkill and right-rate statistics instead (optional)
- --show: display the image (optional, requires a desktop session)
With --source it classifies one image; without it, it evaluates the whole split and reports the top-1 and top-5 error. The default weights are model/{dataset}/model_epoch_0004.pyth.
[Quick Start]
Windows 11 (with the GPU torch build installed)
src\01_venv_create.bat
src\05_inference.bat
src\06_inference_folder.bat
src\03_train.bat
src\04_tensorboard.bat
Ubuntu Linux 24.04
bash src/01_venv_create.sh
bash src/05_inference.sh
bash src/06_inference_folder.sh
bash src/03_train.sh
bash src/04_tensorboard.sh
[GPU]
Check your driver's CUDA version with nvidia-smi and install the matching torch build, for example CUDA 12.8:
pip uninstall -y torch torchvision
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu128
The wrappers refuse to run without CUDA, because the engine would otherwise crash mid-way.
[References]
- RegNet paper (Radosavovic et al. 2020, shipped as 2003.13678.pdf): arxiv.org/abs/2003.13678
- pycls (the engine base): github.com/facebookresearch/pycls
- PyTorch install: pytorch.org/get-started/locally
This SDK is built in AppForAI - AI Dev Tools.
Purchase license separately: USD 400, permanent authorization, single APP authorization, single machine authorization, one-year activation, one-year download, one-year update, one-year email technical support.