Spaces:
Sleeping
Sleeping
Intel Image Classifier - Deployment Guide
Overview
This application is a full-stack web classifier for natural scene images using two CNN models:
- PyTorch Model: Custom CNN architecture
- TensorFlow Model: Custom CNN architecture
The application combines:
- Backend: Django REST API
- Frontend: React with Material-UI
- Models: Two Deep Learning models for image classification
Quick Start for Hugging Face Spaces
Prerequisites
- Git
- Docker & Docker Compose (for local development)
- Or access to Hugging Face Spaces
Option 1: Deploy to Hugging Face Spaces (Recommended)
Fork/Clone the Repository
git clone https://github.com/danielle2035/Intel_classification.git cd Intel_classificationAdd Your Trained Models
Place your trained model files in the
backend/api/models/directory:backend/api/models/ ├── pytorch_model.pth (PyTorch model) └── model_best.keras (TensorFlow model)Push to Hugging Face
# Add HF as remote git remote add hf https://huggingface.co/spaces/YOUR_USERNAME/Intel_classification # Push to deploy git push hf mainAccess Your App
- Go to:
https://huggingface.co/spaces/YOUR_USERNAME/Intel_classification - The app will build and deploy automatically!
- Go to:
Option 2: Build and Run Locally
With Docker Compose (Separate Services)
docker-compose up --build
Services will be available at:
- Frontend:
http://localhost:3000 - Backend API:
http://localhost:8000 - API Docs:
http://localhost:8000/swagger
With Docker (Unified Container - HF Mode)
docker build -t intel-classifier .
docker run -p 7860:7860 intel-classifier
Access at: http://localhost:7860
Without Docker (Development)
Backend Setup
cd backend/api python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate pip install -r ../requirements.txt python manage.py migrate python manage.py runserver 0.0.0.0:8000Frontend Setup (separate terminal)
cd frontend npm install npm startAccess
- Frontend:
http://localhost:3000 - Backend API:
http://localhost:8000
- Frontend:
API Endpoints
Classification
POST /api/classify/
Classify an image using either PyTorch or TensorFlow model.
Response:
{
"class": "mountain",
"confidence": 0.95,
"model_used": "pytorch",
"probabilities": {
"buildings": 0.02,
"forest": 0.01,
"glacier": 0.01,
"mountain": 0.95,
"sea": 0.01,
"street": 0.00
}
}
Models & Classes
Supported Classes
- buildings / Bâtiments / Kër yi
- forest / Forêt / Géej bu wees
- glacier / Glacier / Dëkk bu sedd
- mountain / Montagne / Tund bi
- sea / Mer / Géej bi
- street / Rue / Yoon bi
Deployment Checklist
- Add trained models to
backend/api/models/ - Update
ALLOWED_HOSTSin settings if needed - Test locally with Docker
- Push to Hugging Face Spaces
- Test on HF Space URL
Troubleshooting
Port Already in Use
lsof -i :7860 # Find process
kill -9 <PID> # Kill it
Models Not Loading
- Ensure files are in
backend/api/models/ - Check file names:
pytorch_model.pth,model_best.keras
CORS Errors
- Verify backend and frontend are accessible
- Check Django CSRF_TRUSTED_ORIGINS includes your HF URL
Performance Tips
- Resize images before upload (< 10MB)
- PyTorch is generally faster on CPU
- Adjust confidence threshold in
api_views.pyif needed