Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cropping to include last column and last row #2384

Merged
merged 2 commits into from
Jun 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions beginner_source/data_loading_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,8 @@ def __call__(self, sample):
h, w = image.shape[:2]
new_h, new_w = self.output_size

top = np.random.randint(0, h - new_h)
left = np.random.randint(0, w - new_w)
top = np.random.randint(0, h - new_h + 1)
left = np.random.randint(0, w - new_w + 1)

image = image[top: top + new_h,
left: left + new_w]
Expand All @@ -294,7 +294,7 @@ def __call__(self, sample):

######################################################################
# .. note::
# In the example above, `RandomCrop` uses an external library's random number generator
# In the example above, `RandomCrop` uses an external library's random number generator
# (in this case, Numpy's `np.random.int`). This can result in unexpected behavior with `DataLoader`
# (see `here <https://pytorch.org/docs/stable/notes/faq.html#my-data-loader-workers-return-identical-random-numbers>`_).
# In practice, it is safer to stick to PyTorch's random number generator, e.g. by using `torch.randint` instead.
Expand Down