Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
#
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
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
|