Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
13 changes: 9 additions & 4 deletions src/modeling/glam.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Module that contains networks for MIL family
"""
import warnings
import logging
import numpy as np
import torch
Expand Down Expand Up @@ -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)
Expand Down