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
780253ce
Unverified
Commit
780253ce
authored
Aug 18, 2022
by
amyeroberts
Committed by
GitHub
Aug 18, 2022
Browse files
Rename method to avoid clash with property (#18677)
parent
2c947d29
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
src/transformers/image_utils.py
src/transformers/image_utils.py
+4
-4
No files found.
src/transformers/image_utils.py
View file @
780253ce
...
...
@@ -131,7 +131,7 @@ class ImageFeatureExtractionMixin:
return
image
.
convert
(
"RGB"
)
def
rescale
(
self
,
image
:
np
.
ndarray
,
scale
:
Union
[
float
,
int
])
->
np
.
ndarray
:
def
rescale
_image
(
self
,
image
:
np
.
ndarray
,
scale
:
Union
[
float
,
int
])
->
np
.
ndarray
:
"""
Rescale a numpy image by scale amount
"""
...
...
@@ -163,7 +163,7 @@ class ImageFeatureExtractionMixin:
rescale
=
isinstance
(
image
.
flat
[
0
],
np
.
integer
)
if
rescale
is
None
else
rescale
if
rescale
:
image
=
self
.
rescale
(
image
.
astype
(
np
.
float32
),
1
/
255.0
)
image
=
self
.
rescale
_image
(
image
.
astype
(
np
.
float32
),
1
/
255.0
)
if
channel_first
and
image
.
ndim
==
3
:
image
=
image
.
transpose
(
2
,
0
,
1
)
...
...
@@ -214,9 +214,9 @@ class ImageFeatureExtractionMixin:
# type it may need rescaling.
elif
rescale
:
if
isinstance
(
image
,
np
.
ndarray
):
image
=
self
.
rescale
(
image
.
astype
(
np
.
float32
),
1
/
255.0
)
image
=
self
.
rescale
_image
(
image
.
astype
(
np
.
float32
),
1
/
255.0
)
elif
is_torch_tensor
(
image
):
image
=
self
.
rescale
(
image
.
float
(),
1
/
255.0
)
image
=
self
.
rescale
_image
(
image
.
float
(),
1
/
255.0
)
if
isinstance
(
image
,
np
.
ndarray
):
if
not
isinstance
(
mean
,
np
.
ndarray
):
...
...
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