Update app.py
Browse files
app.py
CHANGED
@@ -79,20 +79,30 @@ def processar_imagem_de_entrada_wrapper(img, modelo):
|
|
79 |
model = models[modelo]
|
80 |
spent, img_out = processar_imagem_de_entrada(img, modelo, model)
|
81 |
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
|
97 |
has_disease = has_disease(img_out)
|
98 |
|
|
|
79 |
model = models[modelo]
|
80 |
spent, img_out = processar_imagem_de_entrada(img, modelo, model)
|
81 |
|
82 |
+
def has_disease(img, model, min_area=500):
|
83 |
+
"""Checks if the angiogram has disease.
|
84 |
+
|
85 |
+
Args:
|
86 |
+
img: The input angiogram.
|
87 |
+
model: The segmentation model.
|
88 |
+
min_area: The minimum area for an anomaly to be considered a disease.
|
89 |
+
|
90 |
+
Returns:
|
91 |
+
True if the angiogram has disease, False otherwise.
|
92 |
+
"""
|
93 |
+
|
94 |
+
# Segment the angiogram.
|
95 |
+
mask = model.predict(img)
|
96 |
+
|
97 |
+
# Detect anomalies in the mask.
|
98 |
+
anomalies = detect_anomalies(img, mask)
|
99 |
+
|
100 |
+
# Check if any of the anomalies are large enough to be considered a disease.
|
101 |
+
for anomaly in anomalies:
|
102 |
+
if anomaly[1] >= min_area:
|
103 |
+
return True
|
104 |
+
|
105 |
+
return False
|
106 |
|
107 |
has_disease = has_disease(img_out)
|
108 |
|