From e0943e6da6b9ff5ce2e4043bd4ec1e3af31f2863 Mon Sep 17 00:00:00 2001 From: Tim Laibacher <tim.laibacher@idiap.ch> Date: Mon, 8 Jul 2019 09:37:18 +0200 Subject: [PATCH] Update docs --- bob/ip/binseg/modeling/driu.py | 2 +- bob/ip/binseg/modeling/losses.py | 8 ++++---- bob/ip/binseg/script/binseg.py | 4 +++- bob/ip/binseg/utils/checkpointer.py | 4 +--- bob/ip/binseg/utils/plot.py | 22 ++++++++++++++++++++++ doc/covdresults.rst | 2 +- doc/index.rst | 1 - doc/links.rst | 9 +++++++++ doc/references.rst | 10 ---------- 9 files changed, 41 insertions(+), 21 deletions(-) delete mode 100644 doc/references.rst diff --git a/bob/ip/binseg/modeling/driu.py b/bob/ip/binseg/modeling/driu.py index 81ad9c4f..466d4eb0 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 7bcde850..de85a581 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 47686ad3..7ddfe2af 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 4da05227..e2090caa 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 db626937..e8eab7da 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 6dca5a6d..05c48c75 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 d38e7a4e..e3f54086 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 7b94ab06..72a0f3e1 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 9422bbc1..00000000 --- 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 -- GitLab