diff --git a/bob/ip/binseg/modeling/driu.py b/bob/ip/binseg/modeling/driu.py index 81ad9c4ff47c4162ef7ed372f5cf505a9fa7cb64..466d4eb0942dcbc5e8f7f26a4ce2ca8db52d6f38 100644 --- a/bob/ip/binseg/modeling/driu.py +++ b/bob/ip/binseg/modeling/driu.py @@ -24,7 +24,7 @@ class ConcatFuseBlock(nn.Module): class DRIU(nn.Module): """ DRIU head module - + Based on paper by `Maninis et al. (2016)`_ Parameters ---------- in_channels_list : list diff --git a/bob/ip/binseg/modeling/losses.py b/bob/ip/binseg/modeling/losses.py index 7bcde8503fdb2334fea0a2f2ce9cc1b0c8253343..de85a581515cb6bccb52074a68963e9978f2c72e 100644 --- a/bob/ip/binseg/modeling/losses.py +++ b/bob/ip/binseg/modeling/losses.py @@ -7,7 +7,7 @@ from torch._jit_internal import weak_script_method class WeightedBCELogitsLoss(_Loss): """ - Implements Equation 1 in [DRIU16]_. Based on ``torch.nn.modules.loss.BCEWithLogitsLoss``. + Implements Equation 1 in `Maninis et al. (2016)`_. Based on ``torch.nn.modules.loss.BCEWithLogitsLoss``. Calculate sum of weighted cross entropy loss. """ def __init__(self, weight=None, size_average=None, reduce=None, reduction='mean', pos_weight=None): @@ -44,7 +44,7 @@ class WeightedBCELogitsLoss(_Loss): class SoftJaccardBCELogitsLoss(_Loss): """ - Implements Equation 6 in [SAT17]_. Based on ``torch.nn.modules.loss.BCEWithLogitsLoss``. + Implements Equation 3 in `Iglovikov et al. (2018)`_. Based on ``torch.nn.modules.loss.BCEWithLogitsLoss``. Attributes ---------- @@ -82,7 +82,7 @@ class SoftJaccardBCELogitsLoss(_Loss): class HEDWeightedBCELogitsLoss(_Loss): """ - Implements Equation 2 in [HED15]_. Based on ``torch.nn.modules.loss.BCEWithLogitsLoss``. + Implements Equation 2 in `He et al. (2015)`_. Based on ``torch.nn.modules.loss.BCEWithLogitsLoss``. Calculate sum of weighted cross entropy loss. """ def __init__(self, weight=None, size_average=None, reduce=None, reduction='mean', pos_weight=None): @@ -123,7 +123,7 @@ class HEDWeightedBCELogitsLoss(_Loss): class HEDSoftJaccardBCELogitsLoss(_Loss): """ - Implements Equation 6 in [SAT17]_ for the hed network. Based on ``torch.nn.modules.loss.BCEWithLogitsLoss``. + Implements Equation 3 in `Iglovikov et al. (2018)`_ for the hed network. Based on ``torch.nn.modules.loss.BCEWithLogitsLoss``. Attributes ---------- diff --git a/bob/ip/binseg/script/binseg.py b/bob/ip/binseg/script/binseg.py index 47686ad3783e7b5241b0b8f3a43bcc1af90f563c..7ddfe2afb6ed569cb03b770b5408a44b6b66d14d 100644 --- a/bob/ip/binseg/script/binseg.py +++ b/bob/ip/binseg/script/binseg.py @@ -30,7 +30,7 @@ from bob.ip.binseg.utils.plot import plot_overview from bob.ip.binseg.utils.click import OptionEatAll from bob.ip.binseg.utils.pdfcreator import create_pdf, get_paths from bob.ip.binseg.utils.rsttable import create_overview_grid -from bob.ip.binseg.utils.plot import metricsviz, overlay +from bob.ip.binseg.utils.plot import metricsviz, overlay,savetransformedtest logger = logging.getLogger(__name__) @@ -397,6 +397,8 @@ def visualize(dataset, output_path, **kwargs): metricsviz(dataset=dataset, output_path=output_path) logger.info('Creating overlay visualizations for {}'.format(output_path)) overlay(dataset=dataset, output_path=output_path) + logger.info('Saving transformed test images {}'.format(output_path)) + savetransformedtest(dataset=dataset, output_path=output_path) # SSLTrain diff --git a/bob/ip/binseg/utils/checkpointer.py b/bob/ip/binseg/utils/checkpointer.py index 4da052277e1733175d2dee397cabb848a626e7a5..e2090caa2c5f337fcae10247446f5676713f33d8 100644 --- a/bob/ip/binseg/utils/checkpointer.py +++ b/bob/ip/binseg/utils/checkpointer.py @@ -11,9 +11,7 @@ from bob.ip.binseg.utils.model_serialization import load_state_dict from bob.ip.binseg.utils.model_zoo import cache_url class Checkpointer: - """Adapted from [MASKRCNNBENCHMARK_18]_ - - Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + """Adapted from `maskrcnn-benchmark`_ under MIT license Returns ------- diff --git a/bob/ip/binseg/utils/plot.py b/bob/ip/binseg/utils/plot.py index db6269377054f5084e0fe84b8fb14c30733ba9a1..e8eab7da9c94b06ed82f353ef3ba626e2879b9d7 100644 --- a/bob/ip/binseg/utils/plot.py +++ b/bob/ip/binseg/utils/plot.py @@ -290,3 +290,25 @@ def overlay(dataset, output_path): overlayed_path = os.path.join(output_path,'overlayed') if not os.path.exists(overlayed_path): os.makedirs(overlayed_path) overlayed.save(os.path.join(overlayed_path,name)) + + +def savetransformedtest(dataset, output_path): + """Save the test images as they are fed into the neural network. + Makes it easier to create overlay animations (e.g. slide) + + Parameters + ---------- + dataset : :py:class:`torch.utils.data.Dataset` + output_path : str + path where results and probability output images are stored. E.g. ``'DRIVE/MODEL'`` + """ + + for sample in dataset: + # get sample + name = sample[0] + img = VF.to_pil_image(sample[1]) # PIL Image + + # save to disk + testimg_path = os.path.join(output_path,'transformedtestimages') + if not os.path.exists(testimg_path): os.makedirs(testimg_path) + img.save(os.path.join(testimg_path,name)) diff --git a/doc/covdresults.rst b/doc/covdresults.rst index 6dca5a6d7cf58178821fb3b3b681f79e7a5061e6..05c48c75481c55b76f3a505c153ae38a15641bea 100644 --- a/doc/covdresults.rst +++ b/doc/covdresults.rst @@ -26,7 +26,7 @@ Dice Scores +-------------------+---------------+---------+ | COVD-HRF | 0.8013 | 0.8036 | +-------------------+---------------+---------+ -| COVD-HRF SSL | still running | 0.7999 | +| COVD-HRF SSL | 0.8002 | 0.7999 | +-------------------+---------------+---------+ | COVD-IOSTAR | 0.7934 | 0.7953 | +-------------------+---------------+---------+ diff --git a/doc/index.rst b/doc/index.rst index d38e7a4e60c83c1bc4703071740adb9add84011f..e3f540864d87efd24b7bf40b649b5b1d2df0bab3 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -21,7 +21,6 @@ Users Guide benchmarkresults covdresults api - references .. todolist:: diff --git a/doc/links.rst b/doc/links.rst index 7b94ab0645774c0e00d9c1f15065d4f093fb9be0..72a0f3e1682d61b0d3f4b62bc7980fbc561153e1 100644 --- a/doc/links.rst +++ b/doc/links.rst @@ -51,3 +51,12 @@ .. REFUGE .. _refuge: http://ai.baidu.com/broad/download?dataset=gon + +.. OtherPapers + +.. _Iglovikov et al. (2018): http://openaccess.thecvf.com/content_cvpr_2018_workshops/w4/html/Iglovikov_TernausNetV2_Fully_Convolutional_CVPR_2018_paper.html +.. _He et al. (2015): https://doi.org/10.1109/ICCV.2015.164 + +.. Software Tools + +.. _maskrcnn-benchmark: https://github.com/facebookresearch/maskrcnn-benchmark diff --git a/doc/references.rst b/doc/references.rst deleted file mode 100644 index 9422bbc16f1e884b37065c4daeba16891172f035..0000000000000000000000000000000000000000 --- a/doc/references.rst +++ /dev/null @@ -1,10 +0,0 @@ -.. vim: set fileencoding=utf-8 : - -=========== -References -=========== - -.. [HED15] *Saining Xie and Zhuowen Tu*, **Holistically-Nested Edge Detection**, in: Proceedings of IEEE International Conference on Computer Vision, 2015 -.. [SAT17] *Alexey Shvets, Vladimir Iglovikov, Alexander Rakhlin and Alexandr A. Kalinin** , in: 17th IEEE International Conference on Machine Learning and Applications (ICMLA), 2017 -.. [DRIU16] *K.K. Maninis, J. Pont-Tuset, P. Arbeláez, and L. Van Gool**, in: Medical Image Computing and Computer-Assisted Intervention (MICCAI), 2016 -.. [MASKRCNNBENCHMARK_18] **Francisco Massa and Ross Girshick**, in https://github.com/facebookresearch/maskrcnn-benchmark \ No newline at end of file