YonaniCodes commited on
Commit
40848b2
·
1 Parent(s): cbbdcf1
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -39,16 +39,15 @@ def predict_breed(image):
39
  return "❌ This model only supports Maize and Tomato leaf images.", {}
40
 
41
  output_lines = ["🌿 **Top 3 Predictions:**"]
42
- bar_data = {"labels": [], "values": []}
43
 
44
  for i in top3_indices:
45
  class_name = labels[i].replace('_', ' ').upper()
46
  confidence = predictions[i] * 100
47
  output_lines.append(f"{class_name}: {confidence:.2f}%")
48
- bar_data["labels"].append(class_name)
49
- bar_data["values"].append(confidence)
50
 
51
- return "\n".join(output_lines), bar_data
52
 
53
  except Exception as e:
54
  print("Prediction Error:", e)
@@ -57,7 +56,7 @@ def predict_breed(image):
57
  interface = gr.Interface(
58
  fn=predict_breed,
59
  inputs=gr.Image(type="pil", label="Upload Maize or Tomato Leaf Image"),
60
- outputs=[gr.Text(label="Prediction"), gr.Bar(label="Confidence Scores")],
61
  title="🌿 Hares: Maize & Tomato Disease Classifier",
62
  description="Upload an image of a maize or tomato leaf to identify possible diseases.",
63
  )
 
39
  return "❌ This model only supports Maize and Tomato leaf images.", {}
40
 
41
  output_lines = ["🌿 **Top 3 Predictions:**"]
42
+ confidence_scores = {}
43
 
44
  for i in top3_indices:
45
  class_name = labels[i].replace('_', ' ').upper()
46
  confidence = predictions[i] * 100
47
  output_lines.append(f"{class_name}: {confidence:.2f}%")
48
+ confidence_scores[class_name] = float(f"{confidence:.2f}")
 
49
 
50
+ return "\n".join(output_lines), confidence_scores
51
 
52
  except Exception as e:
53
  print("Prediction Error:", e)
 
56
  interface = gr.Interface(
57
  fn=predict_breed,
58
  inputs=gr.Image(type="pil", label="Upload Maize or Tomato Leaf Image"),
59
+ outputs=[gr.Text(label="Prediction"), gr.Label(label="Confidence Scores")],
60
  title="🌿 Hares: Maize & Tomato Disease Classifier",
61
  description="Upload an image of a maize or tomato leaf to identify possible diseases.",
62
  )