chimithecat commited on
Commit
7a7add4
·
verified ·
1 Parent(s): ceaacb0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -1,3 +1,5 @@
 
 
1
  import gradio as gr
2
  from transformers import pipeline
3
  from PIL import Image
@@ -12,7 +14,6 @@ def classify(image):
12
  # The model returns a list of dictionaries, e.g., [{'label': '...', 'score': ...}]
13
  predictions = model(image)
14
 
15
- # --- THE FIX IS HERE ---
16
  # Convert the list of dicts into a single dict that gr.Label expects:
17
  # {'label_string': score_float, ...}
18
  confidences = {p['label']: p['score'] for p in predictions}
@@ -23,8 +24,8 @@ def classify(image):
23
  app = gr.Interface(
24
  fn=classify,
25
  inputs=gr.Image(type="pil"),
26
- # gr.Label() can now correctly process the new output format
27
  outputs=gr.Label(),
 
28
  title="Tomato Leaf Disease Analyzer",
29
  description="Upload a tomato leaf image to detect the disease."
30
  )
 
1
+ // Filename: app.py (di Hugging Face Space)
2
+
3
  import gradio as gr
4
  from transformers import pipeline
5
  from PIL import Image
 
14
  # The model returns a list of dictionaries, e.g., [{'label': '...', 'score': ...}]
15
  predictions = model(image)
16
 
 
17
  # Convert the list of dicts into a single dict that gr.Label expects:
18
  # {'label_string': score_float, ...}
19
  confidences = {p['label']: p['score'] for p in predictions}
 
24
  app = gr.Interface(
25
  fn=classify,
26
  inputs=gr.Image(type="pil"),
 
27
  outputs=gr.Label(),
28
+ api_name="predict", # <-- INI ADALAH PERBAIKAN PENTING
29
  title="Tomato Leaf Disease Analyzer",
30
  description="Upload a tomato leaf image to detect the disease."
31
  )