microsoft / torchgeo

TorchGeo: datasets, samplers, transforms, and pre-trained models for geospatial data
https://www.osgeo.org/projects/torchgeo/
MIT License
2.32k stars 298 forks source link

Support classwise metrics #2121

Open robmarkcole opened 2 weeks ago

robmarkcole commented 2 weeks ago

Summary

This FR is to add support for classwise metrics to the segmentation trainer

Rationale

There can be many classes in a dataset and we want class specific metrics

Implementation

Using the approach of @isaaccorley as here with ClasswiseWrapper and enabled by an optional arg to the segmentation trainer, classwise_metrics: bool = False. To support this an additional labels: Optional[List[str]] = None arg will also be added

Alternatives

None

Additional information

No response

adamjstewart commented 2 weeks ago

Why not always compute both macro and micro statistics in all trainers? I would welcome a PR that adds this.

robmarkcole commented 2 weeks ago

In addition to class wise or instead of? I think that would be nice to have the complete set - with the classwise as optional otherwise the list of metrics can get very long

adamjstewart commented 1 week ago

Ah sorry, yeah I meant macro + micro + classwise. As long as that doesn't noticeably slow down training time it should be fine.