"doc/git@developer.sourcefind.cn:OpenDAS/ktransformers.git" did not exist on "055680e26c97b1e5353e9d989b5e087b78f38511"
Unverified Commit 7c9bbf5b authored by Francisco Massa's avatar Francisco Massa Committed by GitHub
Browse files

Fix randomresized params flaky (#1282)

* Fix flakiness of test_randomresized_params

* Real fix

* Reduce number of iters
parent a44a1630
...@@ -141,8 +141,9 @@ class Tester(unittest.TestCase): ...@@ -141,8 +141,9 @@ class Tester(unittest.TestCase):
img = to_pil_image(img) img = to_pil_image(img)
size = 100 size = 100
epsilon = 0.05 epsilon = 0.05
min_scale = 0.25
for _ in range(10): for _ in range(10):
scale_min = round(random.random(), 2) scale_min = max(round(random.random(), 2), min_scale)
scale_range = (scale_min, scale_min + round(random.random(), 2)) scale_range = (scale_min, scale_min + round(random.random(), 2))
aspect_min = max(round(random.random(), 2), epsilon) aspect_min = max(round(random.random(), 2), epsilon)
aspect_ratio_range = (aspect_min, aspect_min + round(random.random(), 2)) aspect_ratio_range = (aspect_min, aspect_min + round(random.random(), 2))
......
...@@ -645,7 +645,7 @@ class RandomResizedCrop(object): ...@@ -645,7 +645,7 @@ class RandomResizedCrop(object):
w = int(round(math.sqrt(target_area * aspect_ratio))) w = int(round(math.sqrt(target_area * aspect_ratio)))
h = int(round(math.sqrt(target_area / aspect_ratio))) h = int(round(math.sqrt(target_area / aspect_ratio)))
if w <= img.size[0] and h <= img.size[1]: if 0 < w <= img.size[0] and 0 < h <= img.size[1]:
i = random.randint(0, img.size[1] - h) i = random.randint(0, img.size[1] - h)
j = random.randint(0, img.size[0] - w) j = random.randint(0, img.size[0] - w)
return i, j, h, w return i, j, h, w
......
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