File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -268,8 +268,8 @@ def __call__(self, sample):
268268 h , w = image .shape [:2 ]
269269 new_h , new_w = self .output_size
270270
271- top = np .random .randint (0 , h - new_h )
272- left = np .random .randint (0 , w - new_w )
271+ top = np .random .randint (0 , h - new_h + 1 )
272+ left = np .random .randint (0 , w - new_w + 1 )
273273
274274 image = image [top : top + new_h ,
275275 left : left + new_w ]
@@ -294,7 +294,7 @@ def __call__(self, sample):
294294
295295######################################################################
296296# .. note::
297- # In the example above, `RandomCrop` uses an external library's random number generator
297+ # In the example above, `RandomCrop` uses an external library's random number generator
298298# (in this case, Numpy's `np.random.int`). This can result in unexpected behavior with `DataLoader`
299299# (see `here <https://pytorch.org/docs/stable/notes/faq.html#my-data-loader-workers-return-identical-random-numbers>`_).
300300# In practice, it is safer to stick to PyTorch's random number generator, e.g. by using `torch.randint` instead.
You can’t perform that action at this time.
0 commit comments