Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
vision
Commits
fd5109a0
Unverified
Commit
fd5109a0
authored
Feb 14, 2022
by
Philip Meier
Committed by
GitHub
Feb 14, 2022
Browse files
Cleanup prototype kernel dispatchers (#5417)
* add all legacy kernels * clarify dispatcher docstrings
parent
9ae0169d
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
145 additions
and
19 deletions
+145
-19
torchvision/prototype/transforms/functional/_augment.py
torchvision/prototype/transforms/functional/_augment.py
+2
-2
torchvision/prototype/transforms/functional/_color.py
torchvision/prototype/transforms/functional/_color.py
+33
-9
torchvision/prototype/transforms/functional/_geometry.py
torchvision/prototype/transforms/functional/_geometry.py
+78
-6
torchvision/prototype/transforms/functional/_misc.py
torchvision/prototype/transforms/functional/_misc.py
+14
-1
torchvision/prototype/transforms/kernels/__init__.py
torchvision/prototype/transforms/kernels/__init__.py
+9
-1
torchvision/prototype/transforms/kernels/_color.py
torchvision/prototype/transforms/kernels/_color.py
+2
-0
torchvision/prototype/transforms/kernels/_geometry.py
torchvision/prototype/transforms/kernels/_geometry.py
+6
-0
torchvision/prototype/transforms/kernels/_misc.py
torchvision/prototype/transforms/kernels/_misc.py
+1
-0
No files found.
torchvision/prototype/transforms/functional/_augment.py
View file @
fd5109a0
...
...
@@ -17,7 +17,7 @@ T = TypeVar("T", bound=features._Feature)
}
)
def
erase
(
input
:
T
,
*
args
:
Any
,
**
kwargs
:
Any
)
->
T
:
"""
ADDME
"""
"""
TODO: add docstring
"""
...
...
...
@@ -28,7 +28,7 @@ def erase(input: T, *args: Any, **kwargs: Any) -> T:
}
)
def
mixup
(
input
:
T
,
*
args
:
Any
,
**
kwargs
:
Any
)
->
T
:
"""
ADDME
"""
"""
TODO: add docstring
"""
...
...
...
torchvision/prototype/transforms/functional/_color.py
View file @
fd5109a0
...
...
@@ -19,7 +19,7 @@ T = TypeVar("T", bound=features._Feature)
}
)
def
adjust_brightness
(
input
:
T
,
*
args
:
Any
,
**
kwargs
:
Any
)
->
T
:
"""
ADDME
"""
"""
TODO: add docstring
"""
...
...
...
@@ -31,7 +31,7 @@ def adjust_brightness(input: T, *args: Any, **kwargs: Any) -> T:
}
)
def
adjust_saturation
(
input
:
T
,
*
args
:
Any
,
**
kwargs
:
Any
)
->
T
:
"""
ADDME
"""
"""
TODO: add docstring
"""
...
...
...
@@ -43,7 +43,7 @@ def adjust_saturation(input: T, *args: Any, **kwargs: Any) -> T:
}
)
def
adjust_contrast
(
input
:
T
,
*
args
:
Any
,
**
kwargs
:
Any
)
->
T
:
"""
ADDME
"""
"""
TODO: add docstring
"""
...
...
...
@@ -55,7 +55,7 @@ def adjust_contrast(input: T, *args: Any, **kwargs: Any) -> T:
}
)
def
adjust_sharpness
(
input
:
T
,
*
args
:
Any
,
**
kwargs
:
Any
)
->
T
:
"""
ADDME
"""
"""
TODO: add docstring
"""
...
...
...
@@ -67,7 +67,7 @@ def adjust_sharpness(input: T, *args: Any, **kwargs: Any) -> T:
}
)
def
posterize
(
input
:
T
,
*
args
:
Any
,
**
kwargs
:
Any
)
->
T
:
"""
ADDME
"""
"""
TODO: add docstring
"""
...
...
...
@@ -79,7 +79,7 @@ def posterize(input: T, *args: Any, **kwargs: Any) -> T:
}
)
def
solarize
(
input
:
T
,
*
args
:
Any
,
**
kwargs
:
Any
)
->
T
:
"""
ADDME
"""
"""
TODO: add docstring
"""
...
...
...
@@ -91,7 +91,7 @@ def solarize(input: T, *args: Any, **kwargs: Any) -> T:
}
)
def
autocontrast
(
input
:
T
,
*
args
:
Any
,
**
kwargs
:
Any
)
->
T
:
"""
ADDME
"""
"""
TODO: add docstring
"""
...
...
...
@@ -103,7 +103,7 @@ def autocontrast(input: T, *args: Any, **kwargs: Any) -> T:
}
)
def
equalize
(
input
:
T
,
*
args
:
Any
,
**
kwargs
:
Any
)
->
T
:
"""
ADDME
"""
"""
TODO: add docstring
"""
...
...
...
@@ -115,5 +115,29 @@ def equalize(input: T, *args: Any, **kwargs: Any) -> T:
}
)
def
invert
(
input
:
T
,
*
args
:
Any
,
**
kwargs
:
Any
)
->
T
:
"""ADDME"""
"""TODO: add docstring"""
...
@
dispatch
(
{
torch
.
Tensor
:
_F
.
adjust_hue
,
PIL
.
Image
.
Image
:
_F
.
adjust_hue
,
features
.
Image
:
K
.
adjust_hue_image
,
}
)
def
adjust_hue
(
input
:
T
,
*
args
:
Any
,
**
kwargs
:
Any
)
->
T
:
"""TODO: add docstring"""
...
@
dispatch
(
{
torch
.
Tensor
:
_F
.
adjust_gamma
,
PIL
.
Image
.
Image
:
_F
.
adjust_gamma
,
features
.
Image
:
K
.
adjust_gamma_image
,
}
)
def
adjust_gamma
(
input
:
T
,
*
args
:
Any
,
**
kwargs
:
Any
)
->
T
:
"""TODO: add docstring"""
...
torchvision/prototype/transforms/functional/_geometry.py
View file @
fd5109a0
...
...
@@ -20,7 +20,7 @@ T = TypeVar("T", bound=features._Feature)
},
)
def
horizontal_flip
(
input
:
T
,
*
args
:
Any
,
**
kwargs
:
Any
)
->
T
:
"""
ADDME
"""
"""
TODO: add docstring
"""
if
isinstance
(
input
,
features
.
BoundingBox
):
output
=
K
.
horizontal_flip_bounding_box
(
input
,
format
=
input
.
format
,
image_size
=
input
.
image_size
)
return
cast
(
T
,
features
.
BoundingBox
.
new_like
(
input
,
output
))
...
...
@@ -38,7 +38,7 @@ def horizontal_flip(input: T, *args: Any, **kwargs: Any) -> T:
}
)
def
resize
(
input
:
T
,
*
args
:
Any
,
**
kwargs
:
Any
)
->
T
:
"""
ADDME
"""
"""
TODO: add docstring
"""
if
isinstance
(
input
,
features
.
BoundingBox
):
size
=
kwargs
.
pop
(
"size"
)
output
=
K
.
resize_bounding_box
(
input
,
size
=
size
,
image_size
=
input
.
image_size
)
...
...
@@ -55,7 +55,7 @@ def resize(input: T, *args: Any, **kwargs: Any) -> T:
}
)
def
center_crop
(
input
:
T
,
*
args
:
Any
,
**
kwargs
:
Any
)
->
T
:
"""
ADDME
"""
"""
TODO: add docstring
"""
...
...
...
@@ -67,7 +67,7 @@ def center_crop(input: T, *args: Any, **kwargs: Any) -> T:
}
)
def
resized_crop
(
input
:
T
,
*
args
:
Any
,
**
kwargs
:
Any
)
->
T
:
"""
ADDME
"""
"""
TODO: add docstring
"""
...
...
...
@@ -79,7 +79,7 @@ def resized_crop(input: T, *args: Any, **kwargs: Any) -> T:
}
)
def
affine
(
input
:
T
,
*
args
:
Any
,
**
kwargs
:
Any
)
->
T
:
"""
ADDME
"""
"""
TODO: add docstring
"""
...
...
...
@@ -91,5 +91,77 @@ def affine(input: T, *args: Any, **kwargs: Any) -> T:
}
)
def
rotate
(
input
:
T
,
*
args
:
Any
,
**
kwargs
:
Any
)
->
T
:
"""ADDME"""
"""TODO: add docstring"""
...
@
dispatch
(
{
torch
.
Tensor
:
_F
.
pad
,
PIL
.
Image
.
Image
:
_F
.
pad
,
features
.
Image
:
K
.
pad_image
,
}
)
def
pad
(
input
:
T
,
*
args
:
Any
,
**
kwargs
:
Any
)
->
T
:
"""TODO: add docstring"""
...
@
dispatch
(
{
torch
.
Tensor
:
_F
.
crop
,
PIL
.
Image
.
Image
:
_F
.
crop
,
features
.
Image
:
K
.
crop_image
,
}
)
def
crop
(
input
:
T
,
*
args
:
Any
,
**
kwargs
:
Any
)
->
T
:
"""TODO: add docstring"""
...
@
dispatch
(
{
torch
.
Tensor
:
_F
.
perspective
,
PIL
.
Image
.
Image
:
_F
.
perspective
,
features
.
Image
:
K
.
perspective_image
,
}
)
def
perspective
(
input
:
T
,
*
args
:
Any
,
**
kwargs
:
Any
)
->
T
:
"""TODO: add docstring"""
...
@
dispatch
(
{
torch
.
Tensor
:
_F
.
vflip
,
PIL
.
Image
.
Image
:
_F
.
vflip
,
features
.
Image
:
K
.
vertical_flip_image
,
}
)
def
vertical_flip
(
input
:
T
,
*
args
:
Any
,
**
kwargs
:
Any
)
->
T
:
"""TODO: add docstring"""
...
@
dispatch
(
{
torch
.
Tensor
:
_F
.
five_crop
,
PIL
.
Image
.
Image
:
_F
.
five_crop
,
features
.
Image
:
K
.
five_crop_image
,
}
)
def
five_crop
(
input
:
T
,
*
args
:
Any
,
**
kwargs
:
Any
)
->
T
:
"""TODO: add docstring"""
...
@
dispatch
(
{
torch
.
Tensor
:
_F
.
ten_crop
,
PIL
.
Image
.
Image
:
_F
.
ten_crop
,
features
.
Image
:
K
.
ten_crop_image
,
}
)
def
ten_crop
(
input
:
T
,
*
args
:
Any
,
**
kwargs
:
Any
)
->
T
:
"""TODO: add docstring"""
...
torchvision/prototype/transforms/functional/_misc.py
View file @
fd5109a0
from
typing
import
TypeVar
,
Any
import
PIL.Image
import
torch
from
torchvision.prototype
import
features
from
torchvision.prototype.transforms
import
kernels
as
K
...
...
@@ -17,5 +18,17 @@ T = TypeVar("T", bound=features._Feature)
}
)
def
normalize
(
input
:
T
,
*
args
:
Any
,
**
kwargs
:
Any
)
->
T
:
"""ADDME"""
"""TODO: add docstring"""
...
@
dispatch
(
{
torch
.
Tensor
:
_F
.
gaussian_blur
,
PIL
.
Image
.
Image
:
_F
.
gaussian_blur
,
features
.
Image
:
K
.
gaussian_blur_image
,
}
)
def
ten_gaussian_blur
(
input
:
T
,
*
args
:
Any
,
**
kwargs
:
Any
)
->
T
:
"""TODO: add docstring"""
...
torchvision/prototype/transforms/kernels/__init__.py
View file @
fd5109a0
...
...
@@ -18,6 +18,8 @@ from ._color import (
autocontrast_image
,
equalize_image
,
invert_image
,
adjust_hue_image
,
adjust_gamma_image
,
)
from
._geometry
import
(
horizontal_flip_bounding_box
,
...
...
@@ -29,6 +31,12 @@ from ._geometry import (
resized_crop_image
,
affine_image
,
rotate_image
,
pad_image
,
crop_image
,
perspective_image
,
vertical_flip_image
,
five_crop_image
,
ten_crop_image
,
)
from
._misc
import
normalize_image
from
._misc
import
normalize_image
,
gaussian_blur_image
from
._type_conversion
import
decode_image_with_pil
,
decode_video_with_av
,
label_to_one_hot
torchvision/prototype/transforms/kernels/_color.py
View file @
fd5109a0
...
...
@@ -10,3 +10,5 @@ solarize_image = _F.solarize
autocontrast_image
=
_F
.
autocontrast
equalize_image
=
_F
.
equalize
invert_image
=
_F
.
invert
adjust_hue_image
=
_F
.
adjust_hue
adjust_gamma_image
=
_F
.
adjust_gamma
torchvision/prototype/transforms/kernels/_geometry.py
View file @
fd5109a0
...
...
@@ -68,3 +68,9 @@ center_crop_image = _F.center_crop
resized_crop_image
=
_F
.
resized_crop
affine_image
=
_F
.
affine
rotate_image
=
_F
.
rotate
pad_image
=
_F
.
pad
crop_image
=
_F
.
crop
perspective_image
=
_F
.
perspective
vertical_flip_image
=
_F
.
vflip
five_crop_image
=
_F
.
five_crop
ten_crop_image
=
_F
.
ten_crop
torchvision/prototype/transforms/kernels/_misc.py
View file @
fd5109a0
...
...
@@ -2,3 +2,4 @@ from torchvision.transforms import functional as _F
normalize_image
=
_F
.
normalize
gaussian_blur_image
=
_F
.
gaussian_blur
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment