# 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) 1. **Fork/Clone the Repository** ```bash git clone https://github.com/danielle2035/Intel_classification.git cd Intel_classification ``` 2. **Add 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) ``` 3. **Push to Hugging Face** ```bash # Add HF as remote git remote add hf https://huggingface.co/spaces/YOUR_USERNAME/Intel_classification # Push to deploy git push hf main ``` 4. **Access Your App** - Go to: `https://huggingface.co/spaces/YOUR_USERNAME/Intel_classification` - The app will build and deploy automatically! ### Option 2: Build and Run Locally #### With Docker Compose (Separate Services) ```bash 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) ```bash docker build -t intel-classifier . docker run -p 7860:7860 intel-classifier ``` Access at: `http://localhost:7860` #### Without Docker (Development) 1. **Backend Setup** ```bash 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:8000 ``` 2. **Frontend Setup (separate terminal)** ```bash cd frontend npm install npm start ``` 3. **Access** - Frontend: `http://localhost:3000` - Backend API: `http://localhost:8000` ## API Endpoints ### Classification **POST** `/api/classify/` Classify an image using either PyTorch or TensorFlow model. **Response:** ```json { "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_HOSTS` in settings if needed - [ ] Test locally with Docker - [ ] Push to Hugging Face Spaces - [ ] Test on HF Space URL ## Troubleshooting **Port Already in Use** ```bash lsof -i :7860 # Find process kill -9 # 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 1. Resize images before upload (< 10MB) 2. PyTorch is generally faster on CPU 3. Adjust confidence threshold in `api_views.py` if needed