Spaces:
Sleeping
Sleeping
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -38,7 +38,8 @@ def load_model():
|
|
| 38 |
classifier = pipeline(
|
| 39 |
"image-classification",
|
| 40 |
model=MODEL_ID,
|
| 41 |
-
device=-1 # Use CPU (change to 0 for GPU)
|
|
|
|
| 42 |
)
|
| 43 |
model_loaded = True
|
| 44 |
logger.info("Model loaded successfully!")
|
|
@@ -179,17 +180,6 @@ def create_interface():
|
|
| 179 |
height=300
|
| 180 |
)
|
| 181 |
|
| 182 |
-
# Example images
|
| 183 |
-
gr.Markdown("### 📸 Example Images")
|
| 184 |
-
gr.Examples(
|
| 185 |
-
examples=[
|
| 186 |
-
["food_recognition_model/data/processed/val/apple_pie/apple_pie_000.jpg"],
|
| 187 |
-
["food_recognition_model/data/processed/val/pizza/pizza_000.jpg"],
|
| 188 |
-
["food_recognition_model/data/processed/val/hamburger/hamburger_000.jpg"],
|
| 189 |
-
],
|
| 190 |
-
inputs=image_input,
|
| 191 |
-
label="Click on an example to test"
|
| 192 |
-
)
|
| 193 |
|
| 194 |
# Event handlers
|
| 195 |
predict_btn.click(
|
|
|
|
| 38 |
classifier = pipeline(
|
| 39 |
"image-classification",
|
| 40 |
model=MODEL_ID,
|
| 41 |
+
device=-1, # Use CPU (change to 0 for GPU)
|
| 42 |
+
use_fast=True # Use fast image processor
|
| 43 |
)
|
| 44 |
model_loaded = True
|
| 45 |
logger.info("Model loaded successfully!")
|
|
|
|
| 180 |
height=300
|
| 181 |
)
|
| 182 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 183 |
|
| 184 |
# Event handlers
|
| 185 |
predict_btn.click(
|