Skip to content

fix prototype features and functional transforms after review #5377

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 4 additions & 3 deletions torchvision/prototype/features/_bounding_box.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from typing import Any, Tuple, Union, Optional

import torch
Expand All @@ -15,7 +17,6 @@ class BoundingBoxFormat(StrEnum):


class BoundingBox(Feature):
formats = BoundingBoxFormat
format: BoundingBoxFormat
image_size: Tuple[int, int]

Expand All @@ -27,7 +28,7 @@ def __new__(
device: Optional[torch.device] = None,
format: Union[BoundingBoxFormat, str],
image_size: Tuple[int, int],
):
) -> BoundingBox:
bounding_box = super().__new__(cls, data, dtype=dtype, device=device)

if isinstance(format, str):
Expand All @@ -37,7 +38,7 @@ def __new__(

return bounding_box

def to_format(self, format: Union[str, BoundingBoxFormat]) -> "BoundingBox":
def to_format(self, format: Union[str, BoundingBoxFormat]) -> BoundingBox:
# import at runtime to avoid cyclic imports
from torchvision.prototype.transforms.functional import convert_bounding_box_format

Expand Down
5 changes: 3 additions & 2 deletions torchvision/prototype/features/_image.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import warnings
from typing import Any, Optional, Union, Tuple, cast

Expand All @@ -20,7 +22,6 @@ class ColorSpace(StrEnum):


class Image(Feature):
color_spaces = ColorSpace
color_space: ColorSpace

def __new__(
Expand Down Expand Up @@ -79,5 +80,5 @@ def guess_color_space(data: torch.Tensor) -> ColorSpace:
def show(self) -> None:
to_pil_image(make_grid(self.view(-1, *self.shape[-3:]))).show()

def draw_bounding_box(self, bounding_box: BoundingBox, **kwargs: Any) -> "Image":
def draw_bounding_box(self, bounding_box: BoundingBox, **kwargs: Any) -> Image:
return Image.new_like(self, draw_bounding_boxes(self, bounding_box.to_format("xyxy").view(-1, 4), **kwargs))
3 changes: 1 addition & 2 deletions torchvision/prototype/features/_label.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ def __new__(

@classmethod
def from_category(cls, category: str, *, categories: Sequence[str]):
categories = list(categories)
return cls(categories.index(category), categories=categories)

def to_categories(self):
Expand All @@ -45,7 +44,7 @@ def __new__(
*,
dtype: Optional[torch.dtype] = None,
device: Optional[torch.device] = None,
like: Optional["Label"] = None,
like: Optional[Label] = None,
categories: Optional[Sequence[str]] = None,
):
one_hot_label = super().__new__(cls, data, dtype=dtype, device=device)
Expand Down
4 changes: 0 additions & 4 deletions torchvision/prototype/transforms/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
from . import functional
from .functional import InterpolationMode # usort: skip

from ._transform import Transform
from ._container import Compose, RandomApply, RandomChoice, RandomOrder # usort: skip
from ._geometry import Resize, RandomResize, HorizontalFlip, Crop, CenterCrop, RandomCrop
from ._misc import Identity, Normalize
from ._presets import CocoEval, ImageNetEval, VocEval, Kinect400Eval, RaftEval
90 changes: 0 additions & 90 deletions torchvision/prototype/transforms/_container.py

This file was deleted.

138 changes: 0 additions & 138 deletions torchvision/prototype/transforms/_geometry.py

This file was deleted.

39 changes: 0 additions & 39 deletions torchvision/prototype/transforms/_misc.py

This file was deleted.

Loading