Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Commit

Permalink
Fix compatibility with TM 10 (#1469)
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanwharris authored Oct 18, 2022
1 parent 41d1251 commit 1d3cb6e
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

### Fixed

- Fixed compatibility with `torchmetrics==1.10.0` ([#1469](https://github.com/Lightning-AI/lightning-flash/pull/1469))


## [0.8.0] - 2022-09-02

Expand Down
1 change: 1 addition & 0 deletions flash/core/utilities/imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class Image:
_PANDAS_GREATER_EQUAL_1_3_0 = compare_version("pandas", operator.ge, "1.3.0")
_ICEVISION_GREATER_EQUAL_0_11_0 = compare_version("icevision", operator.ge, "0.11.0")
_TM_GREATER_EQUAL_0_7_0 = compare_version("torchmetrics", operator.ge, "0.7.0")
_TM_GREATER_EQUAL_0_10_0 = compare_version("torchmetrics", operator.ge, "0.10.0")
_BAAL_GREATER_EQUAL_1_5_2 = compare_version("baal", operator.ge, "1.5.2")

_TEXT_AVAILABLE = all(
Expand Down
5 changes: 4 additions & 1 deletion flash/image/segmentation/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from flash.core.serve import Composition
from flash.core.utilities.imports import (
_TM_GREATER_EQUAL_0_7_0,
_TM_GREATER_EQUAL_0_10_0,
_TORCHVISION_AVAILABLE,
_TORCHVISION_GREATER_EQUAL_0_9,
requires,
Expand Down Expand Up @@ -55,7 +56,9 @@ class InterpolationMode:
NEAREST = "nearest"


if _TM_GREATER_EQUAL_0_7_0:
if _TM_GREATER_EQUAL_0_10_0:
from torchmetrics.classification import MulticlassJaccardIndex as JaccardIndex
elif _TM_GREATER_EQUAL_0_7_0:
from torchmetrics import JaccardIndex
else:
from torchmetrics import IoU as JaccardIndex
Expand Down
6 changes: 4 additions & 2 deletions flash/pointcloud/segmentation/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from flash.core.data.io.input_transform import InputTransform
from flash.core.data.utilities.collate import wrap_collate
from flash.core.registry import FlashRegistry
from flash.core.utilities.imports import _POINTCLOUD_AVAILABLE, _TM_GREATER_EQUAL_0_7_0
from flash.core.utilities.imports import _POINTCLOUD_AVAILABLE, _TM_GREATER_EQUAL_0_7_0, _TM_GREATER_EQUAL_0_10_0
from flash.core.utilities.stability import beta
from flash.core.utilities.types import LOSS_FN_TYPE, LR_SCHEDULER_TYPE, METRICS_TYPE, OPTIMIZER_TYPE
from flash.pointcloud.segmentation.backbones import POINTCLOUD_SEGMENTATION_BACKBONES
Expand All @@ -33,7 +33,9 @@
from open3d._ml3d.torch.modules.losses.semseg_loss import filter_valid_label
from open3d.ml.torch.dataloaders import TorchDataloader

if _TM_GREATER_EQUAL_0_7_0:
if _TM_GREATER_EQUAL_0_10_0:
from torchmetrics.classification import MulticlassJaccardIndex as JaccardIndex
elif _TM_GREATER_EQUAL_0_7_0:
from torchmetrics import JaccardIndex
else:
from torchmetrics import IoU as JaccardIndex
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from flash.image.segmentation.output import SegmentationLabelsOutput

model = SemanticSegmentation.load_from_checkpoint(
"https://flash-weights.s3.amazonaws.com/0.8.0/semantic_segmentation_model.pt"
"https://flash-weights.s3.amazonaws.com/0.9.0/semantic_segmentation_model.pt"
)
model.output = SegmentationLabelsOutput(visualize=False)
model.serve()
2 changes: 1 addition & 1 deletion tests/core/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def test_classification_task_trainer_predict(tmpdir):
),
pytest.param(
SemanticSegmentation,
"0.8.0/semantic_segmentation_model.pt",
"0.9.0/semantic_segmentation_model.pt",
marks=pytest.mark.skipif(
not _IMAGE_TESTING,
reason="image packages aren't installed",
Expand Down

0 comments on commit 1d3cb6e

Please sign in to comment.