Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -65,12 +65,12 @@ def segment(image):
|
|
65 |
mask_image = mask_image.astype(np.uint8)
|
66 |
mask_image = Image.fromarray(mask_image).convert("L")
|
67 |
|
68 |
-
#
|
69 |
positive_pixels = np.count_nonzero(mask_image)
|
70 |
total_pixels = mask_image.size[0] * mask_image.size[1]
|
71 |
percentage = (positive_pixels / total_pixels) * 100
|
72 |
|
73 |
-
|
74 |
class_0_percentage = 100 - percentage
|
75 |
class_1_percentage = percentage
|
76 |
|
@@ -78,19 +78,19 @@ def segment(image):
|
|
78 |
|
79 |
if __name__ == "__main__":
|
80 |
model = build_model(input_shape=(size, size, 1))
|
81 |
-
|
82 |
fn=segment,
|
83 |
inputs="image",
|
84 |
outputs=[
|
85 |
-
gr.Image(type="pil", label="
|
86 |
-
gr.Number(label="
|
87 |
-
gr.Number(label="
|
88 |
],
|
89 |
examples=[["benign(10).png"], ["benign(109).png"]],
|
90 |
-
title
|
91 |
-
description
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
"""
|
96 |
-
).launch(debug=True)
|
|
|
65 |
mask_image = mask_image.astype(np.uint8)
|
66 |
mask_image = Image.fromarray(mask_image).convert("L")
|
67 |
|
68 |
+
# Porcentagem de 0
|
69 |
positive_pixels = np.count_nonzero(mask_image)
|
70 |
total_pixels = mask_image.size[0] * mask_image.size[1]
|
71 |
percentage = (positive_pixels / total_pixels) * 100
|
72 |
|
73 |
+
# Calcular os percentuais de 0 e 1
|
74 |
class_0_percentage = 100 - percentage
|
75 |
class_1_percentage = percentage
|
76 |
|
|
|
78 |
|
79 |
if __name__ == "__main__":
|
80 |
model = build_model(input_shape=(size, size, 1))
|
81 |
+
gr.Interface(
|
82 |
fn=segment,
|
83 |
inputs="image",
|
84 |
outputs=[
|
85 |
+
gr.Image(type="pil", label="Máscara de Câncer de Mama"),
|
86 |
+
gr.Number(label="Porcentagem da Classe 0"),
|
87 |
+
gr.Number(label="Porcentagem da Classe 1")
|
88 |
],
|
89 |
examples=[["benign(10).png"], ["benign(109).png"]],
|
90 |
+
title='<h1 style="text-align: center;">Segmentação de Imagens de Ultrassom de Câncer de Mama! 💐 </h1>',
|
91 |
+
description="""
|
92 |
+
Confira esse avanço emocionante no campo do diagnóstico e tratamento do câncer de mama!
|
93 |
+
Foi desenvolvido um demo de Segmentação de Imagens de Ultrassom de Câncer de Mama.
|
94 |
+
Faça o upload de um arquivo de imagem ou experimente um dos exemplos abaixo! 🙌
|
95 |
"""
|
96 |
+
).launch(debug=True)
|