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
"git@developer.sourcefind.cn:OpenDAS/ollama.git" did not exist on "5c1063df7fb6850410a35ddfb92cd6efb818fa6e"
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
Hide 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):
size
:
List
[
int
],
interpolation
:
InterpolationMode
=
InterpolationMode
.
BILINEAR
,
max_size
:
Optional
[
int
]
=
None
,
antialias
:
bool
=
Fals
e
,
antialias
:
Optional
[
bool
]
=
Non
e
,
)
->
BoundingBox
:
output
,
spatial_size
=
self
.
_F
.
resize_bounding_box
(
self
.
as_subclass
(
torch
.
Tensor
),
spatial_size
=
self
.
spatial_size
,
size
=
size
,
max_size
=
max_size
...
...
@@ -105,7 +105,7 @@ class BoundingBox(_Feature):
width
:
int
,
size
:
List
[
int
],
interpolation
:
InterpolationMode
=
InterpolationMode
.
BILINEAR
,
antialias
:
bool
=
Fals
e
,
antialias
:
Optional
[
bool
]
=
Non
e
,
)
->
BoundingBox
:
output
,
spatial_size
=
self
.
_F
.
resized_crop_bounding_box
(
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):
size
:
List
[
int
],
interpolation
:
InterpolationMode
=
InterpolationMode
.
BILINEAR
,
max_size
:
Optional
[
int
]
=
None
,
antialias
:
bool
=
Fals
e
,
antialias
:
Optional
[
bool
]
=
Non
e
,
)
->
_Feature
:
return
self
...
...
@@ -182,7 +182,7 @@ class _Feature(torch.Tensor):
width
:
int
,
size
:
List
[
int
],
interpolation
:
InterpolationMode
=
InterpolationMode
.
BILINEAR
,
antialias
:
bool
=
Fals
e
,
antialias
:
Optional
[
bool
]
=
Non
e
,
)
->
_Feature
:
return
self
...
...
torchvision/prototype/features/_image.py
View file @
95b594e0
...
...
@@ -123,7 +123,7 @@ class Image(_Feature):
size
:
List
[
int
],
interpolation
:
InterpolationMode
=
InterpolationMode
.
BILINEAR
,
max_size
:
Optional
[
int
]
=
None
,
antialias
:
bool
=
Fals
e
,
antialias
:
Optional
[
bool
]
=
Non
e
,
)
->
Image
:
output
=
self
.
_F
.
resize_image_tensor
(
self
.
as_subclass
(
torch
.
Tensor
),
size
,
interpolation
=
interpolation
,
max_size
=
max_size
,
antialias
=
antialias
...
...
@@ -146,7 +146,7 @@ class Image(_Feature):
width
:
int
,
size
:
List
[
int
],
interpolation
:
InterpolationMode
=
InterpolationMode
.
BILINEAR
,
antialias
:
bool
=
Fals
e
,
antialias
:
Optional
[
bool
]
=
Non
e
,
)
->
Image
:
output
=
self
.
_F
.
resized_crop_image_tensor
(
self
.
as_subclass
(
torch
.
Tensor
),
...
...
torchvision/prototype/features/_mask.py
View file @
95b594e0
...
...
@@ -49,7 +49,7 @@ class Mask(_Feature):
size
:
List
[
int
],
interpolation
:
InterpolationMode
=
InterpolationMode
.
NEAREST
,
max_size
:
Optional
[
int
]
=
None
,
antialias
:
bool
=
Fals
e
,
antialias
:
Optional
[
bool
]
=
Non
e
,
)
->
Mask
:
output
=
self
.
_F
.
resize_mask
(
self
.
as_subclass
(
torch
.
Tensor
),
size
,
max_size
=
max_size
)
return
Mask
.
wrap_like
(
self
,
output
)
...
...
@@ -70,7 +70,7 @@ class Mask(_Feature):
width
:
int
,
size
:
List
[
int
],
interpolation
:
InterpolationMode
=
InterpolationMode
.
NEAREST
,
antialias
:
bool
=
Fals
e
,
antialias
:
Optional
[
bool
]
=
Non
e
,
)
->
Mask
:
output
=
self
.
_F
.
resized_crop_mask
(
self
.
as_subclass
(
torch
.
Tensor
),
top
,
left
,
height
,
width
,
size
=
size
)
return
Mask
.
wrap_like
(
self
,
output
)
...
...
torchvision/prototype/features/_video.py
View file @
95b594e0
...
...
@@ -79,7 +79,7 @@ class Video(_Feature):
size
:
List
[
int
],
interpolation
:
InterpolationMode
=
InterpolationMode
.
BILINEAR
,
max_size
:
Optional
[
int
]
=
None
,
antialias
:
bool
=
Fals
e
,
antialias
:
Optional
[
bool
]
=
Non
e
,
)
->
Video
:
output
=
self
.
_F
.
resize_video
(
self
.
as_subclass
(
torch
.
Tensor
),
...
...
@@ -106,7 +106,7 @@ class Video(_Feature):
width
:
int
,
size
:
List
[
int
],
interpolation
:
InterpolationMode
=
InterpolationMode
.
BILINEAR
,
antialias
:
bool
=
Fals
e
,
antialias
:
Optional
[
bool
]
=
Non
e
,
)
->
Video
:
output
=
self
.
_F
.
resized_crop_video
(
self
.
as_subclass
(
torch
.
Tensor
),
...
...
torchvision/prototype/transforms/functional/_geometry.py
View file @
95b594e0
...
...
@@ -115,8 +115,9 @@ def resize_image_tensor(
size
:
List
[
int
],
interpolation
:
InterpolationMode
=
InterpolationMode
.
BILINEAR
,
max_size
:
Optional
[
int
]
=
None
,
antialias
:
bool
=
Fals
e
,
antialias
:
Optional
[
bool
]
=
Non
e
,
)
->
torch
.
Tensor
:
antialias
=
False
if
antialias
is
None
else
antialias
align_corners
:
Optional
[
bool
]
=
None
if
interpolation
==
InterpolationMode
.
BILINEAR
or
interpolation
==
InterpolationMode
.
BICUBIC
:
align_corners
=
False
...
...
@@ -196,7 +197,7 @@ def resize_video(
size
:
List
[
int
],
interpolation
:
InterpolationMode
=
InterpolationMode
.
BILINEAR
,
max_size
:
Optional
[
int
]
=
None
,
antialias
:
bool
=
Fals
e
,
antialias
:
Optional
[
bool
]
=
Non
e
,
)
->
torch
.
Tensor
:
return
resize_image_tensor
(
video
,
size
=
size
,
interpolation
=
interpolation
,
max_size
=
max_size
,
antialias
=
antialias
)
...
...
@@ -209,10 +210,8 @@ def resize(
antialias
:
Optional
[
bool
]
=
None
,
)
->
features
.
InputTypeJIT
:
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
)
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
)
else
:
if
antialias
is
not
None
and
not
antialias
:
...
...
@@ -1396,7 +1395,7 @@ def resized_crop_image_tensor(
width
:
int
,
size
:
List
[
int
],
interpolation
:
InterpolationMode
=
InterpolationMode
.
BILINEAR
,
antialias
:
bool
=
Fals
e
,
antialias
:
Optional
[
bool
]
=
Non
e
,
)
->
torch
.
Tensor
:
image
=
crop_image_tensor
(
image
,
top
,
left
,
height
,
width
)
return
resize_image_tensor
(
image
,
size
,
interpolation
=
interpolation
,
antialias
=
antialias
)
...
...
@@ -1449,7 +1448,7 @@ def resized_crop_video(
width
:
int
,
size
:
List
[
int
],
interpolation
:
InterpolationMode
=
InterpolationMode
.
BILINEAR
,
antialias
:
bool
=
Fals
e
,
antialias
:
Optional
[
bool
]
=
Non
e
,
)
->
torch
.
Tensor
:
return
resized_crop_image_tensor
(
video
,
top
,
left
,
height
,
width
,
antialias
=
antialias
,
size
=
size
,
interpolation
=
interpolation
...
...
@@ -1467,12 +1466,10 @@ def resized_crop(
antialias
:
Optional
[
bool
]
=
None
,
)
->
features
.
InputTypeJIT
:
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
(
inpt
,
top
,
left
,
height
,
width
,
antialias
=
antialias
,
size
=
size
,
interpolation
=
interpolation
)
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
)
else
:
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