diff --git a/CHANGELOG.md b/CHANGELOG.md index 99643da230..f3e57d1114 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Fixed a bug where `InstanceSegmentation` would fail if samples had an inconsistent number of bboxes, labels, and masks (these will now be treated as negative samples) ([#1222](https://github.com/PyTorchLightning/lightning-flash/pull/1222)) +- Fixed a bug where `ObjectDetector`, `InstanceSegmentation`, and `KeypointDetector` would log train and validation metrics with the same name ([#1252](https://github.com/PyTorchLightning/lightning-flash/pull/1252)) + ## [0.7.0] - 2022-02-15 ### Added diff --git a/flash/core/data/utils.py b/flash/core/data/utils.py index 69294d4a21..f7b3c51a75 100644 --- a/flash/core/data/utils.py +++ b/flash/core/data/utils.py @@ -39,6 +39,7 @@ RunningStage.VALIDATING: "val", RunningStage.PREDICTING: "predict", RunningStage.SERVING: "serve", + RunningStage.SANITY_CHECKING: "val", } _STAGES_PREFIX_VALUES = {"train", "test", "val", "predict", "serve"} diff --git a/flash/core/integrations/icevision/adapter.py b/flash/core/integrations/icevision/adapter.py index cdb6e12ae1..c030cad611 100644 --- a/flash/core/integrations/icevision/adapter.py +++ b/flash/core/integrations/icevision/adapter.py @@ -42,8 +42,8 @@ class SimpleCOCOMetric(COCOMetric): def finalize(self) -> Dict[str, float]: logs = super().finalize() return { - "Precision (IoU=0.50:0.95,area=all)": logs["AP (IoU=0.50:0.95) area=all"], - "Recall (IoU=0.50:0.95,area=all,maxDets=100)": logs["AR (IoU=0.50:0.95) area=all maxDets=100"], + "precision (IoU=0.50:0.95,area=all)": logs["AP (IoU=0.50:0.95) area=all"], + "recall (IoU=0.50:0.95,area=all,maxDets=100)": logs["AR (IoU=0.50:0.95) area=all maxDets=100"], } diff --git a/flash/core/integrations/icevision/wrappers.py b/flash/core/integrations/icevision/wrappers.py index 76da568c1f..b132d00dc7 100644 --- a/flash/core/integrations/icevision/wrappers.py +++ b/flash/core/integrations/icevision/wrappers.py @@ -15,16 +15,19 @@ import torch +from flash.core.data.utils import _STAGES_PREFIX from flash.core.utilities.imports import _ICEVISION_AVAILABLE if _ICEVISION_AVAILABLE: from icevision.models.ross.efficientdet.lightning.model_adapter import ModelAdapter as EffDetModelAdapter -def _log_with_prog_bar_override(log, name, value, **kwargs): +def _log_with_name_and_prog_bar_override(log, adapter, name, value, **kwargs): if "prog_bar" not in kwargs: kwargs["prog_bar"] = True - return log(name.split("/")[-1], value, **kwargs) + metric = name.split("/")[-1] + metric = f"{_STAGES_PREFIX[adapter.trainer.state.stage]}_{metric}" + return log(metric, value, **kwargs) def _effdet_validation_step(validation_step, batch, batch_idx): @@ -36,7 +39,7 @@ def _effdet_validation_step(validation_step, batch, batch_idx): def wrap_icevision_adapter(adapter): if not isinstance(adapter.log, partial): - adapter.log = partial(_log_with_prog_bar_override, adapter.log) + adapter.log = partial(_log_with_name_and_prog_bar_override, adapter.log, adapter) if isinstance(adapter, EffDetModelAdapter) and not isinstance(adapter.validation_step, partial): adapter.validation_step = partial(_effdet_validation_step, adapter.validation_step)