by-liu / SegLossBias

Code for the paper : Do we really need dice? The hidden region-size biases of segmentation losses. MeDIA 2023. https://www.sciencedirect.com/science/article/abs/pii/S136184152300275X
MIT License
38 stars 4 forks source link
pytorch segmentation

The hidden label-marginal biases of segmentation losses

Code for the paper : The hidden label-marginal biases of segmentation losses.

[arxiv]

Table of Content

Prerequisites

Note : I only test the code with python 3.8 and 3.9. Environment manager like conda or virtualenv is strongly recommended.

  1. Install pytorch and opencv tailored for your environment:

    torch==1.7.1
    torchvision==0.8.2
    opencv-python==4.5.1.48
  2. Other depencencies

    pip install -r requirements.txt
  3. Install the library

    pip install -e .

Prepare dataset

Quick start

Testing with trained model

We provide two best models we currently trained on Retinal Lesions and Cityscapes for quick testing.

Configuration system

We use YACS to define and manage all the configurations. In a nutshell, you typically create a YAML configuration file for each experiment.

All configurable options are defined in defaults.py with default values. Note that each YAML configuration file only overrides the options that are chaning in that experiment. You can also overriede options from the command line using a list of fully-qualified key, value pairs.

Training

The configurations may seem confusing at first. You can play quickly with the provided configuration files.

python tools/train_net.py --config-file ./configs/retinal-lesions/unet_bce-l1_896x896.yaml
python tools/train_net.py --config-file ./configs/cityscapes/r50fpn_512x1024_ce_l1.yaml

License

This work is licensed under MIT License. See LICENSE for details.

If you find this paper/code useful for your research, please consider citing :

@misc{liu2021hidden, title={The hidden label-marginal biases of segmentation losses}, author={Bingyuan Liu and Jose Dolz and Adrian Galdran and Riadh Kobbi and Ismail Ben Ayed}, year={2021}, eprint={2104.08717}, archivePrefix={arXiv}, primaryClass={cs.CV} }