A compact, production-style computer vision project for classifying German traffic signs from the GTSRB dataset.
This repository is designed to be simple but professional:
- PyTorch training pipeline
- Torchvision dataset download with
download=True - CNN baseline and ResNet18 transfer learning
- validation split, test evaluation, and saved metrics
- Matplotlib-only reporting figures
- FastAPI inference endpoint
- Dockerfile, Makefile, pyproject.toml, requirements.txt, GitHub Actions
The project uses torchvision.datasets.GTSRB, so the dataset can be downloaded directly from code:
from torchvision.datasets import GTSRB
train_dataset = GTSRB(root="data", split="train", download=True)
test_dataset = GTSRB(root="data", split="test", download=True)python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txt
pip install -e .make trainmake evaluateRun locally:
make apiThen open:
http://localhost:8000/docs
Health check:
curl http://localhost:8000/healthImage prediction:
curl -X POST "http://localhost:8000/predict" \
-F "file=@path/to/sign.png"Build:
make docker-buildRun:
make docker-runThe container expects the trained model to exist at:
models/gtsrb_resnet18_best.pt
You can mount your local model folder:
docker run --rm -p 8000:8000 \
-v "$(pwd)/models:/app/models" \
gtsrb-classifier:latestThe plotting utilities in src/gtsrb_classifier/plots.py use a clean Matplotlib recipe style:
plt.rcParams["figure.dpi"] = 600
plt.rcParams["savefig.dpi"] = 600
plt.rcParams["mathtext.fontset"] = "cm"
plt.rcParams["font.family"] = "serif"Reusable plotting functions:
from gtsrb_classifier.plots import plot_confusion_matrix, plot_training_curves