Skip to content

Repository files navigation

AI Programming with Python

A collection of deep learning projects demonstrating image classification using PyTorch and pre-trained models. This repository contains two comprehensive projects that showcase different approaches to image classification and transfer learning.

Projects Overview

1. Create Your Own Image Classifier

Location: Create Your Own Image Classifier/

A complete deep learning project that trains a neural network to classify flower images into 102 different categories. This project demonstrates how to build, train, and deploy a custom image classifier using transfer learning.

Key Features:

  • Transfer learning with pre-trained CNN models (VGG16, VGG13, DenseNet121, AlexNet)
  • Custom classifier training on flower dataset
  • Command line interface for training and prediction
  • Model checkpointing and visualization
  • Achieves up to 86.45% test accuracy

Technologies: PyTorch, torchvision, transfer learning, data augmentation

2. Use a Pre-trained Image Classifier to Identify Dog Breeds

Location: Use a Pre-trained Image Classifier to Identify Dog Breeds/

A comprehensive image classification system designed for a city dog show to ensure only actual dogs are registered for the competition. This project uses pre-trained CNN models to classify images as dogs or non-dogs and identify specific dog breeds.

Key Features:

  • Dog vs non-dog classification with 100% accuracy
  • Dog breed identification with up to 93.3% accuracy
  • Model comparison across different architectures
  • Comprehensive performance analysis and timing
  • Real-world application for dog show registration

Technologies: PyTorch, pre-trained models, model comparison, performance analysis

Project Comparison

Aspect Flower Classifier Dog Breed Classifier
Purpose Train custom classifier Use pre-trained models
Dataset 102 flower categories 133 dog breeds + non-dogs
Approach Transfer learning + training Pre-trained model inference
Accuracy Up to 86.45% Up to 93.3% breed classification
Focus Model training and optimization Model comparison and evaluation
Output Trained model + predictions Performance analysis + recommendations

Learning Objectives

These projects demonstrate:

  1. Transfer Learning: How to leverage pre-trained models for new tasks
  2. Model Training: Complete pipeline from data loading to model saving
  3. Model Evaluation: Comprehensive performance analysis and comparison
  4. Real-world Applications: Practical use cases for image classification
  5. Command Line Tools: Building user-friendly interfaces for ML models
  6. Data Preprocessing: Proper image augmentation and normalization
  7. Model Optimization: Hyperparameter tuning and architecture selection

Prerequisites

  • Python 3.6+
  • PyTorch
  • torchvision
  • PIL (Pillow)
  • matplotlib
  • numpy

Installation

  1. Clone the repository:
git clone <repository-url>
cd AI-Programming-with-Python
  1. Install required packages:
pip install torch torchvision pillow matplotlib numpy

Quick Start

Flower Classification

cd "Create Your Own Image Classifier"
python train.py data_directory --arch vgg16 --epochs 10
python predict.py image.jpg checkpoint.pth --top_k 5

Dog Breed Classification

cd "Use a Pre-trained Image Classifier to Identify Dog Breeds"
python check_images.py --dir pet_images --arch vgg --dogfile dognames.txt
python compare_models.py

Project Structure

AI-Programming-with-Python/
├── Create Your Own Image Classifier/
│   ├── Image Classifier Project.ipynb    # Complete implementation notebook
│   ├── train.py                          # Training script
│   ├── predict.py                        # Prediction script
│   └── README.md                         # Project documentation
├── Use a Pre-trained Image Classifier to Identify Dog Breeds/
│   ├── data/                             # Test images and data files
│   ├── project-workspace-*/              # Individual implementation workspaces
│   └── README.md                         # Project documentation
└── README.md                             # This file

Key Technologies

  • PyTorch: Deep learning framework
  • torchvision: Computer vision utilities and pre-trained models
  • Transfer Learning: Leveraging pre-trained models for new tasks
  • Data Augmentation: Improving model robustness with image transformations
  • Model Evaluation: Comprehensive performance metrics and analysis
  • Command Line Interfaces: User-friendly ML tool interfaces

Performance Highlights

Flower Classification

  • Test Accuracy: Up to 86.45%
  • Model Size: ~357 MB checkpoint
  • Training Time: ~5 epochs for convergence
  • Supported Architectures: VGG16, VGG13, DenseNet121, AlexNet

Dog Breed Classification

  • Dog Detection: 100% accuracy across all models
  • Breed Classification: Up to 93.3% accuracy (VGG)
  • Model Comparison: AlexNet, VGG, ResNet performance analysis
  • Runtime Analysis: Complete timing measurements

Use Cases

Flower Classifier

  • Botanical research and identification
  • Educational tools for plant recognition
  • Mobile apps for nature enthusiasts
  • Agricultural applications

Dog Breed Classifier

  • Pet registration systems
  • Veterinary applications
  • Animal shelter management
  • Pet adoption platforms

Future Enhancements

  • Support for additional model architectures
  • Real-time camera classification
  • Web interfaces for both projects
  • Mobile app integration
  • Model ensemble methods
  • Hyperparameter optimization tools

Contributing

This repository contains educational projects from the AI Programming with Python course. Feel free to explore the code, run the examples, and experiment with different parameters and architectures.

License

This project is part of the AI Programming with Python course materials.

Contact

For questions about these projects or the AI Programming with Python course, please refer to the individual project README files for detailed documentation and usage instructions.

About

Udacity Nanodegree

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages