Home

Awesome

Optimization with JDTLoss and Evaluation with Fine-grained mIoUs for Semantic Segmentation

Models

<details> <summary>Methods</summary> </details> <details> <summary>Backbones</summary> </details>

Datasets

<details> <summary>Urban</summary> </details> <details> <summary>"Thing" & "Stuff"</summary> </details> <details> <summary>Aerial</summary> </details> <details> <summary>Medical</summary> </details>

Metrics

<details> <summary>Accuracy</summary> </details> <details> <summary>Calibration Error</summary> </details>

Prerequisites

Requirements

Prepapre Datasets

Usage

from losses.jdt_loss import JDTLoss

# Jaccard loss (default): JDTLoss()
# Dice loss: JDTLoss(alpha=0.5, beta=0.5)
criterion = JDTLoss()

for (image, label) in data_loader:
    logits = model(image)
    loss = criterion(logits, label)
from metrics.metric_group import MetricGroup

metric_group = MetricGroup(num_classes=..., ignore_index=...)

for (image, label) in data_loader:
    logits = model(image)
    prob = logits.log_softmax(dim=1).exp()
    # Both `prob` and `label` need to be on CPU
    metric_group.add(prob, label)

results = metric_group.value()
python main.py \
  --data_dir "path/to/data_dir" \
  --output_dir "path/to/output_dir" \
  --model_yaml "deeplabv3plus_resnet101d" \
  --data_yaml "cityscapes" \
  --label_yaml "hard" \
  --loss_yaml "jaccard_ic_present_all" \
  --schedule_yaml "40k_iters" \
  --optim_yaml "adamw_lr6e-5" \
  --test_yaml "test_iou"

FAQs

FAQs.md

Acknowledgements

We express our gratitude to the creators and maintainers of the following projects: pytorch-image-models, MMSegmentation, segmentation_models.pytorch, structure_knowledge_distillation

Citations

@InProceedings{Wang2023Revisiting,
  title     = {Revisiting Evaluation Metrics for Semantic Segmentation: Optimization and Evaluation of Fine-grained Intersection over Union},
  author    = {Wang, Zifu and Berman, Maxim and Rannen-Triki, Amal and Torr, Philip H.S. and Tuia, Devis and Tuytelaars, Tinne and Van Gool, Luc and Yu, Jiaqian and Blaschko, Matthew B.},
  booktitle = {NeurIPS},
  year      = {2023}
}

@InProceedings{Wang2023Jaccard,
  title     = {Jaccard Metric Losses: Optimizing the Jaccard Index with Soft Labels},
  author    = {Wang, Zifu and Ning, Xuefei and Blaschko, Matthew B.},
  booktitle = {NeurIPS},
  year      = {2023}
}

@InProceedings{Wang2023Dice,
  title     = {Dice Semimetric Losses: Optimizing the Dice Score with Soft Labels},
  author    = {Wang, Zifu and Popordanoska, Teodora and Bertels, Jeroen and Lemmens, Robin and Blaschko, Matthew B.},
  booktitle = {MICCAI},
  year      = {2023}
}