Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,17 +1,13 @@
|
|
1 |
import gradio as gr
|
2 |
import torch
|
3 |
-
from transformers import
|
4 |
|
5 |
model_id = "SABR22/food_models"
|
6 |
-
|
7 |
-
model = AutoModelForImageClassification.from_pretrained(model_id)
|
8 |
|
9 |
def classify_food(image):
|
10 |
-
|
11 |
-
|
12 |
-
logits = outputs.logits
|
13 |
-
predicted_class_idx = logits.argmax(-1).item()
|
14 |
-
return model.config.id2label[predicted_class_idx]
|
15 |
|
16 |
interface = gr.Interface(
|
17 |
fn=classify_food,
|
|
|
1 |
import gradio as gr
|
2 |
import torch
|
3 |
+
from transformers import pipeline
|
4 |
|
5 |
model_id = "SABR22/food_models"
|
6 |
+
pipe = pipeline("image-classification", model="SABR22/food_models")
|
|
|
7 |
|
8 |
def classify_food(image):
|
9 |
+
image = pipe(image)
|
10 |
+
return image[0]['label']
|
|
|
|
|
|
|
11 |
|
12 |
interface = gr.Interface(
|
13 |
fn=classify_food,
|