DHEIVER commited on
Commit
c5f5082
·
1 Parent(s): a135d91

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -1
app.py CHANGED
@@ -11,8 +11,11 @@ classifier = VisionClassifierInference(
11
 
12
  # Define a Gradio interface
13
  def classify_image(image_file):
 
14
  label = classifier.predict(img_path=image_file.name)
15
- return f"Predicted class: {label}"
 
 
16
 
17
  iface = gr.Interface(
18
  fn=classify_image,
 
11
 
12
  # Define a Gradio interface
13
  def classify_image(image_file):
14
+ """Classify an image using a pre-trained ViT model."""
15
  label = classifier.predict(img_path=image_file.name)
16
+ # Add a confidence score to the output
17
+ confidence = classifier.predict_proba(img_path=image_file.name)[0][label]
18
+ return f"Predicted class: {label} (confidence: {confidence:.2f})"
19
 
20
  iface = gr.Interface(
21
  fn=classify_image,