OverDriveLee commited on
Commit
d934f93
1 Parent(s): 4407d55

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -2
app.py CHANGED
@@ -64,14 +64,24 @@ def segment(image):
64
  mask_image *= 255
65
  mask_image = mask_image.astype(np.uint8)
66
  mask_image = Image.fromarray(mask_image).convert("L")
67
- return mask_image
 
 
 
 
 
 
 
 
 
 
68
 
69
  if __name__ == "__main__":
70
  model = build_model(input_shape=(size, size, 1))
71
  gr.Interface(
72
  fn=segment,
73
  inputs="image",
74
- outputs=gr.Image(type="pil", label="Breast Cancer Mask"),
75
  examples=[["benign(10).png"], ["benign(109).png"]],
76
  title = '<h1 style="text-align: center;">Breast Cancer Ultrasound Image Segmentation! 💐 </h1>',
77
  description = """
 
64
  mask_image *= 255
65
  mask_image = mask_image.astype(np.uint8)
66
  mask_image = Image.fromarray(mask_image).convert("L")
67
+
68
+ #Porcentaje 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 los porcentajes de 0 y 1
74
+ class_0_percentage = 100 - percentage
75
+ class_1_percentage = percentage
76
+
77
+ return mask_image, class_0_percentage, class_1_percentage
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=[gr.Image(type="pil", label="Breast Cancer Mask"),"number", "number"],
85
  examples=[["benign(10).png"], ["benign(109).png"]],
86
  title = '<h1 style="text-align: center;">Breast Cancer Ultrasound Image Segmentation! 💐 </h1>',
87
  description = """