Update app.py
Browse files
app.py
CHANGED
|
@@ -181,7 +181,7 @@ def upload_folder_images(original_image_path, enhanced_image_path):
|
|
| 181 |
upload_to_gcs(enhanced_dicom_bytes, folder_name + '/' + enhancement_name + '.dcm', content_type='application/dicom')
|
| 182 |
|
| 183 |
|
| 184 |
-
def get_mean_std_per_batch(image_path, df, H=
|
| 185 |
sample_data = []
|
| 186 |
for idx, img in enumerate(df.sample(100)["Image Index"].values):
|
| 187 |
# path = image_dir + img
|
|
@@ -192,7 +192,7 @@ def get_mean_std_per_batch(image_path, df, H=320, W=320):
|
|
| 192 |
std = np.std(sample_data[0])
|
| 193 |
return mean, std
|
| 194 |
|
| 195 |
-
def load_image(img_path, preprocess=True, height=
|
| 196 |
mean, std = get_mean_std_per_batch(img_path, df, height, width)
|
| 197 |
x = keras.utils.load_img(img_path, target_size=(height, width))
|
| 198 |
x = keras.utils.img_to_array(x)
|
|
@@ -225,7 +225,7 @@ def grad_cam(input_model, img_array, cls, layer_name):
|
|
| 225 |
for index, w in enumerate(weights):
|
| 226 |
cam += w * output[:, :, index]
|
| 227 |
|
| 228 |
-
cam = cv2.resize(cam.numpy(), (
|
| 229 |
cam = np.maximum(cam, 0)
|
| 230 |
cam = cam / cam.max()
|
| 231 |
|
|
|
|
| 181 |
upload_to_gcs(enhanced_dicom_bytes, folder_name + '/' + enhancement_name + '.dcm', content_type='application/dicom')
|
| 182 |
|
| 183 |
|
| 184 |
+
def get_mean_std_per_batch(image_path, df, H=512, W=512):
|
| 185 |
sample_data = []
|
| 186 |
for idx, img in enumerate(df.sample(100)["Image Index"].values):
|
| 187 |
# path = image_dir + img
|
|
|
|
| 192 |
std = np.std(sample_data[0])
|
| 193 |
return mean, std
|
| 194 |
|
| 195 |
+
def load_image(img_path, preprocess=True, height=512, width=512):
|
| 196 |
mean, std = get_mean_std_per_batch(img_path, df, height, width)
|
| 197 |
x = keras.utils.load_img(img_path, target_size=(height, width))
|
| 198 |
x = keras.utils.img_to_array(x)
|
|
|
|
| 225 |
for index, w in enumerate(weights):
|
| 226 |
cam += w * output[:, :, index]
|
| 227 |
|
| 228 |
+
cam = cv2.resize(cam.numpy(), (512, 512), cv2.INTER_LINEAR)
|
| 229 |
cam = np.maximum(cam, 0)
|
| 230 |
cam = cam / cam.max()
|
| 231 |
|