DHEIVER commited on
Commit
9a5fe1d
1 Parent(s): 6cabf01

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -14
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
- # Define the function `has_disease`
83
- def has_disease(img_out):
84
- """
85
- Checks if the angiogram has disease based on the segmentation.
86
- Args:
87
- img_out: The segmented angiogram.
88
- Returns:
89
- True if the angiogram has disease, False otherwise.
90
- """
91
- percentage_of_vessels = np.sum(img_out) / (img_out.shape[0] * img_out.shape[1])
92
- if percentage_of_vessels > 0.5:
93
- return "Sim"
94
- else:
95
- return "Não"
 
 
 
 
 
 
 
 
 
 
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