Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -49,33 +49,29 @@ def classify_image(input_image):
|
|
| 49 |
# Crie uma imagem composta com o r贸tulo de previs茫o
|
| 50 |
output_image = (input_image[0] * 255).astype('uint8')
|
| 51 |
|
| 52 |
-
#
|
| 53 |
-
output_image =
|
| 54 |
|
| 55 |
-
#
|
| 56 |
label_background = np.ones((50, output_image.shape[1], 3), dtype=np.uint8) * 255
|
| 57 |
|
| 58 |
-
#
|
| 59 |
output_image[-50:] = label_background
|
| 60 |
|
| 61 |
-
#
|
| 62 |
font = cv2.FONT_HERSHEY_SIMPLEX
|
| 63 |
font_scale = 0.4 # Tamanho da fonte reduzido
|
| 64 |
cv2.putText(output_image, f"Analysis Time: {current_time.strftime('%Y-%m-%d %H:%M:%S')}", (10, output_image.shape[0] - 30), font, font_scale, (0, 0, 0), 1)
|
| 65 |
cv2.putText(output_image, f"Predicted Class: {predicted_class}", (10, output_image.shape[0] - 10), font, font_scale, (0, 0, 0), 1) # Cor preta
|
| 66 |
|
| 67 |
-
#
|
| 68 |
-
|
| 69 |
-
box_size =
|
|
|
|
|
|
|
| 70 |
|
| 71 |
-
#
|
| 72 |
-
|
| 73 |
-
box_y = (output_image.shape[0] - box_size) // 2
|
| 74 |
-
|
| 75 |
-
# Color-code the object box based on the predicted class
|
| 76 |
-
object_box_color = (0, 255, 0) if predicted_class == "Normal" else (255, 0, 0) # Green for Normal, Red for Cataract
|
| 77 |
-
|
| 78 |
-
# Draw a centered object identification box (blue rectangle)
|
| 79 |
cv2.rectangle(output_image, (box_x, box_y), (box_x + box_size, box_y + box_size), object_box_color, 2) # Caixa centralizada
|
| 80 |
|
| 81 |
return output_image
|
|
@@ -89,4 +85,4 @@ input_interface = gr.Interface(
|
|
| 89 |
)
|
| 90 |
|
| 91 |
# Inicie o aplicativo Gradio
|
| 92 |
-
input_interface.launch()
|
|
|
|
| 49 |
# Crie uma imagem composta com o r贸tulo de previs茫o
|
| 50 |
output_image = (input_image[0] * 255).astype('uint8')
|
| 51 |
|
| 52 |
+
# Adicione espa莽o para o r贸tulo de previs茫o na parte inferior da imagem
|
| 53 |
+
output_image = cv2.copyMakeBorder(output_image, 0, 50, 0, 0, cv2.BORDER_CONSTANT, value=(255, 255, 255))
|
| 54 |
|
| 55 |
+
# Desenhe um ret芒ngulo branco como fundo para o r贸tulo
|
| 56 |
label_background = np.ones((50, output_image.shape[1], 3), dtype=np.uint8) * 255
|
| 57 |
|
| 58 |
+
# Coloque o texto do r贸tulo e a caixa dentro do fundo branco
|
| 59 |
output_image[-50:] = label_background
|
| 60 |
|
| 61 |
+
# Escreva o r贸tulo de previs茫o na imagem
|
| 62 |
font = cv2.FONT_HERSHEY_SIMPLEX
|
| 63 |
font_scale = 0.4 # Tamanho da fonte reduzido
|
| 64 |
cv2.putText(output_image, f"Analysis Time: {current_time.strftime('%Y-%m-%d %H:%M:%S')}", (10, output_image.shape[0] - 30), font, font_scale, (0, 0, 0), 1)
|
| 65 |
cv2.putText(output_image, f"Predicted Class: {predicted_class}", (10, output_image.shape[0] - 10), font, font_scale, (0, 0, 0), 1) # Cor preta
|
| 66 |
|
| 67 |
+
# Calcule as coordenadas para centralizar a caixa azul no centro da imagem
|
| 68 |
+
image_height, image_width, _ = output_image.shape
|
| 69 |
+
box_size = 100 # Tamanho da caixa azul (ajuste conforme necess谩rio)
|
| 70 |
+
box_x = (image_width - box_size) // 2
|
| 71 |
+
box_y = (image_height - box_size) // 2
|
| 72 |
|
| 73 |
+
# Desenhe uma caixa de identifica莽茫o de objeto (ret芒ngulo azul) centralizada
|
| 74 |
+
object_box_color = (255, 0, 0) # Azul (BGR)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
cv2.rectangle(output_image, (box_x, box_y), (box_x + box_size, box_y + box_size), object_box_color, 2) # Caixa centralizada
|
| 76 |
|
| 77 |
return output_image
|
|
|
|
| 85 |
)
|
| 86 |
|
| 87 |
# Inicie o aplicativo Gradio
|
| 88 |
+
input_interface.launch()
|