DHEIVER commited on
Commit
083470e
·
1 Parent(s): 5f5e761

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -7
app.py CHANGED
@@ -2,6 +2,7 @@ import tensorflow as tf
2
  import efficientnet.tfkeras as efn
3
  import numpy as np
4
  import gradio as gr
 
5
 
6
  # Dimensões da imagem
7
  IMG_HEIGHT = 224
@@ -55,18 +56,19 @@ def predict_image(input_image):
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
 
2
  import efficientnet.tfkeras as efn
3
  import numpy as np
4
  import gradio as gr
5
+ import plotly.express as px
6
 
7
  # Dimensões da imagem
8
  IMG_HEIGHT = 224
 
56
  predicted_class = class_names[np.argmax(prediction)]
57
  probability = prediction[0][np.argmax(prediction)]
58
 
59
+ # Retorna a previsão em formato de string
60
+ return f"""
61
+ Predicted Class: {predicted_class}
62
+ Probability: {probability:.2%}
63
+ """
 
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.Output(label="Prediction", type="string"),
70
+ interpretation="text",
71
+ custom_interpretation_fn=predict_image
72
  )
73
 
74
  # Execute a interface Gradio