DHEIVER commited on
Commit
5f5e761
·
1 Parent(s): 9b041f8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -16
app.py CHANGED
@@ -55,28 +55,18 @@ def predict_image(input_image):
55
  predicted_class = class_names[np.argmax(prediction)]
56
  probability = prediction[0][np.argmax(prediction)]
57
 
58
- # Altere a interpretação dos resultados para uma tabela HTML
59
- formatted_text = f"""
60
- <table>
61
- <tr>
62
- <th>Predicted Class</th>
63
- <th>Probability</th>
64
- </tr>
65
- <tr>
66
- <td>{predicted_class}</td>
67
- <td>{probability:.2%}</td>
68
- </tr>
69
- </table>
70
- """
71
  return formatted_text
72
 
73
  # Crie uma interface Gradio para fazer previsões
74
  iface = gr.Interface(
75
  fn=predict_image,
76
  inputs=gr.inputs.Image(label="Upload an Image", type="pil"),
77
- outputs=gr.outputs.Textbox(label="Prediction", type="text"),
78
- interpretation="html",
79
- custom_interpretation_fn=lambda prediction: formatted_text
80
  )
81
 
82
  # Execute a interface Gradio
 
55
  predicted_class = class_names[np.argmax(prediction)]
56
  probability = prediction[0][np.argmax(prediction)]
57
 
58
+ # Formate os resultados da previsão para exibição usando o componente BarPlot
59
+ bar_plot_values = [probability, 1 - probability]
60
+ bar_plot_labels = ["Normal", "Cataract"]
61
+
62
+ formatted_text = gr.Plot(values=bar_plot_values, labels=bar_plot_labels, type="bar").render()
 
 
 
 
 
 
 
 
63
  return formatted_text
64
 
65
  # Crie uma interface Gradio para fazer previsões
66
  iface = gr.Interface(
67
  fn=predict_image,
68
  inputs=gr.inputs.Image(label="Upload an Image", type="pil"),
69
+ outputs=gr.outputs.Textbox(label="Prediction", type="text")
 
 
70
  )
71
 
72
  # Execute a interface Gradio