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
95b594e0
Unverified
Commit
95b594e0
authored
Nov 04, 2022
by
Philip Meier
Committed by
GitHub
Nov 04, 2022
Browse files
fix antialias handling on resize and resized_crop (#6913)
parent
9e6dab73
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
15 additions
and
18 deletions
+15
-18
torchvision/prototype/features/_bounding_box.py
torchvision/prototype/features/_bounding_box.py
+2
-2
torchvision/prototype/features/_feature.py
torchvision/prototype/features/_feature.py
+2
-2
torchvision/prototype/features/_image.py
torchvision/prototype/features/_image.py
+2
-2
torchvision/prototype/features/_mask.py
torchvision/prototype/features/_mask.py
+2
-2
torchvision/prototype/features/_video.py
torchvision/prototype/features/_video.py
+2
-2
torchvision/prototype/transforms/functional/_geometry.py
torchvision/prototype/transforms/functional/_geometry.py
+5
-8
No files found.
torchvision/prototype/features/_bounding_box.py
View file @
95b594e0
...
@@ -78,7 +78,7 @@ class BoundingBox(_Feature):
...
@@ -78,7 +78,7 @@ class BoundingBox(_Feature):
size
:
List
[
int
],
size
:
List
[
int
],
interpolation
:
InterpolationMode
=
InterpolationMode
.
BILINEAR
,
interpolation
:
InterpolationMode
=
InterpolationMode
.
BILINEAR
,
max_size
:
Optional
[
int
]
=
None
,
max_size
:
Optional
[
int
]
=
None
,
antialias
:
bool
=
Fals
e
,
antialias
:
Optional
[
bool
]
=
Non
e
,
)
->
BoundingBox
:
)
->
BoundingBox
:
output
,
spatial_size
=
self
.
_F
.
resize_bounding_box
(
output
,
spatial_size
=
self
.
_F
.
resize_bounding_box
(
self
.
as_subclass
(
torch
.
Tensor
),
spatial_size
=
self
.
spatial_size
,
size
=
size
,
max_size
=
max_size
self
.
as_subclass
(
torch
.
Tensor
),
spatial_size
=
self
.
spatial_size
,
size
=
size
,
max_size
=
max_size
...
@@ -105,7 +105,7 @@ class BoundingBox(_Feature):
...
@@ -105,7 +105,7 @@ class BoundingBox(_Feature):
width
:
int
,
width
:
int
,
size
:
List
[
int
],
size
:
List
[
int
],
interpolation
:
InterpolationMode
=
InterpolationMode
.
BILINEAR
,
interpolation
:
InterpolationMode
=
InterpolationMode
.
BILINEAR
,
antialias
:
bool
=
Fals
e
,
antialias
:
Optional
[
bool
]
=
Non
e
,
)
->
BoundingBox
:
)
->
BoundingBox
:
output
,
spatial_size
=
self
.
_F
.
resized_crop_bounding_box
(
output
,
spatial_size
=
self
.
_F
.
resized_crop_bounding_box
(
self
.
as_subclass
(
torch
.
Tensor
),
self
.
format
,
top
,
left
,
height
,
width
,
size
=
size
self
.
as_subclass
(
torch
.
Tensor
),
self
.
format
,
top
,
left
,
height
,
width
,
size
=
size
...
...
torchvision/prototype/features/_feature.py
View file @
95b594e0
...
@@ -164,7 +164,7 @@ class _Feature(torch.Tensor):
...
@@ -164,7 +164,7 @@ class _Feature(torch.Tensor):
size
:
List
[
int
],
size
:
List
[
int
],
interpolation
:
InterpolationMode
=
InterpolationMode
.
BILINEAR
,
interpolation
:
InterpolationMode
=
InterpolationMode
.
BILINEAR
,
max_size
:
Optional
[
int
]
=
None
,
max_size
:
Optional
[
int
]
=
None
,
antialias
:
bool
=
Fals
e
,
antialias
:
Optional
[
bool
]
=
Non
e
,
)
->
_Feature
:
)
->
_Feature
:
return
self
return
self
...
@@ -182,7 +182,7 @@ class _Feature(torch.Tensor):
...
@@ -182,7 +182,7 @@ class _Feature(torch.Tensor):
width
:
int
,
width
:
int
,
size
:
List
[
int
],
size
:
List
[
int
],
interpolation
:
InterpolationMode
=
InterpolationMode
.
BILINEAR
,
interpolation
:
InterpolationMode
=
InterpolationMode
.
BILINEAR
,
antialias
:
bool
=
Fals
e
,
antialias
:
Optional
[
bool
]
=
Non
e
,
)
->
_Feature
:
)
->
_Feature
:
return
self
return
self
...
...
torchvision/prototype/features/_image.py
View file @
95b594e0
...
@@ -123,7 +123,7 @@ class Image(_Feature):
...
@@ -123,7 +123,7 @@ class Image(_Feature):
size
:
List
[
int
],
size
:
List
[
int
],
interpolation
:
InterpolationMode
=
InterpolationMode
.
BILINEAR
,
interpolation
:
InterpolationMode
=
InterpolationMode
.
BILINEAR
,
max_size
:
Optional
[
int
]
=
None
,
max_size
:
Optional
[
int
]
=
None
,
antialias
:
bool
=
Fals
e
,
antialias
:
Optional
[
bool
]
=
Non
e
,
)
->
Image
:
)
->
Image
:
output
=
self
.
_F
.
resize_image_tensor
(
output
=
self
.
_F
.
resize_image_tensor
(
self
.
as_subclass
(
torch
.
Tensor
),
size
,
interpolation
=
interpolation
,
max_size
=
max_size
,
antialias
=
antialias
self
.
as_subclass
(
torch
.
Tensor
),
size
,
interpolation
=
interpolation
,
max_size
=
max_size
,
antialias
=
antialias
...
@@ -146,7 +146,7 @@ class Image(_Feature):
...
@@ -146,7 +146,7 @@ class Image(_Feature):
width
:
int
,
width
:
int
,
size
:
List
[
int
],
size
:
List
[
int
],
interpolation
:
InterpolationMode
=
InterpolationMode
.
BILINEAR
,
interpolation
:
InterpolationMode
=
InterpolationMode
.
BILINEAR
,
antialias
:
bool
=
Fals
e
,
antialias
:
Optional
[
bool
]
=
Non
e
,
)
->
Image
:
)
->
Image
:
output
=
self
.
_F
.
resized_crop_image_tensor
(
output
=
self
.
_F
.
resized_crop_image_tensor
(
self
.
as_subclass
(
torch
.
Tensor
),
self
.
as_subclass
(
torch
.
Tensor
),
...
...
torchvision/prototype/features/_mask.py
View file @
95b594e0
...
@@ -49,7 +49,7 @@ class Mask(_Feature):
...
@@ -49,7 +49,7 @@ class Mask(_Feature):
size
:
List
[
int
],
size
:
List
[
int
],
interpolation
:
InterpolationMode
=
InterpolationMode
.
NEAREST
,
interpolation
:
InterpolationMode
=
InterpolationMode
.
NEAREST
,
max_size
:
Optional
[
int
]
=
None
,
max_size
:
Optional
[
int
]
=
None
,
antialias
:
bool
=
Fals
e
,
antialias
:
Optional
[
bool
]
=
Non
e
,
)
->
Mask
:
)
->
Mask
:
output
=
self
.
_F
.
resize_mask
(
self
.
as_subclass
(
torch
.
Tensor
),
size
,
max_size
=
max_size
)
output
=
self
.
_F
.
resize_mask
(
self
.
as_subclass
(
torch
.
Tensor
),
size
,
max_size
=
max_size
)
return
Mask
.
wrap_like
(
self
,
output
)
return
Mask
.
wrap_like
(
self
,
output
)
...
@@ -70,7 +70,7 @@ class Mask(_Feature):
...
@@ -70,7 +70,7 @@ class Mask(_Feature):
width
:
int
,
width
:
int
,
size
:
List
[
int
],
size
:
List
[
int
],
interpolation
:
InterpolationMode
=
InterpolationMode
.
NEAREST
,
interpolation
:
InterpolationMode
=
InterpolationMode
.
NEAREST
,
antialias
:
bool
=
Fals
e
,
antialias
:
Optional
[
bool
]
=
Non
e
,
)
->
Mask
:
)
->
Mask
:
output
=
self
.
_F
.
resized_crop_mask
(
self
.
as_subclass
(
torch
.
Tensor
),
top
,
left
,
height
,
width
,
size
=
size
)
output
=
self
.
_F
.
resized_crop_mask
(
self
.
as_subclass
(
torch
.
Tensor
),
top
,
left
,
height
,
width
,
size
=
size
)
return
Mask
.
wrap_like
(
self
,
output
)
return
Mask
.
wrap_like
(
self
,
output
)
...
...
torchvision/prototype/features/_video.py
View file @
95b594e0
...
@@ -79,7 +79,7 @@ class Video(_Feature):
...
@@ -79,7 +79,7 @@ class Video(_Feature):
size
:
List
[
int
],
size
:
List
[
int
],
interpolation
:
InterpolationMode
=
InterpolationMode
.
BILINEAR
,
interpolation
:
InterpolationMode
=
InterpolationMode
.
BILINEAR
,
max_size
:
Optional
[
int
]
=
None
,
max_size
:
Optional
[
int
]
=
None
,
antialias
:
bool
=
Fals
e
,
antialias
:
Optional
[
bool
]
=
Non
e
,
)
->
Video
:
)
->
Video
:
output
=
self
.
_F
.
resize_video
(
output
=
self
.
_F
.
resize_video
(
self
.
as_subclass
(
torch
.
Tensor
),
self
.
as_subclass
(
torch
.
Tensor
),
...
@@ -106,7 +106,7 @@ class Video(_Feature):
...
@@ -106,7 +106,7 @@ class Video(_Feature):
width
:
int
,
width
:
int
,
size
:
List
[
int
],
size
:
List
[
int
],
interpolation
:
InterpolationMode
=
InterpolationMode
.
BILINEAR
,
interpolation
:
InterpolationMode
=
InterpolationMode
.
BILINEAR
,
antialias
:
bool
=
Fals
e
,
antialias
:
Optional
[
bool
]
=
Non
e
,
)
->
Video
:
)
->
Video
:
output
=
self
.
_F
.
resized_crop_video
(
output
=
self
.
_F
.
resized_crop_video
(
self
.
as_subclass
(
torch
.
Tensor
),
self
.
as_subclass
(
torch
.
Tensor
),
...
...
torchvision/prototype/transforms/functional/_geometry.py
View file @
95b594e0
...
@@ -115,8 +115,9 @@ def resize_image_tensor(
...
@@ -115,8 +115,9 @@ def resize_image_tensor(
size
:
List
[
int
],
size
:
List
[
int
],
interpolation
:
InterpolationMode
=
InterpolationMode
.
BILINEAR
,
interpolation
:
InterpolationMode
=
InterpolationMode
.
BILINEAR
,
max_size
:
Optional
[
int
]
=
None
,
max_size
:
Optional
[
int
]
=
None
,
antialias
:
bool
=
Fals
e
,
antialias
:
Optional
[
bool
]
=
Non
e
,
)
->
torch
.
Tensor
:
)
->
torch
.
Tensor
:
antialias
=
False
if
antialias
is
None
else
antialias
align_corners
:
Optional
[
bool
]
=
None
align_corners
:
Optional
[
bool
]
=
None
if
interpolation
==
InterpolationMode
.
BILINEAR
or
interpolation
==
InterpolationMode
.
BICUBIC
:
if
interpolation
==
InterpolationMode
.
BILINEAR
or
interpolation
==
InterpolationMode
.
BICUBIC
:
align_corners
=
False
align_corners
=
False
...
@@ -196,7 +197,7 @@ def resize_video(
...
@@ -196,7 +197,7 @@ def resize_video(
size
:
List
[
int
],
size
:
List
[
int
],
interpolation
:
InterpolationMode
=
InterpolationMode
.
BILINEAR
,
interpolation
:
InterpolationMode
=
InterpolationMode
.
BILINEAR
,
max_size
:
Optional
[
int
]
=
None
,
max_size
:
Optional
[
int
]
=
None
,
antialias
:
bool
=
Fals
e
,
antialias
:
Optional
[
bool
]
=
Non
e
,
)
->
torch
.
Tensor
:
)
->
torch
.
Tensor
:
return
resize_image_tensor
(
video
,
size
=
size
,
interpolation
=
interpolation
,
max_size
=
max_size
,
antialias
=
antialias
)
return
resize_image_tensor
(
video
,
size
=
size
,
interpolation
=
interpolation
,
max_size
=
max_size
,
antialias
=
antialias
)
...
@@ -209,10 +210,8 @@ def resize(
...
@@ -209,10 +210,8 @@ def resize(
antialias
:
Optional
[
bool
]
=
None
,
antialias
:
Optional
[
bool
]
=
None
,
)
->
features
.
InputTypeJIT
:
)
->
features
.
InputTypeJIT
:
if
isinstance
(
inpt
,
torch
.
Tensor
)
and
(
torch
.
jit
.
is_scripting
()
or
not
isinstance
(
inpt
,
features
.
_Feature
)):
if
isinstance
(
inpt
,
torch
.
Tensor
)
and
(
torch
.
jit
.
is_scripting
()
or
not
isinstance
(
inpt
,
features
.
_Feature
)):
antialias
=
False
if
antialias
is
None
else
antialias
return
resize_image_tensor
(
inpt
,
size
,
interpolation
=
interpolation
,
max_size
=
max_size
,
antialias
=
antialias
)
return
resize_image_tensor
(
inpt
,
size
,
interpolation
=
interpolation
,
max_size
=
max_size
,
antialias
=
antialias
)
elif
isinstance
(
inpt
,
features
.
_Feature
):
elif
isinstance
(
inpt
,
features
.
_Feature
):
antialias
=
False
if
antialias
is
None
else
antialias
return
inpt
.
resize
(
size
,
interpolation
=
interpolation
,
max_size
=
max_size
,
antialias
=
antialias
)
return
inpt
.
resize
(
size
,
interpolation
=
interpolation
,
max_size
=
max_size
,
antialias
=
antialias
)
else
:
else
:
if
antialias
is
not
None
and
not
antialias
:
if
antialias
is
not
None
and
not
antialias
:
...
@@ -1396,7 +1395,7 @@ def resized_crop_image_tensor(
...
@@ -1396,7 +1395,7 @@ def resized_crop_image_tensor(
width
:
int
,
width
:
int
,
size
:
List
[
int
],
size
:
List
[
int
],
interpolation
:
InterpolationMode
=
InterpolationMode
.
BILINEAR
,
interpolation
:
InterpolationMode
=
InterpolationMode
.
BILINEAR
,
antialias
:
bool
=
Fals
e
,
antialias
:
Optional
[
bool
]
=
Non
e
,
)
->
torch
.
Tensor
:
)
->
torch
.
Tensor
:
image
=
crop_image_tensor
(
image
,
top
,
left
,
height
,
width
)
image
=
crop_image_tensor
(
image
,
top
,
left
,
height
,
width
)
return
resize_image_tensor
(
image
,
size
,
interpolation
=
interpolation
,
antialias
=
antialias
)
return
resize_image_tensor
(
image
,
size
,
interpolation
=
interpolation
,
antialias
=
antialias
)
...
@@ -1449,7 +1448,7 @@ def resized_crop_video(
...
@@ -1449,7 +1448,7 @@ def resized_crop_video(
width
:
int
,
width
:
int
,
size
:
List
[
int
],
size
:
List
[
int
],
interpolation
:
InterpolationMode
=
InterpolationMode
.
BILINEAR
,
interpolation
:
InterpolationMode
=
InterpolationMode
.
BILINEAR
,
antialias
:
bool
=
Fals
e
,
antialias
:
Optional
[
bool
]
=
Non
e
,
)
->
torch
.
Tensor
:
)
->
torch
.
Tensor
:
return
resized_crop_image_tensor
(
return
resized_crop_image_tensor
(
video
,
top
,
left
,
height
,
width
,
antialias
=
antialias
,
size
=
size
,
interpolation
=
interpolation
video
,
top
,
left
,
height
,
width
,
antialias
=
antialias
,
size
=
size
,
interpolation
=
interpolation
...
@@ -1467,12 +1466,10 @@ def resized_crop(
...
@@ -1467,12 +1466,10 @@ def resized_crop(
antialias
:
Optional
[
bool
]
=
None
,
antialias
:
Optional
[
bool
]
=
None
,
)
->
features
.
InputTypeJIT
:
)
->
features
.
InputTypeJIT
:
if
isinstance
(
inpt
,
torch
.
Tensor
)
and
(
torch
.
jit
.
is_scripting
()
or
not
isinstance
(
inpt
,
features
.
_Feature
)):
if
isinstance
(
inpt
,
torch
.
Tensor
)
and
(
torch
.
jit
.
is_scripting
()
or
not
isinstance
(
inpt
,
features
.
_Feature
)):
antialias
=
False
if
antialias
is
None
else
antialias
return
resized_crop_image_tensor
(
return
resized_crop_image_tensor
(
inpt
,
top
,
left
,
height
,
width
,
antialias
=
antialias
,
size
=
size
,
interpolation
=
interpolation
inpt
,
top
,
left
,
height
,
width
,
antialias
=
antialias
,
size
=
size
,
interpolation
=
interpolation
)
)
elif
isinstance
(
inpt
,
features
.
_Feature
):
elif
isinstance
(
inpt
,
features
.
_Feature
):
antialias
=
False
if
antialias
is
None
else
antialias
return
inpt
.
resized_crop
(
top
,
left
,
height
,
width
,
antialias
=
antialias
,
size
=
size
,
interpolation
=
interpolation
)
return
inpt
.
resized_crop
(
top
,
left
,
height
,
width
,
antialias
=
antialias
,
size
=
size
,
interpolation
=
interpolation
)
else
:
else
:
return
resized_crop_image_pil
(
inpt
,
top
,
left
,
height
,
width
,
size
=
size
,
interpolation
=
interpolation
)
return
resized_crop_image_pil
(
inpt
,
top
,
left
,
height
,
width
,
size
=
size
,
interpolation
=
interpolation
)
...
...
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