"git@developer.sourcefind.cn:chenpangpang/transformers.git" did not exist on "506ab34d0e42c77a5ee24d4d94d0c27fb081f374"
Unverified Commit 6aae59d0 authored by Yih-Dar's avatar Yih-Dar Committed by GitHub
Browse files

Compute min_resolution in prepare_image_inputs (#17915)


Co-authored-by: default avatarydshieh <ydshieh@users.noreply.github.com>
parent 776855c7
...@@ -68,10 +68,15 @@ def prepare_image_inputs(feature_extract_tester, equal_resolution=False, numpify ...@@ -68,10 +68,15 @@ def prepare_image_inputs(feature_extract_tester, equal_resolution=False, numpify
) )
else: else:
image_inputs = [] 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): for i in range(feature_extract_tester.batch_size):
width, height = np.random.choice( width, height = np.random.choice(np.arange(min_resolution, feature_extract_tester.max_resolution), 2)
np.arange(feature_extract_tester.min_resolution, feature_extract_tester.max_resolution), 2
)
image_inputs.append( image_inputs.append(
np.random.randint(255, size=(feature_extract_tester.num_channels, width, height), dtype=np.uint8) np.random.randint(255, size=(feature_extract_tester.num_channels, width, height), dtype=np.uint8)
) )
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment