haritsahm
commited on
Commit
·
104566a
1
Parent(s):
5c36fe1
Modify flows and variable names
Browse files
main.py
CHANGED
@@ -97,7 +97,7 @@ def filter_files(files: List) -> List:
|
|
97 |
return file_paths
|
98 |
|
99 |
|
100 |
-
def predict_bilateral(
|
101 |
"""Predict Bilateral Mammography.
|
102 |
|
103 |
Parameters
|
@@ -110,17 +110,23 @@ def predict_bilateral(file):
|
|
110 |
List[List, Dict]
|
111 |
List of objects that will be used to display the result
|
112 |
"""
|
|
|
|
|
|
|
113 |
displays_imgs = []
|
|
|
114 |
|
115 |
-
|
116 |
-
|
|
|
117 |
|
118 |
-
|
|
|
119 |
|
120 |
-
|
121 |
-
|
122 |
|
123 |
-
out, _, out_refiner = BILATERAL_MODEL(
|
124 |
|
125 |
out_refiner = utils.mean_activations(out_refiner).numpy()
|
126 |
|
@@ -135,10 +141,10 @@ def predict_bilateral(file):
|
|
135 |
refined_view, (im_w, im_h), interpolation=cv2.INTER_LINEAR)
|
136 |
|
137 |
image0_colored = cv2.normalize(
|
138 |
-
|
139 |
image0_colored = cv2.cvtColor(image0_colored, cv2.COLOR_GRAY2RGB)
|
140 |
image1_colored = cv2.normalize(
|
141 |
-
|
142 |
image1_colored = cv2.cvtColor(image1_colored, cv2.COLOR_GRAY2RGB)
|
143 |
|
144 |
heatmap0_overlay = cv2.addWeighted(
|
|
|
97 |
return file_paths
|
98 |
|
99 |
|
100 |
+
def predict_bilateral(files):
|
101 |
"""Predict Bilateral Mammography.
|
102 |
|
103 |
Parameters
|
|
|
110 |
List[List, Dict]
|
111 |
List of objects that will be used to display the result
|
112 |
"""
|
113 |
+
|
114 |
+
filtered_files = filter_files(files)
|
115 |
+
|
116 |
displays_imgs = []
|
117 |
+
images = []
|
118 |
|
119 |
+
for path in filtered_files:
|
120 |
+
image = np.array(Image.open(str(path)))
|
121 |
+
images.append(image)
|
122 |
|
123 |
+
images = np.asarray(images).astype(np.float32)
|
124 |
+
im_h, im_w = images[0].shape[:2]
|
125 |
|
126 |
+
images_t = torch.from_numpy(images)
|
127 |
+
images_t = images_t.unsqueeze(0) # Add batch dimension
|
128 |
|
129 |
+
out, _, out_refiner = BILATERAL_MODEL(images_t)
|
130 |
|
131 |
out_refiner = utils.mean_activations(out_refiner).numpy()
|
132 |
|
|
|
141 |
refined_view, (im_w, im_h), interpolation=cv2.INTER_LINEAR)
|
142 |
|
143 |
image0_colored = cv2.normalize(
|
144 |
+
images[0], None, 0, 255, cv2.NORM_MINMAX, dtype=cv2.CV_8U)
|
145 |
image0_colored = cv2.cvtColor(image0_colored, cv2.COLOR_GRAY2RGB)
|
146 |
image1_colored = cv2.normalize(
|
147 |
+
images[1], None, 0, 255, cv2.NORM_MINMAX, dtype=cv2.CV_8U)
|
148 |
image1_colored = cv2.cvtColor(image1_colored, cv2.COLOR_GRAY2RGB)
|
149 |
|
150 |
heatmap0_overlay = cv2.addWeighted(
|