Skip to content

Image-Classification-model is a Streamlit app that integrates MobileNetV2 and a CIFAR-10 model for image classification. Users can upload images and receive predictions with confidence scores from either model. It features a sleek navigation bar for easy switching and real-time results, ideal for both learning and practical use.

Notifications You must be signed in to change notification settings

vivek-kumar-P/Image-Classification-model

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ€– Image Classification Model

This is a Streamlit web app that integrates MobileNetV2 and a CIFAR-10 model for image classification. Users can upload images and receive predictions with confidence scores from either model. It features a sleek navigation bar for easy switching and real-time results, which is ideal for learning and practical use.

🌐 Live App: Streamlit Cloud Deployment (See deployment section) image

🎯 Key Features

  • Dual Model Support:

    • MobileNetV2 (ImageNet): Recognizes 1,000+ different classes - animals, vehicles, objects, etc.
    • Custom CIFAR-10 Model: Classifies into 10 specific categories - airplane, automobile, bird, cat, deer, dog, frog, horse, ship, truck.
  • Intuitive Interface:

    • Navigation Bar: Seamlessly switch between models using sidebar menu
    • Real-Time Classification: Upload images and get instant predictions with confidence scores
    • Beautiful UI: Progress bars, formatted results, responsive design
  • Educational & Practical:

    • Learn about deep learning models and their performance
    • Practical image classification for real-world applications
    • Fully open-source and customizable

πŸ“‹ Prerequisites

  • Python 3.10+ (Recommended: 3.11 for best compatibility)
  • Git (for version control)
  • Web Browser (Chrome, Firefox, Safari, Edge)
  • ~2GB disk space (for dependencies and models)

πŸš€ Installation & Setup

Quick Start (Local Development)

  1. Clone the repository:

    git clone https://github.com/vivek-kumar-P/Image-Classification-model
    cd Image-Classification-model
  2. Create virtual environment (Python 3.11 recommended):

    python -m venv venv
    
    # On Windows:
    venv\Scripts\activate
    
    # On macOS/Linux:
    source venv/bin/activate
  3. Install dependencies:

    pip install --upgrade pip
    pip install -r requirements.txt
  4. Run the app:

    streamlit run app.py
  5. Access the app: Opens automatically at http://localhost:8501

Windows Installation (Step-by-Step)

# Navigate to project
cd "e:\code better\Image-Classification-model"

# Activate venv
.\venv\Scripts\Activate.ps1

# Install requirements
pip install -r requirements.txt

# Run app
streamlit run app.py

Usage

  1. Select a Model:

    • Use the sidebar to choose between MobileNetV2 or CIFAR-10
  2. Upload an Image:

    • Click "Choose an image..." and select JPG/PNG file
    • Supported formats: JPEG, PNG, JPG
    • Max file size: 200MB
  3. View Predictions:

    • Real-time classification results
    • Top predictions with confidence scores
    • Progress bars showing confidence levels

πŸ› Known Issues & Solutions

Issue 1: TensorFlow Installation Error

Error: ERROR: Could not find a version that satisfies the requirement tensorflow

Cause: TensorFlow 2.15+ requires Python 3.10-3.13. Python 3.14+ not yet supported.

Solution:

# Check Python version
python --version

# If Python 3.14+, use Python 3.11 instead
# Create new venv with Python 3.11
python3.11 -m venv venv
venv\Scripts\activate
pip install -r requirements.txt

Issue 2: Missing Visual C++ Redistributable

Error: OSError: [WinError 126] The specified module could not be found

Cause: TensorFlow needs Microsoft Visual C++ runtime libraries.

Solution:

1. Download: https://aka.ms/vs/17/release/vc_redist.x64.exe
2. Run the installer (admin mode)
3. Restart your terminal/IDE
4. Reinstall TensorFlow: pip install tensorflow

Issue 3: Port Already in Use

Error: Port 8501 is already in use

Cause: Another Streamlit app is running on the same port.

Solution:

# Use a different port
streamlit run app.py --server.port 8502

# Or kill existing process (Windows):
netstat -ano | findstr :8501
taskkill /PID <PID> /F

Issue 4: Dependencies Conflict

Error: error: subprocess-exited-with-error with numpy version conflict

Cause: Incompatible version pinning in requirements.txt

Solution:

# Clear pip cache
pip cache purge

# Upgrade pip
pip install --upgrade pip

# Reinstall with fresh environment
pip install -r requirements.txt --no-cache-dir

Issue 5: Streamlit Cloud Deployment Error

Error: TensorFlow installation fails on Streamlit Cloud

Cause: Streamlit Cloud trying to install with wrong Python version

Solution:

1. Delete the app from Streamlit Cloud
2. Redeploy and select Python 3.11 in Advanced Settings
3. Click Deploy

🌐 Streamlit Cloud Deployment

Deploy Your App (Live on Web)

  1. Push code to GitHub:

    git add .
    git commit -m "Your message"
    git push origin main
  2. Go to Streamlit Cloud:

  3. Deploy New App:

    • Click "New app"
    • Select repository: vivek-kumar-P/Image-Classification-model
    • Branch: main
    • Main file: app.py
  4. Configure Python Version (IMPORTANT):

    • Click "Advanced settings"
    • Select Python 3.11 from dropdown
    • Click "Deploy"
  5. Wait for deployment (2-3 minutes):

    • App will be live at: https://your-username-image-classification.streamlit.app

Troubleshooting Deployment

Build fails with TensorFlow error?

  • Delete app β†’ Redeploy with Python 3.11 selected

Port/Process errors?

  • Streamlit Cloud handles this automatically, just redeploy

Dependencies not installing?

  • Update requirements.txt with compatible versions
  • Commit β†’ Push β†’ Redeploy

πŸ“Š System Architecture

Local Development:

Your Computer
β”œβ”€ Python 3.11
β”œβ”€ Virtual Environment
β”œβ”€ Dependencies (from requirements.txt)
β”œβ”€ App code (app.py)
β”œβ”€ Models (cifar10_model.h5)
└─ Runs on localhost:8501

Streamlit Cloud:

Streamlit's Servers
β”œβ”€ Python 3.11 (selected during deploy)
β”œβ”€ Virtual Environment (auto-created)
β”œβ”€ Dependencies (installed from requirements.txt)
β”œβ”€ Your code (cloned from GitHub)
└─ Runs 24/7 at streamlit.app URL

Key Point: Cloud app is independent from local setup! Deleting local files won't affect the live app.


πŸ“¦ Project Structure

Image-Classification-model/
β”œβ”€β”€ app.py                      # Main Streamlit application
β”œβ”€β”€ train.py                    # Model training script
β”œβ”€β”€ cifar10_model.h5           # Pre-trained CIFAR-10 model
β”œβ”€β”€ requirements.txt           # Python dependencies
β”œβ”€β”€ README.md                  # Documentation (this file)
β”œβ”€β”€ .streamlit/
β”‚   └── config.toml            # Streamlit Cloud config
└── Testing Images/
    β”œβ”€β”€ CIFAR-10/              # Test images
    └── MobileNetV2/           # Test images

πŸ“ Recent Updates (January 28, 2026)

Changes Made:

βœ… Fixed dependency conflicts in requirements.txt βœ… Added flexible version constraints instead of strict pinning βœ… Added .streamlit/config.toml for Cloud deployment βœ… Updated app.py with better error handling βœ… Tested on Python 3.11 with TensorFlow 2.15.0 βœ… Verified Streamlit Cloud deployment

Problems Tackled:

  1. TensorFlow not available for Python 3.14 β†’ Switched to Python 3.11
  2. Dependency version conflicts β†’ Updated requirements.txt with compatible versions
  3. Missing Visual C++ libraries β†’ Provided download and install instructions
  4. Port conflicts on local β†’ Added port configuration examples
  5. Streamlit Cloud deployment failures β†’ Added Python version selection guide

πŸ”§ Troubleshooting Checklist

Problem Command Status
Wrong Python version python --version Check output
venv not activating venv\Scripts\activate.ps1 PowerShell
Dependencies failing pip install --upgrade pip Then reinstall
App not starting streamlit run app.py --logger.level=error Debug mode
Port in use streamlit run app.py --server.port 8502 Alt port
TensorFlow error Use Python 3.11 Fallback version

πŸ“š Model Information

MobileNetV2 (ImageNet)

  • Classes: 1,000+
  • Input: 224Γ—224 RGB images
  • Performance: Fast, mobile-friendly
  • Use case: General object detection

CIFAR-10

  • Classes: 10 (airplane, car, bird, cat, deer, dog, frog, horse, ship, truck)
  • Input: 32Γ—32 RGB images
  • Performance: Specialized classification
  • Use case: Specific object detection in 10 categories

πŸš€ Future Enhancements

  • Add image download with predictions
  • Add batch image processing
  • Deploy custom model training interface
  • Add prediction history
  • Mobile app version
  • Real-time webcam classification

πŸ“„ License

This project is open-source and available for educational and commercial use.


πŸ‘₯ Contributing

Feel free to:

  • Fork the repository
  • Create issues for bugs/features
  • Submit pull requests
  • Share feedback and improvements

πŸ™ Acknowledgments

  • Streamlit - Web app framework
  • TensorFlow - Deep learning library
  • Keras - Neural network API
  • MobileNetV2 - Pre-trained model
  • CIFAR-10 Dataset - Training data

πŸ“ž Support & Contact

For issues or questions:

  1. Check the Troubleshooting section above
  2. Review Known Issues & Solutions
  3. Open an issue on GitHub
  4. Contact the maintainer

Last Updated: January 28, 2026 Status: βœ… Production Ready for Streamlit Cloud

About

Image-Classification-model is a Streamlit app that integrates MobileNetV2 and a CIFAR-10 model for image classification. Users can upload images and receive predictions with confidence scores from either model. It features a sleek navigation bar for easy switching and real-time results, ideal for both learning and practical use.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages