-
Notifications
You must be signed in to change notification settings - Fork 411
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
imports: deprecate from pkg root [2/n] Detection (#1694)
* imports: detection * functionals * imports * fix * all
- Loading branch information
Showing
13 changed files
with
402 additions
and
327 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
from typing import Any, Collection | ||
|
||
from torchmetrics.detection import ModifiedPanopticQuality, PanopticQuality | ||
from torchmetrics.utilities.prints import _deprecated_root_import_class | ||
|
||
|
||
class _ModifiedPanopticQuality(ModifiedPanopticQuality): | ||
"""Wrapper for deprecated import. | ||
>>> from torch import tensor | ||
>>> preds = tensor([[[0, 0], [0, 1], [6, 0], [7, 0], [0, 2], [1, 0]]]) | ||
>>> target = tensor([[[0, 1], [0, 0], [6, 0], [7, 0], [6, 0], [255, 0]]]) | ||
>>> pq_modified = _ModifiedPanopticQuality(things = {0, 1}, stuffs = {6, 7}) | ||
>>> pq_modified(preds, target) | ||
tensor(0.7667, dtype=torch.float64) | ||
""" | ||
|
||
def __init__( | ||
self, | ||
things: Collection[int], | ||
stuffs: Collection[int], | ||
allow_unknown_preds_category: bool = False, | ||
**kwargs: Any, | ||
) -> None: | ||
_deprecated_root_import_class("ModifiedPanopticQuality", "detection") | ||
return super().__init__( | ||
things=things, stuffs=stuffs, allow_unknown_preds_category=allow_unknown_preds_category, **kwargs | ||
) | ||
|
||
|
||
class _PanopticQuality(PanopticQuality): | ||
"""Wrapper for deprecated import. | ||
>>> from torch import tensor | ||
>>> preds = tensor([[[[6, 0], [0, 0], [6, 0], [6, 0]], | ||
... [[0, 0], [0, 0], [6, 0], [0, 1]], | ||
... [[0, 0], [0, 0], [6, 0], [0, 1]], | ||
... [[0, 0], [7, 0], [6, 0], [1, 0]], | ||
... [[0, 0], [7, 0], [7, 0], [7, 0]]]]) | ||
>>> target = tensor([[[[6, 0], [0, 1], [6, 0], [0, 1]], | ||
... [[0, 1], [0, 1], [6, 0], [0, 1]], | ||
... [[0, 1], [0, 1], [6, 0], [1, 0]], | ||
... [[0, 1], [7, 0], [1, 0], [1, 0]], | ||
... [[0, 1], [7, 0], [7, 0], [7, 0]]]]) | ||
>>> panoptic_quality = _PanopticQuality(things = {0, 1}, stuffs = {6, 7}) | ||
>>> panoptic_quality(preds, target) | ||
tensor(0.5463, dtype=torch.float64) | ||
""" | ||
|
||
def __init__( | ||
self, | ||
things: Collection[int], | ||
stuffs: Collection[int], | ||
allow_unknown_preds_category: bool = False, | ||
**kwargs: Any, | ||
) -> None: | ||
_deprecated_root_import_class("PanopticQuality", "detection") | ||
return super().__init__( | ||
things=things, stuffs=stuffs, allow_unknown_preds_category=allow_unknown_preds_category, **kwargs | ||
) |
212 changes: 0 additions & 212 deletions
212
src/torchmetrics/detection/modified_panoptic_quality.py
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.