- Version: 20261019
- Source Code Copyright: GNU Affero General Public License v3.0 (AGPL-3.0) — ultralytics/ultralytics
- Vendored ultralytics 8.4.16 engine in src/ultralytics.
- Redistribution Restriction: This source code is integrated by LEADERG INC. Please use it privately. Please DO NOT distribute it to internet.
Console/terminal pipeline for training and running a YOLO26 image-classification model on Windows 11, Ubuntu Linux 24.04 and macOS 14+ (Apple Silicon). The vendored ultralytics 8.4.16 engine (AGPL/GPL, src/ultralytics) is imported from source; no pip ultralytics is needed. Two datasets ship with trained weights: plate (steel-surface defects, 6 classes) and chest (chest X-ray, NORMAL / PNEUMONIA).
GPU: training and inference run on an NVIDIA GPU (CUDA) on Windows and Linux and on the Apple GPU (MPS) on Apple Silicon Macs, with automatic CPU fallback (--device auto: CUDA → MPS → CPU). Training YOLO26x-cls on the CPU works but is slow.
[Folder Layout]
- data/{dataset}/ — train/, val/, test/ class subfolders and ImageNet.yaml.
- model/{dataset}/ — starting weights (yolo26x-cls.pt), the shipped trained model (best.pt) and training output (best.pt, last.pt, results.csv, plots; a new training run replaces best.pt).
- tool/ — shared utility helpers (tools.py, including the device selection CUDA → MPS → CPU).
- src/ — Python entry points, launcher scripts, requirements, and the bundled ultralytics package.
- venv/ — virtual environment created by 02_venv_create_windows.bat / 02_venv_create_linux.sh / 02_venv_create_mac.sh.
[Prerequisites]
- Python 3.14, installed by 01_python_install_windows.bat (winget), 01_python_install_linux.sh (apt; deadsnakes PPA when needed; needs sudo) or 01_python_install_mac.sh (Homebrew).
- 02_venv_create_windows.bat / 02_venv_create_linux.sh / 02_venv_create_mac.sh install PyTorch 2.13.0 + torchvision 0.28.0 first, then src/requirements.txt. No pip ultralytics — the engine is vendored.
- Windows / Linux GPU: the PyTorch CUDA 13.0 (cu130) build; needs an NVIDIA Turing-or-newer GPU (GTX 16 / RTX 20 and later) and a driver supporting CUDA 13.0+ (check nvidia-smi). Pascal/Volta GPUs (GTX 10xx, V100) are not supported by cu130 (reinstall torch/torchvision from the cu126 index for those). Without a usable NVIDIA GPU everything runs on the CPU.
- macOS: Apple Silicon (arm64) with macOS 14+ only (PyTorch has no Intel-Mac wheels); training and inference use the Apple GPU through Metal (MPS), and operations MPS lacks fall back to the CPU.
- Windows 11 uses the .bat launchers; Ubuntu 24.04 and macOS use the .sh launchers.
[Quick Start (Windows 11)]
src\01_python_install_windows.bat
src\02_venv_create_windows.bat
src\04_create_yaml.bat --dataset plate
src\05_train.bat --dataset plate --epochs 100
src\06_inference.bat --dataset plate --source data\plate\test\crazing-11.png
src\07_inference_folder.bat --dataset plate --source data\plate\test
Open a new terminal after 01_python_install_windows.bat before running 02_venv_create_windows.bat.
[Quick Start (Ubuntu 24.04)]
bash src/01_python_install_linux.sh
bash src/02_venv_create_linux.sh
bash src/04_create_yaml.sh --dataset plate
bash src/05_train.sh --dataset plate --epochs 100
bash src/06_inference.sh --dataset plate --source data/plate/test/crazing-11.png
bash src/07_inference_folder.sh --dataset plate --source data/plate/test
[Quick Start (macOS 14+, Apple Silicon)]
bash src/01_python_install_mac.sh
bash src/02_venv_create_mac.sh
bash src/04_create_yaml.sh --dataset plate
bash src/05_train.sh --dataset plate --epochs 100
bash src/06_inference.sh --dataset plate --source data/plate/test/crazing-11.png
bash src/07_inference_folder.sh --dataset plate --source data/plate/test
[Launcher Scripts]
1. 01_python_install_windows.bat / 01_python_install_linux.sh / 01_python_install_mac.sh
Install Python 3.14 (winget / apt + deadsnakes PPA / Homebrew). Does nothing if it is already installed.
2. 02_venv_create_windows.bat / 02_venv_create_linux.sh / 02_venv_create_mac.sh
Recreate the venv with Python 3.14, install PyTorch 2.13.0 + torchvision 0.28.0 (Windows/Linux: CUDA 13.0 build; macOS: PyPI build with MPS) and src/requirements.txt. Aborts loudly if pip fails; prints whether CUDA (macOS: MPS) is available.
3. 03_venv_activate.bat / 03_venv_activate.sh
Activate the venv in the current shell so you can run python directly. On Windows: src\03_venv_activate.bat. On Linux/macOS you must source it: source src/03_venv_activate.sh. Optional — scripts 04–07 use the venv's Python directly. If the project folder was renamed after the venv was created, re-create the venv with 02_venv_create_windows/linux/mac first; the other launchers do not need activation.
4. 04_create_yaml.bat / 04_create_yaml.sh
Rebuild ImageNet.yaml from the class folders under train/.
5. 05_train.bat / 05_train.sh
Train the classifier (auto-creates ImageNet.yaml if missing).
6. 06_inference.bat / 06_inference.sh
Run inference on a single image.
7. 07_inference_folder.bat / 07_inference_folder.sh
Run inference on a folder of images.
8. 99_venv_clean.bat / 99_venv_clean.sh
Delete the venv folder.
9. 99_venv_deactivate.bat / 99_venv_deactivate.sh
Deactivate the venv in the current shell. On Linux/macOS, source it: source src/99_venv_deactivate.sh (bash or zsh).
[Python Entry Points]
- src/create_yaml.py — walk data/{dataset}/train/ and emit ImageNet.yaml.
- src/train.py — train YOLO26 classification. CLI: --dataset --batch-size --image-size --epochs --workers --device --weights.
- src/inference.py — single-image or folder inference. CLI: --dataset --source --image-size --device --threshold --weights --show.
- train.py and inference.py take --device auto|cuda|cuda:N|mps|cpu (default auto: CUDA, then MPS, then CPU; a bare index such as 0 means cuda:0) and print the selected device at startup (Device: cuda).
- Training progress is printed to the console; the engine also writes results.csv / results.png to model/{dataset}/.
[Troubleshooting]
- Device: cpu although the PC has an NVIDIA GPU: the CUDA 13.0 build needs a driver supporting CUDA 13.0+ and a Turing-or-newer GPU. Update the driver; for Pascal/Volta GPUs reinstall torch/torchvision from https://download.pytorch.org/whl/cu126 inside the venv.
- 02_venv_create_mac.sh stops with "Apple Silicon (arm64) only": PyTorch 2.13 has no Intel-Mac wheels; use an Apple Silicon Mac with an arm64 Python.
[References]
- Ultralytics source: https://github.com/ultralytics/ultralytics
- Ultralytics docs: https://docs.ultralytics.com/
- Classification task reference: https://docs.ultralytics.com/tasks/classify/
- ImageNet dataset spec: https://www.image-net.org/
- PyTorch install matrix (CUDA / MPS builds): https://pytorch.org/get-started/locally/
This SDK is built in AppForAI - AI Dev Tools.