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

Fix compatibility with TM 10 #1469

Merged
merged 5 commits into from
Oct 18, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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