Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -43,32 +43,20 @@ def classify_image(input_image):
|
|
43 |
class_labels = ["Normal", "Cataract"] # Substitua pelas suas etiquetas de classe reais
|
44 |
predicted_class = class_labels[class_index]
|
45 |
|
46 |
-
# Crie uma imagem composta com
|
47 |
output_image = (input_image[0] * 255).astype('uint8')
|
48 |
-
output_image_with_box = output_image.copy()
|
49 |
|
50 |
-
#
|
51 |
-
if predicted_class == "Cataract": # Adicione sua l贸gica para desenhar a caixa com base na classe
|
52 |
-
image_height, image_width, _ = output_image.shape
|
53 |
-
box_size = min(image_height, image_width) // 2
|
54 |
-
x1 = (image_width - box_size) // 2
|
55 |
-
y1 = (image_height - box_size) // 2
|
56 |
-
x2 = x1 + box_size
|
57 |
-
y2 = y1 + box_size
|
58 |
-
cv2.rectangle(output_image_with_box, (x1, y1), (x2, y2), (0, 255, 0), 2) # Caixa verde
|
59 |
-
|
60 |
-
# Escreva o r贸tulo de previs茫o no output_image_with_box (com a cor da caixa)
|
61 |
font = cv2.FONT_HERSHEY_SIMPLEX
|
62 |
font_scale = 0.4 # Tamanho da fonte reduzido
|
63 |
|
64 |
# Adicione a data e hora da an谩lise
|
65 |
current_time = datetime.datetime.now()
|
66 |
-
cv2.putText(
|
67 |
-
|
68 |
-
cv2.putText(output_image_with_box, f"Predicted Class: {predicted_class}", (10, 60), font, font_scale, (0, 255, 0), 1) # Cor verde
|
69 |
|
70 |
-
|
71 |
|
|
|
72 |
|
73 |
# Crie uma interface Gradio
|
74 |
input_interface = gr.Interface(
|
@@ -79,4 +67,4 @@ input_interface = gr.Interface(
|
|
79 |
)
|
80 |
|
81 |
# Inicie o aplicativo Gradio
|
82 |
-
input_interface.launch()
|
|
|
43 |
class_labels = ["Normal", "Cataract"] # Substitua pelas suas etiquetas de classe reais
|
44 |
predicted_class = class_labels[class_index]
|
45 |
|
46 |
+
# Crie uma imagem composta com o r贸tulo de previs茫o
|
47 |
output_image = (input_image[0] * 255).astype('uint8')
|
|
|
48 |
|
49 |
+
# Escreva o r贸tulo de previs茫o no output_image (com a cor do texto)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
font = cv2.FONT_HERSHEY_SIMPLEX
|
51 |
font_scale = 0.4 # Tamanho da fonte reduzido
|
52 |
|
53 |
# Adicione a data e hora da an谩lise
|
54 |
current_time = datetime.datetime.now()
|
55 |
+
cv2.putText(output_image, f"Analysis Time: {current_time.strftime('%Y-%m-%d %H:%M:%S')}", (10, 40), font, font_scale, (0, 255, 0), 1)
|
|
|
|
|
56 |
|
57 |
+
cv2.putText(output_image, f"Predicted Class: {predicted_class}", (10, 60), font, font_scale, (0, 255, 0), 1) # Cor verde
|
58 |
|
59 |
+
return output_image
|
60 |
|
61 |
# Crie uma interface Gradio
|
62 |
input_interface = gr.Interface(
|
|
|
67 |
)
|
68 |
|
69 |
# Inicie o aplicativo Gradio
|
70 |
+
input_interface.launch()
|