From 2c5c1f049b5125d1ef0b1e11b4fe016c02a84e29 Mon Sep 17 00:00:00 2001 From: Crimson2461 <111436689+Crimson2461@users.noreply.github.com> Date: Wed, 17 Aug 2022 14:42:19 +0200 Subject: [PATCH 1/3] Remove assert statements --- src/modeling/glam.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/modeling/glam.py b/src/modeling/glam.py index 6edab0b..4052236 100644 --- a/src/modeling/glam.py +++ b/src/modeling/glam.py @@ -57,10 +57,10 @@ def _convert_crop_position(self, crops_x_small, cam_size, x_original): top_k_prop_x = crops_x_small[:, :, 0] / h top_k_prop_y = crops_x_small[:, :, 1] / w # sanity check - assert np.max(top_k_prop_x) <= 1.0, "top_k_prop_x >= 1.0" - assert np.min(top_k_prop_x) >= 0.0, "top_k_prop_x <= 0.0" - assert np.max(top_k_prop_y) <= 1.0, "top_k_prop_y >= 1.0" - assert np.min(top_k_prop_y) >= 0.0, "top_k_prop_y <= 0.0" + # assert np.max(top_k_prop_x) <= 1.0, "top_k_prop_x >= 1.0" + # assert np.min(top_k_prop_x) >= 0.0, "top_k_prop_x <= 0.0" + # assert np.max(top_k_prop_y) <= 1.0, "top_k_prop_y >= 1.0" + # assert np.min(top_k_prop_y) >= 0.0, "top_k_prop_y <= 0.0" # interpolate the crop position from cam_size to x_original top_k_interpolate_x = np.expand_dims(np.around(top_k_prop_x * H), -1) top_k_interpolate_y = np.expand_dims(np.around(top_k_prop_y * W), -1) From e0cfec9dcd64dfdd5581b88be5451dd10667f42f Mon Sep 17 00:00:00 2001 From: Crimson2461 <111436689+Crimson2461@users.noreply.github.com> Date: Thu, 18 Aug 2022 09:39:01 +0200 Subject: [PATCH 2/3] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index ca1b970..5cbe7b4 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Weakly-supervised High-resolution Segmentation of Mammography Images for Breast Cancer Diagnosis +*This repository is a fork of the original implementation: [https://github.com/nyukat/GLAM](https://github.com/nyukat/GLAM).* + ## Introduction This is an implementation of the GLAM (Global-Local Activation Maps) model as described in [our paper](https://openreview.net/pdf?id=nBT8eNF7aXr). In this work, we introduce a novel neural network architecture to perform weakly-supervised segmentation of high-resolution images. The proposed model selects regions of interest via coarse-level localization, and then performs fine-grained segmentation of those regions. From e89f6aca73396641843354db20b6025a3f369d52 Mon Sep 17 00:00:00 2001 From: Ankit Dhall Date: Thu, 18 Aug 2022 09:54:22 +0200 Subject: [PATCH 3/3] Convert asserts to warnings --- src/modeling/glam.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/modeling/glam.py b/src/modeling/glam.py index 4052236..ca04597 100644 --- a/src/modeling/glam.py +++ b/src/modeling/glam.py @@ -1,6 +1,7 @@ """ Module that contains networks for MIL family """ +import warnings import logging import numpy as np import torch @@ -57,10 +58,14 @@ def _convert_crop_position(self, crops_x_small, cam_size, x_original): top_k_prop_x = crops_x_small[:, :, 0] / h top_k_prop_y = crops_x_small[:, :, 1] / w # sanity check - # assert np.max(top_k_prop_x) <= 1.0, "top_k_prop_x >= 1.0" - # assert np.min(top_k_prop_x) >= 0.0, "top_k_prop_x <= 0.0" - # assert np.max(top_k_prop_y) <= 1.0, "top_k_prop_y >= 1.0" - # assert np.min(top_k_prop_y) >= 0.0, "top_k_prop_y <= 0.0" + if np.max(top_k_prop_x) <= 1.0: + warnings.warn("top_k_prop_x >= 1.0") + if np.min(top_k_prop_x) >= 0.0: + warnings.warn("top_k_prop_x <= 0.0") + if np.max(top_k_prop_y) <= 1.0: + warnings.warn("top_k_prop_y >= 1.0") + if np.min(top_k_prop_y) >= 0.0: + warnings.warn("top_k_prop_y <= 0.0") # interpolate the crop position from cam_size to x_original top_k_interpolate_x = np.expand_dims(np.around(top_k_prop_x * H), -1) top_k_interpolate_y = np.expand_dims(np.around(top_k_prop_y * W), -1)