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
6aae59d0
Unverified
Commit
6aae59d0
authored
Jun 29, 2022
by
Yih-Dar
Committed by
GitHub
Jun 29, 2022
Browse files
Compute min_resolution in prepare_image_inputs (#17915)
Co-authored-by:
ydshieh
<
ydshieh@users.noreply.github.com
>
parent
776855c7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
3 deletions
+8
-3
tests/test_feature_extraction_common.py
tests/test_feature_extraction_common.py
+8
-3
No files found.
tests/test_feature_extraction_common.py
View file @
6aae59d0
...
...
@@ -68,10 +68,15 @@ def prepare_image_inputs(feature_extract_tester, equal_resolution=False, numpify
)
else
:
image_inputs
=
[]
# To avoid getting image width/height 0
min_resolution
=
feature_extract_tester
.
min_resolution
if
getattr
(
feature_extract_tester
,
"size_divisor"
,
None
):
# If `size_divisor` is defined, the image needs to have width/size >= `size_divisor`
min_resolution
=
max
(
feature_extract_tester
.
size_divisor
,
min_resolution
)
for
i
in
range
(
feature_extract_tester
.
batch_size
):
width
,
height
=
np
.
random
.
choice
(
np
.
arange
(
feature_extract_tester
.
min_resolution
,
feature_extract_tester
.
max_resolution
),
2
)
width
,
height
=
np
.
random
.
choice
(
np
.
arange
(
min_resolution
,
feature_extract_tester
.
max_resolution
),
2
)
image_inputs
.
append
(
np
.
random
.
randint
(
255
,
size
=
(
feature_extract_tester
.
num_channels
,
width
,
height
),
dtype
=
np
.
uint8
)
)
...
...
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