YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
CNN Image Classifier - CIFAR-10
A modern Flask web application for image classification using a trained CIFAR-10 Convolutional Neural Network model.
Features
- Real CIFAR-10 Model: Uses a trained CNN model for accurate image classification
- OpenCV Integration: Optimized image processing with OpenCV for better performance
- 10 Object Classes: Classifies images into airplane, automobile, bird, cat, deer, dog, frog, horse, ship, and truck
- Image Preview: Real-time preview of uploaded images
- Confidence Scores: Shows prediction confidence with visual progress bars
Quickstart
- Create and activate a virtual environment (Windows PowerShell):
python -m venv .venv
.venv\Scripts\Activate.ps1
- Install dependencies:
pip install -r requirements.txt
- Run the app:
python app.py
- Open in browser:
http://localhost:5000
Project Structure
CNN-Image-Classifier/
βββ app.py # Main application entry point
βββ app/
β βββ __init__.py # Flask app factory
β βββ model.py # CIFAR-10 model implementation
β βββ routes.py # Flask routes and handlers
βββ models/
β βββ model_cifar10.h5 # Trained CIFAR-10 model
βββ templates/
β βββ index.html # Upload page with modern UI
β βββ result.html # Results page with predictions
βββ static/
β βββ css/
β βββ style.css # Custom styles (legacy)
βββ uploads/ # Temporary file storage
βββ requirements.txt # Python dependencies
βββ .gitignore # Git ignore rules
βββ README.md # This file
Dependencies
- Flask 3.0.3: Web framework
- TensorFlow 2.15.0: Deep learning framework for model loading
- OpenCV 4.8.1.78: Computer vision library for image processing
- NumPy 2.1.2: Numerical computing
- Pillow 10.4.0: Image processing
- Werkzeug 3.0.3: WSGI utilities
Model Information
The application uses a pre-trained CIFAR-10 CNN model that can classify images into 10 categories:
- Airplane: Aircraft and flying vehicles
- Automobile: Cars and road vehicles
- Bird: Various bird species
- Cat: Domestic and wild cats
- Deer: Deer and similar animals
- Dog: Dogs and canines
- Frog: Frogs and amphibians
- Horse: Horses and equines
- Ship: Boats and watercraft
- Truck: Trucks and large vehicles
Technical Details
Image Processing Pipeline
- Upload: User uploads image through web interface
- Preprocessing: OpenCV processes image (resize to 32x32, normalize to [0,1])
- Prediction: CIFAR-10 model predicts class and confidence
- Results: Beautiful results page displays prediction with confidence score
Performance Optimizations
- OpenCV Processing: Faster image operations compared to PIL
- Model Caching: Model loaded once and cached for subsequent requests
- Stream Processing: Direct file stream processing without temporary files
- Responsive Design: Optimized for all device sizes
Usage
- Upload Image: Click the upload area or drag & drop an image
- Preview: See a preview of your uploaded image
- Predict: Click "Prediksi Gambar" to classify the image
- View Results: See the prediction with confidence score and class information
Configuration
- Max Upload Size: 10 MB (configurable in
app/__init__.py) - Supported Formats: PNG, JPG, JPEG
- Model Path:
models/model_cifar10.h5 - Image Size: Automatically resized to 32x32 pixels for CIFAR-10
Development
Adding New Models
To use a different model:
- Replace
models/model_cifar10.h5with your trained model - Update class names in
app/model.py - Adjust image preprocessing if needed
- Update the UI to reflect new classes
Customizing the UI
The application uses Tailwind CSS for styling. Key files:
templates/index.html: Upload interfacetemplates/result.html: Results display- Custom CSS in template
<style>sections
Notes
- Uploaded files are temporarily stored in
uploads/directory - Model files are stored in
models/directory for better organization - The application uses Indonesian language for user interface
- All error messages are localized to Indonesian
- Professional design without emojis for business use
License
This project is for educational purposes. Please ensure you have proper licensing for any models or datasets used.
Inference Providers NEW
This model isn't deployed by any Inference Provider. π Ask for provider support