Console/terminal pipeline for training and running an Inception-v2 image classifier with PyTorch, supporting Windows 11 and Ubuntu Linux 24.04. The engine scripts live under src/examples/imagenet/ and support several architectures via --arch, with Inception-v2 as the default. The example dataset plate holds steel-plate surface defect images in 6 classes (CR, IN, PA, PS, RS and SC) and ships with a trained Inception-v2 checkpoint, so inference works out of the box.
[Folder Structure]
- CLAUDE.md / AGENT.md: program specification (identical content).
- CHANGELOG.md: change log.
- copyright.txt: copyright notice.
- 1512.00567.pdf: Inception-v2 / v3 reference paper.
- data/{dataset}/: labels_map.txt (the class list, regenerated by training) plus train/, val/ and test/ in the torchvision ImageFolder layout (one subfolder per class).
- model/{dataset}/: model_best.pth.tar (best checkpoint), checkpoint.pth.tar (latest) and logs/ (TensorBoard).
- tool/tools.py: shared helpers.
- src/: the wrapper entry points, the engine (examples/imagenet/), 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. 02_venv_activate.bat / 02_venv_activate.sh
Activate the virtual environment. On Linux use source src/02_venv_activate.sh.
3. 03_train.bat / 03_train.sh
Train the classifier. Defaults: dataset plate, architecture inception_v2, batch size 32, image size 512, 500 epochs, learning rate 0.0001. It resumes from model_best.pth.tar when that file is present.
4. 04_tensorboard.bat / 04_tensorboard.sh
Open TensorBoard on model/{dataset}/logs. Positional arguments: [dataset] [port], default plate and 6066.
5. 05_inference.bat / 05_inference.sh
Classify a single image; the default is data/plate/test/IN/IN-1.png.
6. 06_inference_folder.bat / 06_inference_folder.sh
Classify every image in a folder, data/{dataset}/test by default, and report Acc@1 and Acc@5.
7. 07_inference_folder_topk.bat / 07_inference_folder_topk.sh
The folder-inference variant that reports underkill, overkill and right-rate statistics.
8. 99_venv_clear.bat / 99_venv_clear.sh
Delete the venv/ folder.
[Python Entry Points]
src/train.py
- --dataset plate: dataset name
- --arch inception_v2: network architecture
- --batch-size 32: batch size
- --image-size 512: image size
- --epochs 500: number of training epochs
- --learning-rate 0.0001: learning rate
- --workers 4: number of data-loading workers
- --num-classes: number of classes (optional)
- --resume: checkpoint to resume from
- --pretrained: path to a pretrained weights file
The class count is derived from the class folders under data/{dataset}/train. It resumes from model/{dataset}/model_best.pth.tar when that file exists; --resume "" trains from scratch. Checkpoints land in model/{dataset}/ and the TensorBoard logs in model/{dataset}/logs/, which is cleared on every run.
src/inference.py
- --dataset plate: dataset name
- --arch inception_v2: network architecture
- --source: the input, either a single image or a folder
- --batch-size 64: batch size
- --image-size 512: image size
- --num-classes: number of classes (optional)
- --weights: path to the weights file (optional)
- --topk-right: switch folder mode to the underkill, overkill and right-rate variant (optional)
- --show: display each image (optional, requires a desktop session)
A file source classifies one image; a folder source reports Acc@1 and Acc@5 over all the images.
[Quick Start]
Windows 11
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
Inference works out of the box with the shipped checkpoint. Inception-v2 at image size 512 is heavy — training realistically wants an NVIDIA GPU, and CPU folder inference is slow.
[GPU]
The default PyPI torch wheel is CPU-only on Windows. For an NVIDIA GPU, check your driver's CUDA version with nvidia-smi and install the matching build, for example CUDA 12.8:
pip uninstall -y torch torchvision
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu128
The engine auto-detects CUDA and falls back to CPU when it is unavailable.
[References]
- Rethinking the Inception Architecture paper (Szegedy et al. 2015, shipped as 1512.00567.pdf): arxiv.org/abs/1512.00567
- EfficientNet-PyTorch (vendored repository): github.com/lukemelas/EfficientNet-PyTorch
- Extra architectures: zjZSTU/GoogLeNet, weiaicunzai/pytorch-cifar100, d-li14/mobilenetv3.pytorch
- 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.