File size: 5,719 Bytes
fbd6723
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
# 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](https://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
```bash
# 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!
```bash
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

```bash
# 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)

```bash
docker-compose up --build
```

Services:
- Frontend: http://localhost:3000
- Backend: http://localhost:8000
- Docs: http://localhost:8000/swagger

---

## Option C: Run Locally Without Docker

### Backend Setup

```bash
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)

```bash
cd frontend

# Install dependencies
npm install

# Start development server
npm start
```

Frontend runs on **http://localhost:3000**

---

## Testing Your Deployment

### 1. Check Health
```bash
curl http://localhost:7860/health/
# Expected: {"status": "healthy", "service": "Intel Image Classifier API", "version": "1.0.0"}
```

### 2. Classify an Image
```bash
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
- Swagger: **http://localhost:7860/swagger/**
- ReDoc: **http://localhost:7860/redoc/**
- Admin Panel: **http://localhost:7860/admin/** (user: admin, pass: admin)

---

## Troubleshooting

### "Port 7860 already in use"
```bash
# 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`:
```python
CONFIDENCE_THRESHOLD = 0.6  # Change this value
```

### Add Custom Classes
Update `CLASSES` list in `backend/api/notifications/api_views.py`:
```python
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](DEPLOYMENT.md)
2. **Issues**: [GitHub Issues](https://github.com/danielle2035/Intel_classification/issues)
3. **Discussions**: [HF Space Discussions](https://huggingface.co/spaces/danielle2035/Intel_classification/discussions)

---

**Ready?** Let's go! πŸš€

Choose your deployment method above and follow the steps!