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
1c1cd68b
"git@developer.sourcefind.cn:OpenDAS/ollama.git" did not exist on "abed273de3a6183d734f0f3f0f129d7bd08ac4b4"
Unverified
Commit
1c1cd68b
authored
Jun 28, 2023
by
Philip Meier
Committed by
GitHub
Jun 28, 2023
Browse files
undeprecate to_grayscale (#7707)
parent
25c8a3a2
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
9 additions
and
12 deletions
+9
-12
test/test_transforms_v2_functional.py
test/test_transforms_v2_functional.py
+1
-0
torchvision/transforms/functional.py
torchvision/transforms/functional.py
+1
-1
torchvision/transforms/v2/functional/__init__.py
torchvision/transforms/v2/functional/__init__.py
+2
-1
torchvision/transforms/v2/functional/_color.py
torchvision/transforms/v2/functional/_color.py
+5
-0
torchvision/transforms/v2/functional/_deprecated.py
torchvision/transforms/v2/functional/_deprecated.py
+0
-10
No files found.
test/test_transforms_v2_functional.py
View file @
1c1cd68b
...
@@ -539,6 +539,7 @@ class TestDispatchers:
...
@@ -539,6 +539,7 @@ class TestDispatchers:
(
F
.
to_pil_image
,
F
.
to_image_pil
),
(
F
.
to_pil_image
,
F
.
to_image_pil
),
(
F
.
elastic_transform
,
F
.
elastic
),
(
F
.
elastic_transform
,
F
.
elastic
),
(
F
.
convert_image_dtype
,
F
.
convert_dtype_image_tensor
),
(
F
.
convert_image_dtype
,
F
.
convert_dtype_image_tensor
),
(
F
.
to_grayscale
,
F
.
rgb_to_grayscale
),
]
]
],
],
)
)
...
...
torchvision/transforms/functional.py
View file @
1c1cd68b
...
@@ -1248,7 +1248,7 @@ def affine(
...
@@ -1248,7 +1248,7 @@ def affine(
# Looks like to_grayscale() is a stand-alone functional that is never called
# Looks like to_grayscale() is a stand-alone functional that is never called
# from the transform classes. Perhaps it's still here for BC? I can't be
# from the transform classes. Perhaps it's still here for BC? I can't be
# bothered to dig.
Anyway, this can be deprecated as we migrate to V2.
# bothered to dig.
@
torch
.
jit
.
unused
@
torch
.
jit
.
unused
def
to_grayscale
(
img
,
num_output_channels
=
1
):
def
to_grayscale
(
img
,
num_output_channels
=
1
):
"""Convert PIL image of any mode (RGB, HSV, LAB, etc) to grayscale version of image.
"""Convert PIL image of any mode (RGB, HSV, LAB, etc) to grayscale version of image.
...
...
torchvision/transforms/v2/functional/__init__.py
View file @
1c1cd68b
...
@@ -76,6 +76,7 @@ from ._color import (
...
@@ -76,6 +76,7 @@ from ._color import (
solarize_image_pil
,
solarize_image_pil
,
solarize_image_tensor
,
solarize_image_tensor
,
solarize_video
,
solarize_video
,
to_grayscale
,
)
)
from
._geometry
import
(
from
._geometry
import
(
affine
,
affine
,
...
@@ -168,4 +169,4 @@ from ._misc import (
...
@@ -168,4 +169,4 @@ from ._misc import (
from
._temporal
import
uniform_temporal_subsample
,
uniform_temporal_subsample_video
from
._temporal
import
uniform_temporal_subsample
,
uniform_temporal_subsample_video
from
._type_conversion
import
pil_to_tensor
,
to_image_pil
,
to_image_tensor
,
to_pil_image
from
._type_conversion
import
pil_to_tensor
,
to_image_pil
,
to_image_tensor
,
to_pil_image
from
._deprecated
import
get_image_size
,
to_grayscale
,
to_tensor
# usort: skip
from
._deprecated
import
get_image_size
,
to_tensor
# usort: skip
torchvision/transforms/v2/functional/_color.py
View file @
1c1cd68b
...
@@ -56,6 +56,11 @@ def rgb_to_grayscale(
...
@@ -56,6 +56,11 @@ def rgb_to_grayscale(
)
)
# `to_grayscale` actually predates `rgb_to_grayscale` in v1, but only handles PIL images. Since `rgb_to_grayscale` is a
# superset in terms of functionality and has the same signature, we alias here to avoid disruption.
to_grayscale
=
rgb_to_grayscale
def
_blend
(
image1
:
torch
.
Tensor
,
image2
:
torch
.
Tensor
,
ratio
:
float
)
->
torch
.
Tensor
:
def
_blend
(
image1
:
torch
.
Tensor
,
image2
:
torch
.
Tensor
,
ratio
:
float
)
->
torch
.
Tensor
:
ratio
=
float
(
ratio
)
ratio
=
float
(
ratio
)
fp
=
image1
.
is_floating_point
()
fp
=
image1
.
is_floating_point
()
...
...
torchvision/transforms/v2/functional/_deprecated.py
View file @
1c1cd68b
import
warnings
import
warnings
from
typing
import
Any
,
List
,
Union
from
typing
import
Any
,
List
,
Union
import
PIL.Image
import
torch
import
torch
from
torchvision
import
datapoints
from
torchvision
import
datapoints
from
torchvision.transforms
import
functional
as
_F
from
torchvision.transforms
import
functional
as
_F
@
torch
.
jit
.
unused
def
to_grayscale
(
inpt
:
PIL
.
Image
.
Image
,
num_output_channels
:
int
=
1
)
->
PIL
.
Image
.
Image
:
warnings
.
warn
(
"The function `to_grayscale` is deprecated in will be removed in a future release. "
"Instead, please use `rgb_to_grayscale`."
,
)
return
_F
.
to_grayscale
(
inpt
,
num_output_channels
=
num_output_channels
)
@
torch
.
jit
.
unused
@
torch
.
jit
.
unused
def
to_tensor
(
inpt
:
Any
)
->
torch
.
Tensor
:
def
to_tensor
(
inpt
:
Any
)
->
torch
.
Tensor
:
warnings
.
warn
(
warnings
.
warn
(
...
...
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