Kompletní end-to-end machine learning projekt demonstrující inferenci v reálném čase na plnobarevných (RGB) obrázcích. Aplikace využívá vlastní hlubokou konvoluční síť (CNN) natrénovanou na datasetu CIFAR-10 k rozpoznávání 10 různých tříd objektů a zvířat. A complete end-to-end machine learning project demonstrating real-time inference on full-color (RGB) images. This application utilizes a custom deep Convolutional Neural Network (CNN) trained on the CIFAR-10 dataset to recognize 10 different classes of objects and animals.
Ukázka uživatelského rozhraní CustomTkinter CustomTkinter User Interface Showcase
Tento projekt staví na předchozích modelech a představuje složitost reálných barevných obrazů: Building upon previous models, this project introduces the complexities of real-world colored images:
Batch Normalization a Dropout, aby se zabránilo overfittingu na složitějších texturách.
Transitioning from 1-channel to 3-channel RGB images requires a deeper network architecture with Batch Normalization and Dropout to prevent overfitting on complex textures.
RandomCrop s paddingem a RandomHorizontalFlip), které zajišťují robustní zobecnění modelu.
The training pipeline utilizes CIFAR-specific augmentations (RandomCrop with padding and RandomHorizontalFlip) to ensure robust generalization.
CustomTkinter s dynamickými prvky (progress bar pro jistotu modelu, barevně odlišené výsledky).
Built with CustomTkinter, offering a modern, dark, "borderless" dashboard with rounded corners and dynamic elements.
ReduceLROnPlateau) a sledováním přes TensorBoard a Weights & Biases.
Encapsulated training pipeline with automatic checkpoints, a dynamic ReduceLROnPlateau learning rate scheduler, and tracking using TensorBoard and Weights & Biases.
cifar10_vision_dashboard/
├── data/
│ ├── dataset/ # Downloaded CIFAR-10 data
│ └── model/ # Saved final models (.pth)
├── src/
│ ├── app.py # Main GUI application
│ ├── model.py # Deeper CNN architecture definition
│ ├── train.py # Training configuration and augmentations
│ └── trainer.py # Encapsulated training loop and logging
├── requirements.txt
└── README.md
Doporučuje se použít čisté virtuální prostředí. Ensure you are using a clean virtual environment.
1. Instalace závislostí1. Install Dependencies
pip install -r requirements.txt
2. Trénování modelu2. Train the Model
Spusťte trénovací pipeline. Skript stáhne CIFAR-10 dataset, inicializuje W&B a uloží nejlepší váhy. Run the training pipeline. The script will download the CIFAR-10 dataset, initialize W&B, and save the best model.
python src/train.py
3. Spuštění aplikace3. Run the Application
Spusťte vizuální dashboard pro inferenci v reálném čase. Launch the visual dashboard for real-time inference.
python src/app.py
Pro zvládnutí složitosti 32x32 RGB snímků je navržen hlubší a stabilnější vlastní PyTorch model. Využívá 3 konvoluční bloky (s Batch Normalizací pro stabilizaci tréninku) a klasifikátor s vrstvou Dropout, která výrazně omezuje overfitting. To handle the complexity of 32x32 RGB images, the custom PyTorch model is designed with a deeper, stabilized architecture. It utilizes 3 Convolutional Blocks (with Batch Normalization for stability) and a Classifier with a Dropout layer to significantly reduce overfitting.
import torch.nn as nn
class CIFAR10ClassifierCNN(nn.Module):
def __init__(self):
super().__init__()
# Feature Extractor (3 Convolutional Blocks)
self.features = nn.Sequential(
# Block 1 (3 channels -> 32)
nn.Conv2d(3, 32, kernel_size=3, padding=1),
nn.BatchNorm2d(32),
nn.ReLU(),
nn.MaxPool2d(2),
# Block 2 (32 channels -> 64)
nn.Conv2d(32, 64, kernel_size=3, padding=1),
nn.BatchNorm2d(64),
nn.ReLU(),
nn.MaxPool2d(2),
# Block 3 (64 channels -> 128)
nn.Conv2d(64, 128, kernel_size=3, padding=1),
nn.BatchNorm2d(128),
nn.ReLU(),
nn.MaxPool2d(2)
)
# Classifier: 128 * 4 * 4 = 2048 parameters flattened
self.classifier = nn.Sequential(
nn.Flatten(),
nn.Linear(2048, 512),
nn.ReLU(),
nn.Dropout(p=0.5), # Prevents overfitting
nn.Linear(512, 10)
)
def forward(self, x):
return self.classifier(self.features(x))
Všechny trénovací běhy jsou automaticky logovány. Křivky ztrátové funkce a metrik můžete sledovat lokálně pomocí TensorBoardu: All training runs are automatically logged. You can view the loss curves and accuracy metrics locally using TensorBoard:
tensorboard --logdir data/runs
Případně si je můžete zobrazit v cloudových dashboardech vašeho účtu Weights & Biases. Or view your rich dashboards in the cloud via your Weights & Biases account.