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
chenpangpang
transformers
Commits
d27e4c18
Unverified
Commit
d27e4c18
authored
Aug 01, 2023
by
amyeroberts
Committed by
GitHub
Aug 01, 2023
Browse files
Move rescale dtype recasting to match torchvision ToTensor (#25229)
Move dtype recasting to match torchvision ToTensor
parent
3170af71
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
2 deletions
+3
-2
src/transformers/image_transforms.py
src/transformers/image_transforms.py
+3
-2
No files found.
src/transformers/image_transforms.py
View file @
d27e4c18
...
@@ -110,11 +110,12 @@ def rescale(
...
@@ -110,11 +110,12 @@ def rescale(
if
not
isinstance
(
image
,
np
.
ndarray
):
if
not
isinstance
(
image
,
np
.
ndarray
):
raise
ValueError
(
f
"Input image must be of type np.ndarray, got
{
type
(
image
)
}
"
)
raise
ValueError
(
f
"Input image must be of type np.ndarray, got
{
type
(
image
)
}
"
)
image
=
image
.
astype
(
dtype
)
rescaled_image
=
image
*
scale
rescaled_image
=
image
*
scale
if
data_format
is
not
None
:
if
data_format
is
not
None
:
rescaled_image
=
to_channel_dimension_format
(
rescaled_image
,
data_format
)
rescaled_image
=
to_channel_dimension_format
(
rescaled_image
,
data_format
)
rescaled_image
=
rescaled_image
.
astype
(
dtype
)
return
rescaled_image
return
rescaled_image
...
...
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