Python PyTorch Deep Learning Computer Vision
Flower Species Image Classifier
Deep learning command-line application that uses transfer learning (ResNet18/VGG13) to classify 102 different flower species with PyTorch.
Flower Species Image Classifier
Overview
This project is a deep learning-based image classification application developed in Python. It provides a robust command-line interface (CLI) for training a custom neural network classifier on top of pre-trained architectures (like ResNet18 and VGG13) and using it to predict flower species from raw images with high accuracy.
Key Features
- Transfer Learning: Leverages PyTorch’s pre-trained ImageNet models (
resnet18andvgg13) as powerful feature extractors for computer vision tasks. - Custom Classifier Architecture: Modifies the base models by seamlessly swapping native fully connected layers with a dynamically configurable classifier to map specifically to 102 flower categories.
- CLI Utilities:
train.py: Allows users to define custom learning rates, hidden layer sizing, training epochs, model architecture, and GPU acceleration. It saves the training progress, weights, and configurations to a reusable checkpoint.predict.py: Reconstructs the saved model using the dynamic checkpoint metadata to predict the Top-K most probable flower species for any given image input.
- Data Augmentation: Implements
torchvision.transformsto augment training data—applying random rotations, resized crops, and horizontal flips—to significantly reduce model overfitting.
Technical Stack
- Language: Python 3
- Deep Learning Framework: PyTorch
- Data Processing & Visualization: NumPy, PIL (Pillow), Matplotlib, torchvision
- Core Concepts: Transfer Learning, Deep Neural Networks, Optimizer Tuning (Adam), Loss Functions (NLLLoss), GPU Acceleration (CUDA)
How It Works
- Data Preprocessing: Images are loaded, resized, center-cropped to
224x224pixels, converted to PyTorch tensors, and normalized against ImageNet standard metrics. - Training Phase: The model freezes the heavy convolutional base representations (preventing them from losing generalized visual knowledge) and only calculates gradients/backpropagates through the new custom classifier block.
- Inference Phase: Input images are fed through the evaluation-ready model. Exponentiated
LogSoftmaxoutputs are used to extract the highest probabilities and map them to human-readable flower names via a JSON dictionary.
Result
A highly accurate and configurable inference model that intelligently categorizes botanical species, showcasing strong foundational ML engineering practices and PyTorch framework knowledge.