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
d4d20f01
".github/vscode:/vscode.git/clone" did not exist on "f5d7635e11fa858ca6a41313ebf1b74409d8ac62"
Unverified
Commit
d4d20f01
authored
Feb 16, 2023
by
Philip Meier
Committed by
GitHub
Feb 16, 2023
Browse files
make type alias private (#7266)
parent
e405f3c3
Changes
24
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
96 additions
and
96 deletions
+96
-96
torchvision/datapoints/__init__.py
torchvision/datapoints/__init__.py
+3
-3
torchvision/datapoints/_bounding_box.py
torchvision/datapoints/_bounding_box.py
+5
-5
torchvision/datapoints/_datapoint.py
torchvision/datapoints/_datapoint.py
+8
-8
torchvision/datapoints/_image.py
torchvision/datapoints/_image.py
+9
-9
torchvision/datapoints/_mask.py
torchvision/datapoints/_mask.py
+5
-5
torchvision/datapoints/_video.py
torchvision/datapoints/_video.py
+9
-9
torchvision/prototype/transforms/_augment.py
torchvision/prototype/transforms/_augment.py
+5
-5
torchvision/prototype/transforms/_geometry.py
torchvision/prototype/transforms/_geometry.py
+1
-1
torchvision/prototype/transforms/_misc.py
torchvision/prototype/transforms/_misc.py
+2
-2
torchvision/transforms/v2/_augment.py
torchvision/transforms/v2/_augment.py
+2
-2
torchvision/transforms/v2/_auto_augment.py
torchvision/transforms/v2/_auto_augment.py
+10
-10
torchvision/transforms/v2/_color.py
torchvision/transforms/v2/_color.py
+4
-4
torchvision/transforms/v2/_geometry.py
torchvision/transforms/v2/_geometry.py
+9
-9
torchvision/transforms/v2/_meta.py
torchvision/transforms/v2/_meta.py
+2
-2
torchvision/transforms/v2/_misc.py
torchvision/transforms/v2/_misc.py
+1
-1
torchvision/transforms/v2/_temporal.py
torchvision/transforms/v2/_temporal.py
+1
-1
torchvision/transforms/v2/_utils.py
torchvision/transforms/v2/_utils.py
+4
-4
torchvision/transforms/v2/functional/_augment.py
torchvision/transforms/v2/functional/_augment.py
+2
-2
torchvision/transforms/v2/functional/_color.py
torchvision/transforms/v2/functional/_color.py
+13
-13
torchvision/transforms/v2/functional/_deprecated.py
torchvision/transforms/v2/functional/_deprecated.py
+1
-1
No files found.
torchvision/datapoints/__init__.py
View file @
d4d20f01
from
._bounding_box
import
BoundingBox
,
BoundingBoxFormat
from
._datapoint
import
FillType
,
FillTypeJIT
,
InputType
,
InputTypeJIT
from
._image
import
Image
,
ImageType
,
ImageTypeJIT
,
TensorImageType
,
TensorImageTypeJIT
from
._datapoint
import
_
FillType
,
_
FillTypeJIT
,
_
InputType
,
_
InputTypeJIT
from
._image
import
_
ImageType
,
_
ImageTypeJIT
,
_
TensorImageType
,
_
TensorImageTypeJIT
,
Image
from
._mask
import
Mask
from
._video
import
TensorVideoType
,
TensorVideoTypeJIT
,
Video
,
VideoType
,
VideoTypeJIT
from
._video
import
_
TensorVideoType
,
_
TensorVideoTypeJIT
,
_
VideoType
,
_
VideoTypeJIT
,
Video
from
._dataset_wrapper
import
wrap_dataset_for_transforms_v2
# type: ignore[attr-defined] # usort: skip
torchvision/datapoints/_bounding_box.py
View file @
d4d20f01
...
...
@@ -6,7 +6,7 @@ import torch
from
torchvision._utils
import
StrEnum
from
torchvision.transforms
import
InterpolationMode
# TODO: this needs to be moved out of transforms
from
._datapoint
import
Datapoint
,
FillTypeJIT
from
._datapoint
import
_FillTypeJIT
,
Datapoint
class
BoundingBoxFormat
(
StrEnum
):
...
...
@@ -136,7 +136,7 @@ class BoundingBox(Datapoint):
interpolation
:
Union
[
InterpolationMode
,
int
]
=
InterpolationMode
.
NEAREST
,
expand
:
bool
=
False
,
center
:
Optional
[
List
[
float
]]
=
None
,
fill
:
FillTypeJIT
=
None
,
fill
:
_
FillTypeJIT
=
None
,
)
->
BoundingBox
:
output
,
spatial_size
=
self
.
_F
.
rotate_bounding_box
(
self
.
as_subclass
(
torch
.
Tensor
),
...
...
@@ -155,7 +155,7 @@ class BoundingBox(Datapoint):
scale
:
float
,
shear
:
List
[
float
],
interpolation
:
Union
[
InterpolationMode
,
int
]
=
InterpolationMode
.
NEAREST
,
fill
:
FillTypeJIT
=
None
,
fill
:
_
FillTypeJIT
=
None
,
center
:
Optional
[
List
[
float
]]
=
None
,
)
->
BoundingBox
:
output
=
self
.
_F
.
affine_bounding_box
(
...
...
@@ -175,7 +175,7 @@ class BoundingBox(Datapoint):
startpoints
:
Optional
[
List
[
List
[
int
]]],
endpoints
:
Optional
[
List
[
List
[
int
]]],
interpolation
:
Union
[
InterpolationMode
,
int
]
=
InterpolationMode
.
BILINEAR
,
fill
:
FillTypeJIT
=
None
,
fill
:
_
FillTypeJIT
=
None
,
coefficients
:
Optional
[
List
[
float
]]
=
None
,
)
->
BoundingBox
:
output
=
self
.
_F
.
perspective_bounding_box
(
...
...
@@ -192,7 +192,7 @@ class BoundingBox(Datapoint):
self
,
displacement
:
torch
.
Tensor
,
interpolation
:
Union
[
InterpolationMode
,
int
]
=
InterpolationMode
.
BILINEAR
,
fill
:
FillTypeJIT
=
None
,
fill
:
_
FillTypeJIT
=
None
,
)
->
BoundingBox
:
output
=
self
.
_F
.
elastic_bounding_box
(
self
.
as_subclass
(
torch
.
Tensor
),
self
.
format
,
self
.
spatial_size
,
displacement
=
displacement
...
...
torchvision/datapoints/_datapoint.py
View file @
d4d20f01
...
...
@@ -11,8 +11,8 @@ from torchvision.transforms import InterpolationMode
D
=
TypeVar
(
"D"
,
bound
=
"Datapoint"
)
FillType
=
Union
[
int
,
float
,
Sequence
[
int
],
Sequence
[
float
],
None
]
FillTypeJIT
=
Optional
[
List
[
float
]]
_
FillType
=
Union
[
int
,
float
,
Sequence
[
int
],
Sequence
[
float
],
None
]
_
FillTypeJIT
=
Optional
[
List
[
float
]]
class
Datapoint
(
torch
.
Tensor
):
...
...
@@ -181,7 +181,7 @@ class Datapoint(torch.Tensor):
interpolation
:
Union
[
InterpolationMode
,
int
]
=
InterpolationMode
.
NEAREST
,
expand
:
bool
=
False
,
center
:
Optional
[
List
[
float
]]
=
None
,
fill
:
FillTypeJIT
=
None
,
fill
:
_
FillTypeJIT
=
None
,
)
->
Datapoint
:
return
self
...
...
@@ -192,7 +192,7 @@ class Datapoint(torch.Tensor):
scale
:
float
,
shear
:
List
[
float
],
interpolation
:
Union
[
InterpolationMode
,
int
]
=
InterpolationMode
.
NEAREST
,
fill
:
FillTypeJIT
=
None
,
fill
:
_
FillTypeJIT
=
None
,
center
:
Optional
[
List
[
float
]]
=
None
,
)
->
Datapoint
:
return
self
...
...
@@ -202,7 +202,7 @@ class Datapoint(torch.Tensor):
startpoints
:
Optional
[
List
[
List
[
int
]]],
endpoints
:
Optional
[
List
[
List
[
int
]]],
interpolation
:
Union
[
InterpolationMode
,
int
]
=
InterpolationMode
.
BILINEAR
,
fill
:
FillTypeJIT
=
None
,
fill
:
_
FillTypeJIT
=
None
,
coefficients
:
Optional
[
List
[
float
]]
=
None
,
)
->
Datapoint
:
return
self
...
...
@@ -211,7 +211,7 @@ class Datapoint(torch.Tensor):
self
,
displacement
:
torch
.
Tensor
,
interpolation
:
Union
[
InterpolationMode
,
int
]
=
InterpolationMode
.
BILINEAR
,
fill
:
FillTypeJIT
=
None
,
fill
:
_
FillTypeJIT
=
None
,
)
->
Datapoint
:
return
self
...
...
@@ -255,5 +255,5 @@ class Datapoint(torch.Tensor):
return
self
InputType
=
Union
[
torch
.
Tensor
,
PIL
.
Image
.
Image
,
Datapoint
]
InputTypeJIT
=
torch
.
Tensor
_
InputType
=
Union
[
torch
.
Tensor
,
PIL
.
Image
.
Image
,
Datapoint
]
_
InputTypeJIT
=
torch
.
Tensor
torchvision/datapoints/_image.py
View file @
d4d20f01
...
...
@@ -6,7 +6,7 @@ import PIL.Image
import
torch
from
torchvision.transforms.functional
import
InterpolationMode
from
._datapoint
import
Datapoint
,
FillTypeJIT
from
._datapoint
import
_FillTypeJIT
,
Datapoint
class
Image
(
Datapoint
):
...
...
@@ -116,7 +116,7 @@ class Image(Datapoint):
interpolation
:
Union
[
InterpolationMode
,
int
]
=
InterpolationMode
.
NEAREST
,
expand
:
bool
=
False
,
center
:
Optional
[
List
[
float
]]
=
None
,
fill
:
FillTypeJIT
=
None
,
fill
:
_
FillTypeJIT
=
None
,
)
->
Image
:
output
=
self
.
_F
.
rotate_image_tensor
(
self
.
as_subclass
(
torch
.
Tensor
),
angle
,
interpolation
=
interpolation
,
expand
=
expand
,
fill
=
fill
,
center
=
center
...
...
@@ -130,7 +130,7 @@ class Image(Datapoint):
scale
:
float
,
shear
:
List
[
float
],
interpolation
:
Union
[
InterpolationMode
,
int
]
=
InterpolationMode
.
NEAREST
,
fill
:
FillTypeJIT
=
None
,
fill
:
_
FillTypeJIT
=
None
,
center
:
Optional
[
List
[
float
]]
=
None
,
)
->
Image
:
output
=
self
.
_F
.
affine_image_tensor
(
...
...
@@ -150,7 +150,7 @@ class Image(Datapoint):
startpoints
:
Optional
[
List
[
List
[
int
]]],
endpoints
:
Optional
[
List
[
List
[
int
]]],
interpolation
:
Union
[
InterpolationMode
,
int
]
=
InterpolationMode
.
BILINEAR
,
fill
:
FillTypeJIT
=
None
,
fill
:
_
FillTypeJIT
=
None
,
coefficients
:
Optional
[
List
[
float
]]
=
None
,
)
->
Image
:
output
=
self
.
_F
.
perspective_image_tensor
(
...
...
@@ -167,7 +167,7 @@ class Image(Datapoint):
self
,
displacement
:
torch
.
Tensor
,
interpolation
:
Union
[
InterpolationMode
,
int
]
=
InterpolationMode
.
BILINEAR
,
fill
:
FillTypeJIT
=
None
,
fill
:
_
FillTypeJIT
=
None
,
)
->
Image
:
output
=
self
.
_F
.
elastic_image_tensor
(
self
.
as_subclass
(
torch
.
Tensor
),
displacement
,
interpolation
=
interpolation
,
fill
=
fill
...
...
@@ -241,7 +241,7 @@ class Image(Datapoint):
return
Image
.
wrap_like
(
self
,
output
)
ImageType
=
Union
[
torch
.
Tensor
,
PIL
.
Image
.
Image
,
Image
]
ImageTypeJIT
=
torch
.
Tensor
TensorImageType
=
Union
[
torch
.
Tensor
,
Image
]
TensorImageTypeJIT
=
torch
.
Tensor
_
ImageType
=
Union
[
torch
.
Tensor
,
PIL
.
Image
.
Image
,
Image
]
_
ImageTypeJIT
=
torch
.
Tensor
_
TensorImageType
=
Union
[
torch
.
Tensor
,
Image
]
_
TensorImageTypeJIT
=
torch
.
Tensor
torchvision/datapoints/_mask.py
View file @
d4d20f01
...
...
@@ -6,7 +6,7 @@ import PIL.Image
import
torch
from
torchvision.transforms
import
InterpolationMode
from
._datapoint
import
Datapoint
,
FillTypeJIT
from
._datapoint
import
_FillTypeJIT
,
Datapoint
class
Mask
(
Datapoint
):
...
...
@@ -96,7 +96,7 @@ class Mask(Datapoint):
interpolation
:
Union
[
InterpolationMode
,
int
]
=
InterpolationMode
.
NEAREST
,
expand
:
bool
=
False
,
center
:
Optional
[
List
[
float
]]
=
None
,
fill
:
FillTypeJIT
=
None
,
fill
:
_
FillTypeJIT
=
None
,
)
->
Mask
:
output
=
self
.
_F
.
rotate_mask
(
self
.
as_subclass
(
torch
.
Tensor
),
angle
,
expand
=
expand
,
center
=
center
,
fill
=
fill
)
return
Mask
.
wrap_like
(
self
,
output
)
...
...
@@ -108,7 +108,7 @@ class Mask(Datapoint):
scale
:
float
,
shear
:
List
[
float
],
interpolation
:
Union
[
InterpolationMode
,
int
]
=
InterpolationMode
.
NEAREST
,
fill
:
FillTypeJIT
=
None
,
fill
:
_
FillTypeJIT
=
None
,
center
:
Optional
[
List
[
float
]]
=
None
,
)
->
Mask
:
output
=
self
.
_F
.
affine_mask
(
...
...
@@ -127,7 +127,7 @@ class Mask(Datapoint):
startpoints
:
Optional
[
List
[
List
[
int
]]],
endpoints
:
Optional
[
List
[
List
[
int
]]],
interpolation
:
Union
[
InterpolationMode
,
int
]
=
InterpolationMode
.
NEAREST
,
fill
:
FillTypeJIT
=
None
,
fill
:
_
FillTypeJIT
=
None
,
coefficients
:
Optional
[
List
[
float
]]
=
None
,
)
->
Mask
:
output
=
self
.
_F
.
perspective_mask
(
...
...
@@ -139,7 +139,7 @@ class Mask(Datapoint):
self
,
displacement
:
torch
.
Tensor
,
interpolation
:
Union
[
InterpolationMode
,
int
]
=
InterpolationMode
.
NEAREST
,
fill
:
FillTypeJIT
=
None
,
fill
:
_
FillTypeJIT
=
None
,
)
->
Mask
:
output
=
self
.
_F
.
elastic_mask
(
self
.
as_subclass
(
torch
.
Tensor
),
displacement
,
fill
=
fill
)
return
Mask
.
wrap_like
(
self
,
output
)
torchvision/datapoints/_video.py
View file @
d4d20f01
...
...
@@ -5,7 +5,7 @@ from typing import Any, List, Optional, Tuple, Union
import
torch
from
torchvision.transforms.functional
import
InterpolationMode
from
._datapoint
import
Datapoint
,
FillTypeJIT
from
._datapoint
import
_FillTypeJIT
,
Datapoint
class
Video
(
Datapoint
):
...
...
@@ -115,7 +115,7 @@ class Video(Datapoint):
interpolation
:
Union
[
InterpolationMode
,
int
]
=
InterpolationMode
.
NEAREST
,
expand
:
bool
=
False
,
center
:
Optional
[
List
[
float
]]
=
None
,
fill
:
FillTypeJIT
=
None
,
fill
:
_
FillTypeJIT
=
None
,
)
->
Video
:
output
=
self
.
_F
.
rotate_video
(
self
.
as_subclass
(
torch
.
Tensor
),
angle
,
interpolation
=
interpolation
,
expand
=
expand
,
fill
=
fill
,
center
=
center
...
...
@@ -129,7 +129,7 @@ class Video(Datapoint):
scale
:
float
,
shear
:
List
[
float
],
interpolation
:
Union
[
InterpolationMode
,
int
]
=
InterpolationMode
.
NEAREST
,
fill
:
FillTypeJIT
=
None
,
fill
:
_
FillTypeJIT
=
None
,
center
:
Optional
[
List
[
float
]]
=
None
,
)
->
Video
:
output
=
self
.
_F
.
affine_video
(
...
...
@@ -149,7 +149,7 @@ class Video(Datapoint):
startpoints
:
Optional
[
List
[
List
[
int
]]],
endpoints
:
Optional
[
List
[
List
[
int
]]],
interpolation
:
Union
[
InterpolationMode
,
int
]
=
InterpolationMode
.
BILINEAR
,
fill
:
FillTypeJIT
=
None
,
fill
:
_
FillTypeJIT
=
None
,
coefficients
:
Optional
[
List
[
float
]]
=
None
,
)
->
Video
:
output
=
self
.
_F
.
perspective_video
(
...
...
@@ -166,7 +166,7 @@ class Video(Datapoint):
self
,
displacement
:
torch
.
Tensor
,
interpolation
:
Union
[
InterpolationMode
,
int
]
=
InterpolationMode
.
BILINEAR
,
fill
:
FillTypeJIT
=
None
,
fill
:
_
FillTypeJIT
=
None
,
)
->
Video
:
output
=
self
.
_F
.
elastic_video
(
self
.
as_subclass
(
torch
.
Tensor
),
displacement
,
interpolation
=
interpolation
,
fill
=
fill
...
...
@@ -232,7 +232,7 @@ class Video(Datapoint):
return
Video
.
wrap_like
(
self
,
output
)
VideoType
=
Union
[
torch
.
Tensor
,
Video
]
VideoTypeJIT
=
torch
.
Tensor
TensorVideoType
=
Union
[
torch
.
Tensor
,
Video
]
TensorVideoTypeJIT
=
torch
.
Tensor
_
VideoType
=
Union
[
torch
.
Tensor
,
Video
]
_
VideoTypeJIT
=
torch
.
Tensor
_
TensorVideoType
=
Union
[
torch
.
Tensor
,
Video
]
_
TensorVideoTypeJIT
=
torch
.
Tensor
torchvision/prototype/transforms/_augment.py
View file @
d4d20f01
...
...
@@ -119,15 +119,15 @@ class SimpleCopyPaste(Transform):
def
_copy_paste
(
self
,
image
:
datapoints
.
TensorImageType
,
image
:
datapoints
.
_
TensorImageType
,
target
:
Dict
[
str
,
Any
],
paste_image
:
datapoints
.
TensorImageType
,
paste_image
:
datapoints
.
_
TensorImageType
,
paste_target
:
Dict
[
str
,
Any
],
random_selection
:
torch
.
Tensor
,
blending
:
bool
,
resize_interpolation
:
F
.
InterpolationMode
,
antialias
:
Optional
[
bool
],
)
->
Tuple
[
datapoints
.
TensorImageType
,
Dict
[
str
,
Any
]]:
)
->
Tuple
[
datapoints
.
_
TensorImageType
,
Dict
[
str
,
Any
]]:
paste_masks
=
paste_target
[
"masks"
].
wrap_like
(
paste_target
[
"masks"
],
paste_target
[
"masks"
][
random_selection
])
paste_boxes
=
paste_target
[
"boxes"
].
wrap_like
(
paste_target
[
"boxes"
],
paste_target
[
"boxes"
][
random_selection
])
...
...
@@ -199,7 +199,7 @@ class SimpleCopyPaste(Transform):
def
_extract_image_targets
(
self
,
flat_sample
:
List
[
Any
]
)
->
Tuple
[
List
[
datapoints
.
TensorImageType
],
List
[
Dict
[
str
,
Any
]]]:
)
->
Tuple
[
List
[
datapoints
.
_
TensorImageType
],
List
[
Dict
[
str
,
Any
]]]:
# fetch all images, bboxes, masks and labels from unstructured input
# with List[image], List[BoundingBox], List[Mask], List[Label]
images
,
bboxes
,
masks
,
labels
=
[],
[],
[],
[]
...
...
@@ -230,7 +230,7 @@ class SimpleCopyPaste(Transform):
def
_insert_outputs
(
self
,
flat_sample
:
List
[
Any
],
output_images
:
List
[
datapoints
.
TensorImageType
],
output_images
:
List
[
datapoints
.
_
TensorImageType
],
output_targets
:
List
[
Dict
[
str
,
Any
]],
)
->
None
:
c0
,
c1
,
c2
,
c3
=
0
,
0
,
0
,
0
...
...
torchvision/prototype/transforms/_geometry.py
View file @
d4d20f01
...
...
@@ -14,7 +14,7 @@ class FixedSizeCrop(Transform):
def
__init__
(
self
,
size
:
Union
[
int
,
Sequence
[
int
]],
fill
:
Union
[
datapoints
.
FillType
,
Dict
[
Type
,
datapoints
.
FillType
]]
=
0
,
fill
:
Union
[
datapoints
.
_
FillType
,
Dict
[
Type
,
datapoints
.
_
FillType
]]
=
0
,
padding_mode
:
str
=
"constant"
,
)
->
None
:
super
().
__init__
()
...
...
torchvision/prototype/transforms/_misc.py
View file @
d4d20f01
...
...
@@ -26,7 +26,7 @@ class PermuteDimensions(Transform):
self
.
dims
=
dims
def
_transform
(
self
,
inpt
:
Union
[
datapoints
.
TensorImageType
,
datapoints
.
TensorVideoType
],
params
:
Dict
[
str
,
Any
]
self
,
inpt
:
Union
[
datapoints
.
_
TensorImageType
,
datapoints
.
_
TensorVideoType
],
params
:
Dict
[
str
,
Any
]
)
->
torch
.
Tensor
:
dims
=
self
.
dims
[
type
(
inpt
)]
if
dims
is
None
:
...
...
@@ -50,7 +50,7 @@ class TransposeDimensions(Transform):
self
.
dims
=
dims
def
_transform
(
self
,
inpt
:
Union
[
datapoints
.
TensorImageType
,
datapoints
.
TensorVideoType
],
params
:
Dict
[
str
,
Any
]
self
,
inpt
:
Union
[
datapoints
.
_
TensorImageType
,
datapoints
.
_
TensorVideoType
],
params
:
Dict
[
str
,
Any
]
)
->
torch
.
Tensor
:
dims
=
self
.
dims
[
type
(
inpt
)]
if
dims
is
None
:
...
...
torchvision/transforms/v2/_augment.py
View file @
d4d20f01
...
...
@@ -97,8 +97,8 @@ class RandomErasing(_RandomApplyTransform):
return
dict
(
i
=
i
,
j
=
j
,
h
=
h
,
w
=
w
,
v
=
v
)
def
_transform
(
self
,
inpt
:
Union
[
datapoints
.
ImageType
,
datapoints
.
VideoType
],
params
:
Dict
[
str
,
Any
]
)
->
Union
[
datapoints
.
ImageType
,
datapoints
.
VideoType
]:
self
,
inpt
:
Union
[
datapoints
.
_
ImageType
,
datapoints
.
_
VideoType
],
params
:
Dict
[
str
,
Any
]
)
->
Union
[
datapoints
.
_
ImageType
,
datapoints
.
_
VideoType
]:
if
params
[
"v"
]
is
not
None
:
inpt
=
F
.
erase
(
inpt
,
**
params
,
inplace
=
self
.
inplace
)
...
...
torchvision/transforms/v2/_auto_augment.py
View file @
d4d20f01
...
...
@@ -20,7 +20,7 @@ class _AutoAugmentBase(Transform):
self
,
*
,
interpolation
:
Union
[
InterpolationMode
,
int
]
=
InterpolationMode
.
NEAREST
,
fill
:
Union
[
datapoints
.
FillType
,
Dict
[
Type
,
datapoints
.
FillType
]]
=
None
,
fill
:
Union
[
datapoints
.
_
FillType
,
Dict
[
Type
,
datapoints
.
_
FillType
]]
=
None
,
)
->
None
:
super
().
__init__
()
self
.
interpolation
=
_check_interpolation
(
interpolation
)
...
...
@@ -35,7 +35,7 @@ class _AutoAugmentBase(Transform):
self
,
inputs
:
Any
,
unsupported_types
:
Tuple
[
Type
,
...]
=
(
datapoints
.
BoundingBox
,
datapoints
.
Mask
),
)
->
Tuple
[
Tuple
[
List
[
Any
],
TreeSpec
,
int
],
Union
[
datapoints
.
ImageType
,
datapoints
.
VideoType
]]:
)
->
Tuple
[
Tuple
[
List
[
Any
],
TreeSpec
,
int
],
Union
[
datapoints
.
_
ImageType
,
datapoints
.
_
VideoType
]]:
flat_inputs
,
spec
=
tree_flatten
(
inputs
if
len
(
inputs
)
>
1
else
inputs
[
0
])
needs_transform_list
=
self
.
_needs_transform_list
(
flat_inputs
)
...
...
@@ -68,7 +68,7 @@ class _AutoAugmentBase(Transform):
def
_unflatten_and_insert_image_or_video
(
self
,
flat_inputs_with_spec
:
Tuple
[
List
[
Any
],
TreeSpec
,
int
],
image_or_video
:
Union
[
datapoints
.
ImageType
,
datapoints
.
VideoType
],
image_or_video
:
Union
[
datapoints
.
_
ImageType
,
datapoints
.
_
VideoType
],
)
->
Any
:
flat_inputs
,
spec
,
idx
=
flat_inputs_with_spec
flat_inputs
[
idx
]
=
image_or_video
...
...
@@ -76,12 +76,12 @@ class _AutoAugmentBase(Transform):
def
_apply_image_or_video_transform
(
self
,
image
:
Union
[
datapoints
.
ImageType
,
datapoints
.
VideoType
],
image
:
Union
[
datapoints
.
_
ImageType
,
datapoints
.
_
VideoType
],
transform_id
:
str
,
magnitude
:
float
,
interpolation
:
Union
[
InterpolationMode
,
int
],
fill
:
Dict
[
Type
,
datapoints
.
FillTypeJIT
],
)
->
Union
[
datapoints
.
ImageType
,
datapoints
.
VideoType
]:
fill
:
Dict
[
Type
,
datapoints
.
_
FillTypeJIT
],
)
->
Union
[
datapoints
.
_
ImageType
,
datapoints
.
_
VideoType
]:
fill_
=
fill
[
type
(
image
)]
if
transform_id
==
"Identity"
:
...
...
@@ -194,7 +194,7 @@ class AutoAugment(_AutoAugmentBase):
self
,
policy
:
AutoAugmentPolicy
=
AutoAugmentPolicy
.
IMAGENET
,
interpolation
:
Union
[
InterpolationMode
,
int
]
=
InterpolationMode
.
NEAREST
,
fill
:
Union
[
datapoints
.
FillType
,
Dict
[
Type
,
datapoints
.
FillType
]]
=
None
,
fill
:
Union
[
datapoints
.
_
FillType
,
Dict
[
Type
,
datapoints
.
_
FillType
]]
=
None
,
)
->
None
:
super
().
__init__
(
interpolation
=
interpolation
,
fill
=
fill
)
self
.
policy
=
policy
...
...
@@ -351,7 +351,7 @@ class RandAugment(_AutoAugmentBase):
magnitude
:
int
=
9
,
num_magnitude_bins
:
int
=
31
,
interpolation
:
Union
[
InterpolationMode
,
int
]
=
InterpolationMode
.
NEAREST
,
fill
:
Union
[
datapoints
.
FillType
,
Dict
[
Type
,
datapoints
.
FillType
]]
=
None
,
fill
:
Union
[
datapoints
.
_
FillType
,
Dict
[
Type
,
datapoints
.
_
FillType
]]
=
None
,
)
->
None
:
super
().
__init__
(
interpolation
=
interpolation
,
fill
=
fill
)
self
.
num_ops
=
num_ops
...
...
@@ -404,7 +404,7 @@ class TrivialAugmentWide(_AutoAugmentBase):
self
,
num_magnitude_bins
:
int
=
31
,
interpolation
:
Union
[
InterpolationMode
,
int
]
=
InterpolationMode
.
NEAREST
,
fill
:
Union
[
datapoints
.
FillType
,
Dict
[
Type
,
datapoints
.
FillType
]]
=
None
,
fill
:
Union
[
datapoints
.
_
FillType
,
Dict
[
Type
,
datapoints
.
_
FillType
]]
=
None
,
):
super
().
__init__
(
interpolation
=
interpolation
,
fill
=
fill
)
self
.
num_magnitude_bins
=
num_magnitude_bins
...
...
@@ -462,7 +462,7 @@ class AugMix(_AutoAugmentBase):
alpha
:
float
=
1.0
,
all_ops
:
bool
=
True
,
interpolation
:
Union
[
InterpolationMode
,
int
]
=
InterpolationMode
.
BILINEAR
,
fill
:
Union
[
datapoints
.
FillType
,
Dict
[
Type
,
datapoints
.
FillType
]]
=
None
,
fill
:
Union
[
datapoints
.
_
FillType
,
Dict
[
Type
,
datapoints
.
_
FillType
]]
=
None
,
)
->
None
:
super
().
__init__
(
interpolation
=
interpolation
,
fill
=
fill
)
self
.
_PARAMETER_MAX
=
10
...
...
torchvision/transforms/v2/_color.py
View file @
d4d20f01
...
...
@@ -163,8 +163,8 @@ class RandomPhotometricDistort(Transform):
)
def
_permute_channels
(
self
,
inpt
:
Union
[
datapoints
.
ImageType
,
datapoints
.
VideoType
],
permutation
:
torch
.
Tensor
)
->
Union
[
datapoints
.
ImageType
,
datapoints
.
VideoType
]:
self
,
inpt
:
Union
[
datapoints
.
_
ImageType
,
datapoints
.
_
VideoType
],
permutation
:
torch
.
Tensor
)
->
Union
[
datapoints
.
_
ImageType
,
datapoints
.
_
VideoType
]:
orig_inpt
=
inpt
if
isinstance
(
orig_inpt
,
PIL
.
Image
.
Image
):
...
...
@@ -179,8 +179,8 @@ class RandomPhotometricDistort(Transform):
return
output
def
_transform
(
self
,
inpt
:
Union
[
datapoints
.
ImageType
,
datapoints
.
VideoType
],
params
:
Dict
[
str
,
Any
]
)
->
Union
[
datapoints
.
ImageType
,
datapoints
.
VideoType
]:
self
,
inpt
:
Union
[
datapoints
.
_
ImageType
,
datapoints
.
_
VideoType
],
params
:
Dict
[
str
,
Any
]
)
->
Union
[
datapoints
.
_
ImageType
,
datapoints
.
_
VideoType
]:
if
params
[
"brightness"
]:
inpt
=
F
.
adjust_brightness
(
inpt
,
brightness_factor
=
ColorJitter
.
_generate_value
(
self
.
brightness
[
0
],
self
.
brightness
[
1
])
...
...
torchvision/transforms/v2/_geometry.py
View file @
d4d20f01
...
...
@@ -160,7 +160,7 @@ class RandomResizedCrop(Transform):
)
ImageOrVideoTypeJIT
=
Union
[
datapoints
.
ImageTypeJIT
,
datapoints
.
VideoTypeJIT
]
ImageOrVideoTypeJIT
=
Union
[
datapoints
.
_
ImageTypeJIT
,
datapoints
.
_
VideoTypeJIT
]
class
FiveCrop
(
Transform
):
...
...
@@ -232,7 +232,7 @@ class TenCrop(Transform):
raise
TypeError
(
f
"BoundingBox'es and Mask's are not supported by
{
type
(
self
).
__name__
}
()"
)
def
_transform
(
self
,
inpt
:
Union
[
datapoints
.
ImageType
,
datapoints
.
VideoType
],
params
:
Dict
[
str
,
Any
]
self
,
inpt
:
Union
[
datapoints
.
_
ImageType
,
datapoints
.
_
VideoType
],
params
:
Dict
[
str
,
Any
]
)
->
Tuple
[
ImageOrVideoTypeJIT
,
ImageOrVideoTypeJIT
,
...
...
@@ -264,7 +264,7 @@ class Pad(Transform):
def
__init__
(
self
,
padding
:
Union
[
int
,
Sequence
[
int
]],
fill
:
Union
[
datapoints
.
FillType
,
Dict
[
Type
,
datapoints
.
FillType
]]
=
0
,
fill
:
Union
[
datapoints
.
_
FillType
,
Dict
[
Type
,
datapoints
.
_
FillType
]]
=
0
,
padding_mode
:
Literal
[
"constant"
,
"edge"
,
"reflect"
,
"symmetric"
]
=
"constant"
,
)
->
None
:
super
().
__init__
()
...
...
@@ -287,7 +287,7 @@ class Pad(Transform):
class
RandomZoomOut
(
_RandomApplyTransform
):
def
__init__
(
self
,
fill
:
Union
[
datapoints
.
FillType
,
Dict
[
Type
,
datapoints
.
FillType
]]
=
0
,
fill
:
Union
[
datapoints
.
_
FillType
,
Dict
[
Type
,
datapoints
.
_
FillType
]]
=
0
,
side_range
:
Sequence
[
float
]
=
(
1.0
,
4.0
),
p
:
float
=
0.5
,
)
->
None
:
...
...
@@ -330,7 +330,7 @@ class RandomRotation(Transform):
degrees
:
Union
[
numbers
.
Number
,
Sequence
],
interpolation
:
Union
[
InterpolationMode
,
int
]
=
InterpolationMode
.
NEAREST
,
expand
:
bool
=
False
,
fill
:
Union
[
datapoints
.
FillType
,
Dict
[
Type
,
datapoints
.
FillType
]]
=
0
,
fill
:
Union
[
datapoints
.
_
FillType
,
Dict
[
Type
,
datapoints
.
_
FillType
]]
=
0
,
center
:
Optional
[
List
[
float
]]
=
None
,
)
->
None
:
super
().
__init__
()
...
...
@@ -371,7 +371,7 @@ class RandomAffine(Transform):
scale
:
Optional
[
Sequence
[
float
]]
=
None
,
shear
:
Optional
[
Union
[
int
,
float
,
Sequence
[
float
]]]
=
None
,
interpolation
:
Union
[
InterpolationMode
,
int
]
=
InterpolationMode
.
NEAREST
,
fill
:
Union
[
datapoints
.
FillType
,
Dict
[
Type
,
datapoints
.
FillType
]]
=
0
,
fill
:
Union
[
datapoints
.
_
FillType
,
Dict
[
Type
,
datapoints
.
_
FillType
]]
=
0
,
center
:
Optional
[
List
[
float
]]
=
None
,
)
->
None
:
super
().
__init__
()
...
...
@@ -464,7 +464,7 @@ class RandomCrop(Transform):
size
:
Union
[
int
,
Sequence
[
int
]],
padding
:
Optional
[
Union
[
int
,
Sequence
[
int
]]]
=
None
,
pad_if_needed
:
bool
=
False
,
fill
:
Union
[
datapoints
.
FillType
,
Dict
[
Type
,
datapoints
.
FillType
]]
=
0
,
fill
:
Union
[
datapoints
.
_
FillType
,
Dict
[
Type
,
datapoints
.
_
FillType
]]
=
0
,
padding_mode
:
Literal
[
"constant"
,
"edge"
,
"reflect"
,
"symmetric"
]
=
"constant"
,
)
->
None
:
super
().
__init__
()
...
...
@@ -556,7 +556,7 @@ class RandomPerspective(_RandomApplyTransform):
def
__init__
(
self
,
distortion_scale
:
float
=
0.5
,
fill
:
Union
[
datapoints
.
FillType
,
Dict
[
Type
,
datapoints
.
FillType
]]
=
0
,
fill
:
Union
[
datapoints
.
_
FillType
,
Dict
[
Type
,
datapoints
.
_
FillType
]]
=
0
,
interpolation
:
Union
[
InterpolationMode
,
int
]
=
InterpolationMode
.
BILINEAR
,
p
:
float
=
0.5
,
)
->
None
:
...
...
@@ -618,7 +618,7 @@ class ElasticTransform(Transform):
self
,
alpha
:
Union
[
float
,
Sequence
[
float
]]
=
50.0
,
sigma
:
Union
[
float
,
Sequence
[
float
]]
=
5.0
,
fill
:
Union
[
datapoints
.
FillType
,
Dict
[
Type
,
datapoints
.
FillType
]]
=
0
,
fill
:
Union
[
datapoints
.
_
FillType
,
Dict
[
Type
,
datapoints
.
_
FillType
]]
=
0
,
interpolation
:
Union
[
InterpolationMode
,
int
]
=
InterpolationMode
.
BILINEAR
,
)
->
None
:
super
().
__init__
()
...
...
torchvision/transforms/v2/_meta.py
View file @
d4d20f01
...
...
@@ -31,8 +31,8 @@ class ConvertDtype(Transform):
self
.
dtype
=
dtype
def
_transform
(
self
,
inpt
:
Union
[
datapoints
.
TensorImageType
,
datapoints
.
TensorVideoType
],
params
:
Dict
[
str
,
Any
]
)
->
Union
[
datapoints
.
TensorImageType
,
datapoints
.
TensorVideoType
]:
self
,
inpt
:
Union
[
datapoints
.
_
TensorImageType
,
datapoints
.
_
TensorVideoType
],
params
:
Dict
[
str
,
Any
]
)
->
Union
[
datapoints
.
_
TensorImageType
,
datapoints
.
_
TensorVideoType
]:
return
F
.
convert_dtype
(
inpt
,
self
.
dtype
)
...
...
torchvision/transforms/v2/_misc.py
View file @
d4d20f01
...
...
@@ -119,7 +119,7 @@ class Normalize(Transform):
raise
TypeError
(
f
"
{
type
(
self
).
__name__
}
() does not support PIL images."
)
def
_transform
(
self
,
inpt
:
Union
[
datapoints
.
TensorImageType
,
datapoints
.
TensorVideoType
],
params
:
Dict
[
str
,
Any
]
self
,
inpt
:
Union
[
datapoints
.
_
TensorImageType
,
datapoints
.
_
TensorVideoType
],
params
:
Dict
[
str
,
Any
]
)
->
Any
:
return
F
.
normalize
(
inpt
,
mean
=
self
.
mean
,
std
=
self
.
std
,
inplace
=
self
.
inplace
)
...
...
torchvision/transforms/v2/_temporal.py
View file @
d4d20f01
...
...
@@ -13,5 +13,5 @@ class UniformTemporalSubsample(Transform):
super
().
__init__
()
self
.
num_samples
=
num_samples
def
_transform
(
self
,
inpt
:
datapoints
.
VideoType
,
params
:
Dict
[
str
,
Any
])
->
datapoints
.
VideoType
:
def
_transform
(
self
,
inpt
:
datapoints
.
_
VideoType
,
params
:
Dict
[
str
,
Any
])
->
datapoints
.
_
VideoType
:
return
F
.
uniform_temporal_subsample
(
inpt
,
self
.
num_samples
)
torchvision/transforms/v2/_utils.py
View file @
d4d20f01
...
...
@@ -4,7 +4,7 @@ from collections import defaultdict
from
typing
import
Any
,
Dict
,
Literal
,
Sequence
,
Type
,
TypeVar
,
Union
from
torchvision
import
datapoints
from
torchvision.datapoints._datapoint
import
FillType
,
FillTypeJIT
from
torchvision.datapoints._datapoint
import
_
FillType
,
_
FillTypeJIT
from
torchvision.transforms.transforms
import
_check_sequence_input
,
_setup_angle
,
_setup_size
# noqa: F401
...
...
@@ -26,7 +26,7 @@ def _setup_float_or_seq(arg: Union[float, Sequence[float]], name: str, req_size:
return
arg
def
_check_fill_arg
(
fill
:
Union
[
FillType
,
Dict
[
Type
,
FillType
]])
->
None
:
def
_check_fill_arg
(
fill
:
Union
[
_
FillType
,
Dict
[
Type
,
_
FillType
]])
->
None
:
if
isinstance
(
fill
,
dict
):
for
key
,
value
in
fill
.
items
():
# Check key for type
...
...
@@ -52,7 +52,7 @@ def _get_defaultdict(default: T) -> Dict[Any, T]:
return
defaultdict
(
functools
.
partial
(
_default_arg
,
default
))
def
_convert_fill_arg
(
fill
:
datapoints
.
FillType
)
->
datapoints
.
FillTypeJIT
:
def
_convert_fill_arg
(
fill
:
datapoints
.
_
FillType
)
->
datapoints
.
_
FillTypeJIT
:
# Fill = 0 is not equivalent to None, https://github.com/pytorch/vision/issues/6517
# So, we can't reassign fill to 0
# if fill is None:
...
...
@@ -65,7 +65,7 @@ def _convert_fill_arg(fill: datapoints.FillType) -> datapoints.FillTypeJIT:
return
fill
# type: ignore[return-value]
def
_setup_fill_arg
(
fill
:
Union
[
FillType
,
Dict
[
Type
,
FillType
]])
->
Dict
[
Type
,
FillTypeJIT
]:
def
_setup_fill_arg
(
fill
:
Union
[
_
FillType
,
Dict
[
Type
,
_
FillType
]])
->
Dict
[
Type
,
_
FillTypeJIT
]:
_check_fill_arg
(
fill
)
if
isinstance
(
fill
,
dict
):
...
...
torchvision/transforms/v2/functional/_augment.py
View file @
d4d20f01
...
...
@@ -36,14 +36,14 @@ def erase_video(
def
erase
(
inpt
:
Union
[
datapoints
.
ImageTypeJIT
,
datapoints
.
VideoTypeJIT
],
inpt
:
Union
[
datapoints
.
_
ImageTypeJIT
,
datapoints
.
_
VideoTypeJIT
],
i
:
int
,
j
:
int
,
h
:
int
,
w
:
int
,
v
:
torch
.
Tensor
,
inplace
:
bool
=
False
,
)
->
Union
[
datapoints
.
ImageTypeJIT
,
datapoints
.
VideoTypeJIT
]:
)
->
Union
[
datapoints
.
_
ImageTypeJIT
,
datapoints
.
_
VideoTypeJIT
]:
if
not
torch
.
jit
.
is_scripting
():
_log_api_usage_once
(
erase
)
...
...
torchvision/transforms/v2/functional/_color.py
View file @
d4d20f01
...
...
@@ -37,8 +37,8 @@ rgb_to_grayscale_image_pil = _FP.to_grayscale
def
rgb_to_grayscale
(
inpt
:
Union
[
datapoints
.
ImageTypeJIT
,
datapoints
.
VideoTypeJIT
],
num_output_channels
:
int
=
1
)
->
Union
[
datapoints
.
ImageTypeJIT
,
datapoints
.
VideoTypeJIT
]:
inpt
:
Union
[
datapoints
.
_
ImageTypeJIT
,
datapoints
.
_
VideoTypeJIT
],
num_output_channels
:
int
=
1
)
->
Union
[
datapoints
.
_
ImageTypeJIT
,
datapoints
.
_
VideoTypeJIT
]:
if
not
torch
.
jit
.
is_scripting
():
_log_api_usage_once
(
rgb_to_grayscale
)
if
num_output_channels
not
in
(
1
,
3
):
...
...
@@ -85,7 +85,7 @@ def adjust_brightness_video(video: torch.Tensor, brightness_factor: float) -> to
return
adjust_brightness_image_tensor
(
video
,
brightness_factor
=
brightness_factor
)
def
adjust_brightness
(
inpt
:
datapoints
.
InputTypeJIT
,
brightness_factor
:
float
)
->
datapoints
.
InputTypeJIT
:
def
adjust_brightness
(
inpt
:
datapoints
.
_
InputTypeJIT
,
brightness_factor
:
float
)
->
datapoints
.
_
InputTypeJIT
:
if
not
torch
.
jit
.
is_scripting
():
_log_api_usage_once
(
adjust_brightness
)
...
...
@@ -127,7 +127,7 @@ def adjust_saturation_video(video: torch.Tensor, saturation_factor: float) -> to
return
adjust_saturation_image_tensor
(
video
,
saturation_factor
=
saturation_factor
)
def
adjust_saturation
(
inpt
:
datapoints
.
InputTypeJIT
,
saturation_factor
:
float
)
->
datapoints
.
InputTypeJIT
:
def
adjust_saturation
(
inpt
:
datapoints
.
_
InputTypeJIT
,
saturation_factor
:
float
)
->
datapoints
.
_
InputTypeJIT
:
if
not
torch
.
jit
.
is_scripting
():
_log_api_usage_once
(
adjust_saturation
)
...
...
@@ -171,7 +171,7 @@ def adjust_contrast_video(video: torch.Tensor, contrast_factor: float) -> torch.
return
adjust_contrast_image_tensor
(
video
,
contrast_factor
=
contrast_factor
)
def
adjust_contrast
(
inpt
:
datapoints
.
InputTypeJIT
,
contrast_factor
:
float
)
->
datapoints
.
InputTypeJIT
:
def
adjust_contrast
(
inpt
:
datapoints
.
_
InputTypeJIT
,
contrast_factor
:
float
)
->
datapoints
.
_
InputTypeJIT
:
if
not
torch
.
jit
.
is_scripting
():
_log_api_usage_once
(
adjust_contrast
)
...
...
@@ -247,7 +247,7 @@ def adjust_sharpness_video(video: torch.Tensor, sharpness_factor: float) -> torc
return
adjust_sharpness_image_tensor
(
video
,
sharpness_factor
=
sharpness_factor
)
def
adjust_sharpness
(
inpt
:
datapoints
.
InputTypeJIT
,
sharpness_factor
:
float
)
->
datapoints
.
InputTypeJIT
:
def
adjust_sharpness
(
inpt
:
datapoints
.
_
InputTypeJIT
,
sharpness_factor
:
float
)
->
datapoints
.
_
InputTypeJIT
:
if
not
torch
.
jit
.
is_scripting
():
_log_api_usage_once
(
adjust_sharpness
)
...
...
@@ -364,7 +364,7 @@ def adjust_hue_video(video: torch.Tensor, hue_factor: float) -> torch.Tensor:
return
adjust_hue_image_tensor
(
video
,
hue_factor
=
hue_factor
)
def
adjust_hue
(
inpt
:
datapoints
.
InputTypeJIT
,
hue_factor
:
float
)
->
datapoints
.
InputTypeJIT
:
def
adjust_hue
(
inpt
:
datapoints
.
_
InputTypeJIT
,
hue_factor
:
float
)
->
datapoints
.
_
InputTypeJIT
:
if
not
torch
.
jit
.
is_scripting
():
_log_api_usage_once
(
adjust_hue
)
...
...
@@ -407,7 +407,7 @@ def adjust_gamma_video(video: torch.Tensor, gamma: float, gain: float = 1) -> to
return
adjust_gamma_image_tensor
(
video
,
gamma
=
gamma
,
gain
=
gain
)
def
adjust_gamma
(
inpt
:
datapoints
.
InputTypeJIT
,
gamma
:
float
,
gain
:
float
=
1
)
->
datapoints
.
InputTypeJIT
:
def
adjust_gamma
(
inpt
:
datapoints
.
_
InputTypeJIT
,
gamma
:
float
,
gain
:
float
=
1
)
->
datapoints
.
_
InputTypeJIT
:
if
not
torch
.
jit
.
is_scripting
():
_log_api_usage_once
(
adjust_gamma
)
...
...
@@ -444,7 +444,7 @@ def posterize_video(video: torch.Tensor, bits: int) -> torch.Tensor:
return
posterize_image_tensor
(
video
,
bits
=
bits
)
def
posterize
(
inpt
:
datapoints
.
InputTypeJIT
,
bits
:
int
)
->
datapoints
.
InputTypeJIT
:
def
posterize
(
inpt
:
datapoints
.
_
InputTypeJIT
,
bits
:
int
)
->
datapoints
.
_
InputTypeJIT
:
if
not
torch
.
jit
.
is_scripting
():
_log_api_usage_once
(
posterize
)
...
...
@@ -475,7 +475,7 @@ def solarize_video(video: torch.Tensor, threshold: float) -> torch.Tensor:
return
solarize_image_tensor
(
video
,
threshold
=
threshold
)
def
solarize
(
inpt
:
datapoints
.
InputTypeJIT
,
threshold
:
float
)
->
datapoints
.
InputTypeJIT
:
def
solarize
(
inpt
:
datapoints
.
_
InputTypeJIT
,
threshold
:
float
)
->
datapoints
.
_
InputTypeJIT
:
if
not
torch
.
jit
.
is_scripting
():
_log_api_usage_once
(
solarize
)
...
...
@@ -528,7 +528,7 @@ def autocontrast_video(video: torch.Tensor) -> torch.Tensor:
return
autocontrast_image_tensor
(
video
)
def
autocontrast
(
inpt
:
datapoints
.
InputTypeJIT
)
->
datapoints
.
InputTypeJIT
:
def
autocontrast
(
inpt
:
datapoints
.
_
InputTypeJIT
)
->
datapoints
.
_
InputTypeJIT
:
if
not
torch
.
jit
.
is_scripting
():
_log_api_usage_once
(
autocontrast
)
...
...
@@ -621,7 +621,7 @@ def equalize_video(video: torch.Tensor) -> torch.Tensor:
return
equalize_image_tensor
(
video
)
def
equalize
(
inpt
:
datapoints
.
InputTypeJIT
)
->
datapoints
.
InputTypeJIT
:
def
equalize
(
inpt
:
datapoints
.
_
InputTypeJIT
)
->
datapoints
.
_
InputTypeJIT
:
if
not
torch
.
jit
.
is_scripting
():
_log_api_usage_once
(
equalize
)
...
...
@@ -655,7 +655,7 @@ def invert_video(video: torch.Tensor) -> torch.Tensor:
return
invert_image_tensor
(
video
)
def
invert
(
inpt
:
datapoints
.
InputTypeJIT
)
->
datapoints
.
InputTypeJIT
:
def
invert
(
inpt
:
datapoints
.
_
InputTypeJIT
)
->
datapoints
.
_
InputTypeJIT
:
if
not
torch
.
jit
.
is_scripting
():
_log_api_usage_once
(
invert
)
...
...
torchvision/transforms/v2/functional/_deprecated.py
View file @
d4d20f01
...
...
@@ -31,7 +31,7 @@ def to_tensor(inpt: Any) -> torch.Tensor:
return
_F
.
to_tensor
(
inpt
)
def
get_image_size
(
inpt
:
Union
[
datapoints
.
ImageTypeJIT
,
datapoints
.
VideoTypeJIT
])
->
List
[
int
]:
def
get_image_size
(
inpt
:
Union
[
datapoints
.
_
ImageTypeJIT
,
datapoints
.
_
VideoTypeJIT
])
->
List
[
int
]:
warnings
.
warn
(
"The function `get_image_size(...)` is deprecated and will be removed in a future release. "
"Instead, please use `get_spatial_size(...)` which returns `[h, w]` instead of `[w, h]`."
...
...
Prev
1
2
Next
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