Code of our MIDL 2018 submission
Switch branches/tags
Nothing to show
Clone or download
Latest commit 62b66df Aug 6, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
ACDC-2D-All Init Jun 14, 2018
.gitignore Init Jun 14, 2018 Init Jun 14, 2018 Init Jun 14, 2018 Readme Jun 15, 2018 Readme Jun 15, 2018 Readme Jun 15, 2018 Update Aug 6, 2018
requirements.txt Readme Jun 15, 2018 Init Jun 14, 2018

Constrained-CNN losses for weakly supervised segmentation

Code of our submission at MIDL 2018. Video of the talk is available:

To run it, simply run (python3.6+, the requirements are specified in the requirements.txt file).

The partial ground truth that we used are provided, but not the original dataset: You will need to download and pre-process it yourselves first.

The code was developed for PyTorch 0.3.1, and has been modified slightly to work with PyTorch 0.4. However, a lot of cleanup (removing the variables for instance) still need to be done.

Loss functions

The loss functions are located in, and are defined as autograd functions. We implemented manually both the forward and the backward passes with numpy. We use a batch size of 1, and the code might need to be modified before working for more.

The inputs (predictions, labels and weak labels) are all represented as 4-D tensors:

b, c, w, h = input.shape
assert target.shape == input.shape
assert weakLabels.shape == (b, 1, w, h)

b is the batch size, c the number of classes (2), and w, h the image size. Since this is a binary problem, the two classes are complementary (minus the rounding errors), both for the predictions and labels:

assert np.allclose(input[:, 0, ...].cpu().numpy(), 1 - input[:, 1, ...].cpu().numpy(), atol=1e-2)