Skip to content

Repository files navigation

🤖 AI Image Classifier

An AI-powered image classification app using Python, TensorFlow & Flask — upload any image and get instant predictions with a clean, modern web UI.

Python TensorFlow Flask Keras Docker License


📸 Preview

AI Image Classifier Preview

📸 How It Works

  1. 📤 Upload Image - Choose any image from your device (JPEG, PNG, or WebP)
  2. 🧠 AI Processing - The MobileNetV2 model analyzes the image in real-time
  3. 📊 Get Results - Receive top-5 predictions with confidence percentages
  4. ✨ Instant Display - View beautiful, formatted results in your browser

⚡ Application Flow

┌────────────────────────────────────────────────────────────┐
│         AI IMAGE CLASSIFIER - APPLICATION FLOW             │
├────────────────────────────────────────────────────────────┤
│                                                             │
│  STEP 1: UPLOAD INTERFACE                                  │
│  ┌──────────────────────────────────────────────────────┐  │
│  │ 📁 Drop image here or click to browse                │  │
│  │ Accepts: JPEG, PNG, WebP (max 25MB)                 │  │
│  └──────────────────────────────────────────────────────┘  │
│                            ↓                                │
│  STEP 2: AI PROCESSING                                     │
│  ┌──────────────────────────────────────────────────────┐  │
│  │ 🧠 TensorFlow + MobileNetV2 Model                    │  │
│  │ • Pre-trained on ImageNet (1,000 classes)           │  │
│  │ • Lightweight & Fast (25ms inference)               │  │
│  │ • Accurate predictions with confidence scores        │  │
│  └──────────────────────────────────────────────────────┘  │
│                            ↓                                │
│  STEP 3: DETAILED RESULTS                                  │
│  ┌──────────────────────────────────────────────────────┐  │
│  │ Top-5 Predictions:                                    │  │
│  │ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━  │  │
│  │ 1. Dog              [████████████████] 98.34%        │  │
│  │ 2. Puppy            [██████] 1.45%                  │  │
│  │ 3. Animal           [███] 0.15%                     │  │
│  │ 4. Mammal           [██] 0.04%                      │  │
│  │ 5. Canine           [█] 0.02%                       │  │
│  │ Processing time: 0.23 seconds                        │  │
│  └──────────────────────────────────────────────────────┘  │
│                                                             │
└────────────────────────────────────────────────────────────┘

✨ Key Features

  • 🖼️ Universal Image Support - Works with JPEG, PNG, and WebP formats
  • Lightning Fast - MobileNetV2 optimized for speed and accuracy
  • 📊 Confidence Scores - Top-5 predictions with detailed percentages
  • 🎨 Beautiful UI - Clean, responsive, modern web interface
  • 🔌 REST API - Programmatic access via HTTP endpoints
  • 🐳 Docker Ready - Containerized deployment for easy scaling
  • 📱 Mobile Friendly - Works seamlessly on all devices
  • 🔒 Secure - Local processing, no data sent to external servers

🛠️ Tech Stack

Tech Stack

Component Technology
ML Framework TensorFlow / Keras
Backend Python, Flask
Frontend HTML, CSS, JavaScript
Pre-trained Model MobileNetV2 (ImageNet)
Server Gunicorn
Containerization Docker
Model Size ~13 MB

📁 Project Structure

ai-image-classifier/
├── app.py                  # Flask application entry point
├── requirements.txt        # Python dependencies
├── Dockerfile             # Docker configuration
├── docker-compose.yml     # Docker compose setup
├── static/
│   ├── css/
│   │   └── style.css     # Application styling
│   └── js/
│       └── script.js     # Frontend logic
├── templates/
│   ├── base.html         # Base template
│   ├── index.html        # Upload page
│   └── results.html      # Results display
├── models/
│   └── mobilenetv2.h5    # Pre-trained model
└── utils/
    ├── predictor.py      # Prediction logic
    └── image_handler.py  # Image processing

🚀 Quick Start

Option 1: Using pip

# Clone the repository
git clone https://github.com/razinahmed/ai-image-classifier.git
cd ai-image-classifier

# Create virtual environment (recommended)
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Run the application
python app.py

# Open in browser
# Navigate to http://localhost:5000

Option 2: Using Docker

# Build the Docker image
docker build -t ai-image-classifier .

# Run the container
docker run -p 5000:5000 ai-image-classifier

# Access the application
# Navigate to http://localhost:5000

Option 3: Using Docker Compose

# Start the application
docker-compose up -d

# View logs
docker-compose logs -f

# Stop the application
docker-compose down

🔌 API Reference

Classification Endpoint

Endpoint Method Description
/predict POST Classify an uploaded image
/ GET Serve the web interface
/health GET Check API health status

Request Format

curl -X POST -F "image=@photo.jpg" http://localhost:5000/predict

Response Format

{
  "success": true,
  "predictions": [
    {
      "class": "dog",
      "confidence": 0.9834
    },
    {
      "class": "puppy",
      "confidence": 0.0145
    }
  ],
  "processing_time": 0.23
}

Error Handling

{
  "success": false,
  "error": "No image provided",
  "status_code": 400
}

🧠 Model Information

MobileNetV2

MobileNetV2 is a lightweight convolutional neural network architecture designed by Google for mobile and embedded vision applications.

Property Details
Parameters 3.5M
Model Size ~13 MB
Input Shape 224 × 224 × 3
Training Data ImageNet-1k
Classes 1,000 object classes
Accuracy (Top-1) ~71.8%
Inference Speed ~25ms (CPU)
Architecture Inverted Residuals with Linear Bottlenecks

Why MobileNetV2?

Lightweight - Perfect for real-time inference
Fast - Minimal latency on CPU-only hardware
Accurate - Solid ImageNet performance
Portable - Easy deployment on any platform
Proven - Battle-tested across millions of devices


📋 Requirements

tensorflow>=2.10.0
flask>=2.2.0
keras>=2.10.0
pillow>=9.0.0
numpy>=1.22.0
python-dotenv>=0.20.0
gunicorn>=20.1.0

For complete requirements, see requirements.txt


🤝 Contributing

Contributions are welcome and greatly appreciated! Here's how you can help:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Areas for Contribution

  • 🎨 UI/UX improvements
  • 📈 Model accuracy enhancements
  • 📚 Documentation improvements
  • 🧪 Test coverage expansion
  • 🐛 Bug fixes and optimizations

📜 License

This project is licensed under the MIT License - see the LICENSE file for details.

MIT License summary:

  • ✅ Commercial use
  • ✅ Modification
  • ✅ Distribution
  • ✅ Private use
  • ⚠️ Liability limitation
  • ⚠️ Warranty disclaimer

📞 Support & Contact


Made with ❤️ by Abdul Rasak V

⭐ If you found this project helpful, please consider giving it a star!

Star on GitHubReport IssueSuggest Feature

About

Deep learning image classifier with Flask web UI — supports custom model training and real-time predictions

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages