question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add random crop transform

See original GitHub issue

🚀 Feature

Add random crop as a transformer apart from the LabelSampler.

Motivation

I’m doing patch based segmentation. My images are relatively large 512x512x512 and I only take patches of size 128x128x64. I’m now currently applying random affine on the entire image, but this process is too slow. Therefore, it would be nice to apply a random crop to get images of size 256x256x128, then apply a random affine, then extract patches.

Or is there any other better way to reduce the compute here?

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
jxchen01commented, Jan 26, 2022

hmm… interesting. I want to give it shot and try to make a PR.

1reaction
mathpluscodecommented, Jun 13, 2021

Hi, @mathpluscode. Nice to see you here. Would the example in #205 (comment) work?

If the reading time is another bottleneck, we could implement a reader that uses NiBabel’s memmap to perform the random crop at reading time. Please let me know.

Hi @fepegar, thanks for the quick reply! Yes this example sounds enough for my application. Will try it and let you know if it works still!

Read more comments on GitHub >

github_iconTop Results From Across the Web

RandomCrop — Torchvision main documentation - PyTorch
class torchvision.transforms.RandomCrop(size, padding=None, pad_if_needed=False, fill=0, ... Crop the given image at a random location.
Read more >
Why and How to Implement Random Crop Data Augmentation
Random crop is a data augmentation technique wherein we create a random subset of an original image. This helps our model generalize better ......
Read more >
PyTorch – How to crop an image at a random location?
Steps · Import the required libraries. · Read the input image. · Define a transform to crop the image at random location. ·...
Read more >
How to crop an image at random location in PyTorch
Cropping is a technique of removal of unwanted outer areas from an image to achieve this we use a method in python that...
Read more >
Crop transforms (augmentations.crops.transforms)
* If a tuple of two int s with values a and b , then each side will be cropped/padded by a random...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found