Doja2002 commited on
Commit
72485ae
·
verified ·
1 Parent(s): 6a0166d

Updated app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -7
app.py CHANGED
@@ -1,7 +1,5 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
- import requests
4
- from PIL import Image
5
 
6
  # Use a specific image classification model from Hugging Face
7
  MODEL_ID = "nateraw/food"
@@ -24,17 +22,13 @@ def predict(img):
24
  # Format the output as a dictionary for Gradio's Label component
25
  return {r["label"]: float(r["score"]) for r in out}
26
 
27
- # Create the Gradio interface
28
  iface = gr.Interface(
29
  fn=predict,
30
  inputs=gr.Image(type="pil", label="Upload image"),
31
  outputs=gr.Label(num_top_classes=3),
32
  title="Image Classifier",
33
  description="Upload an image to see its top 3 predicted classifications.",
34
- examples=[
35
- "https://huggingface.co/datasets/nateraw/food/resolve/main/001.jpg",
36
- "https://huggingface.co/datasets/nateraw/food/resolve/main/002.jpg",
37
- ]
38
  )
39
 
40
  # Launch the interface
 
1
  import gradio as gr
2
  from transformers import pipeline
 
 
3
 
4
  # Use a specific image classification model from Hugging Face
5
  MODEL_ID = "nateraw/food"
 
22
  # Format the output as a dictionary for Gradio's Label component
23
  return {r["label"]: float(r["score"]) for r in out}
24
 
25
+ # Create the Gradio interface without examples
26
  iface = gr.Interface(
27
  fn=predict,
28
  inputs=gr.Image(type="pil", label="Upload image"),
29
  outputs=gr.Label(num_top_classes=3),
30
  title="Image Classifier",
31
  description="Upload an image to see its top 3 predicted classifications.",
 
 
 
 
32
  )
33
 
34
  # Launch the interface