Intel_classification / QUICK_START.md
danielle2035's picture
Add
fbd6723
|
Raw
History Blame Contribute Delete
5.72 kB

Quick Start Guide - Intel Image Classifier

Get up and running in minutes!

Prereq: Install Models

Before deploying, you need your trained models. Place them in:

backend/api/models/
β”œβ”€β”€ pytorch_model.pth      # PyTorch model weights
└── model_best.keras       # TensorFlow/Keras model

Note: If you don't have these files yet, see /ml/ directory for training scripts.


Option A: Deploy to Hugging Face (Recommended ⭐)

Step 1: Create Space on Hugging Face

  1. Go to huggingface.co/spaces
  2. Click "Create new Space"
  3. Choose:
    • Name: Intel_classification
    • License: MIT
    • Space SDK: Docker
    • Visibility: Public

Step 2: Clone and Update Repository

# Clone this repo
git clone https://github.com/danielle2035/Intel_classification.git
cd Intel_classification

# Add your trained models to backend/api/models/
cp /path/to/pytorch_model.pth backend/api/models/
cp /path/to/model_best.keras backend/api/models/

# Add Hugging Face remote
git remote add hf https://huggingface.co/spaces/YOUR_HF_USERNAME/Intel_classification

Step 3: Deploy!

git push hf main

Done! Watch your Space build and deploy automatically. Access it at:

https://huggingface.co/spaces/YOUR_HF_USERNAME/Intel_classification

Option B: Run Locally with Docker

Easiest Way

# Build the image
docker build -t intel-classifier .

# Run it
docker run -p 7860:7860 intel-classifier

Then open: http://localhost:7860

With Docker Compose (Development)

docker-compose up --build

Services:


Option C: Run Locally Without Docker

Backend Setup

cd backend/api

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

# Install dependencies
pip install -r ../requirements.txt

# Run migrations
python manage.py migrate

# Start server
python manage.py runserver 8000

Keep terminal open. Backend runs on http://localhost:8000

Frontend Setup (New Terminal)

cd frontend

# Install dependencies
npm install

# Start development server
npm start

Frontend runs on http://localhost:3000


Testing Your Deployment

1. Check Health

curl http://localhost:7860/health/
# Expected: {"status": "healthy", "service": "Intel Image Classifier API", "version": "1.0.0"}

2. Classify an Image

curl -X POST \
  -F "image=@test_image.jpg" \
  -F "model=pytorch" \
  http://localhost:7860/api/classify/

3. Visit Web Interface

Open in browser: http://localhost:7860

4. Check API Docs


Troubleshooting

"Port 7860 already in use"

# Find what's using it
lsof -i :7860

# Kill the process
kill -9 <PID>

"Models not found"

Ensure these files exist:

  • backend/api/models/pytorch_model.pth
  • backend/api/models/model_best.keras

If missing, only one model will be available.

"CORS Error"

This usually means backend and frontend are on different domains. Verify:

  • Docker mode: Both on same domain βœ…
  • Local dev: Frontend 3000, Backend 8000 - they communicate via proxy βœ…
  • HF Spaces: Auto-configured βœ…

"Models take too long to load"

First startup loads models into memory. This can take 1-2 minutes for large models. Subsequent requests are fast!


Common Tasks

Change Confidence Threshold

Edit backend/api/notifications/api_views.py:

CONFIDENCE_THRESHOLD = 0.6  # Change this value

Add Custom Classes

Update CLASSES list in backend/api/notifications/api_views.py:

CLASSES = ["buildings", "forest", "glacier", "mountain", "sea", "street", "YOUR_CLASS"]

Then retrain your models.

Use a Different Model

Add to backend/api/models/:

  • pytorch_model.pth
  • model_best.keras

The API automatically detects available models.


File Structure Reference

intel-classifier/
β”œβ”€β”€ Dockerfile                    # Docker configuration
β”œβ”€β”€ README.md                     # Main documentation
β”œβ”€β”€ DEPLOYMENT.md                # Detailed deployment guide
β”œβ”€β”€ REORGANIZATION.md            # What changed
β”œβ”€β”€ QUICK_START.md              # This file!
β”‚
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ api/notifications/       # Image classification API
β”‚   β”‚   └── api_views.py
β”‚   β”œβ”€β”€ models/                  # Your trained models
β”‚   β”‚   β”œβ”€β”€ pytorch_model.pth
β”‚   β”‚   └── model_best.keras
β”‚   └── requirements.txt
β”‚
β”œβ”€β”€ frontend/                    # React web interface
β”‚   β”œβ”€β”€ src/App.js
β”‚   └── package.json
β”‚
└── ml/                         # Training scripts (for reference)
    └── models/

Next Steps

  1. βœ… Add your trained models
  2. βœ… Test locally (Docker or native)
  3. βœ… Push to Hugging Face Spaces
  4. βœ… Share with friends!
  5. πŸ“Š Monitor predictions at /admin/
  6. πŸ”„ Retrain to improve accuracy
  7. πŸš€ Add more features (authentication, history, etc.)

Support

Need help?

  1. Documentation: See DEPLOYMENT.md
  2. Issues: GitHub Issues
  3. Discussions: HF Space Discussions

Ready? Let's go! πŸš€

Choose your deployment method above and follow the steps!