I have coded a custom transform class to generate N random crops with padding size and number of random crops:

  
      gist.github.com
  
  
    https://gist.github.com/amirhfarzaneh/66251288d07c67f6cfd23efc3c1143ad 287
custom_transform.py
import numbers
import random
from torchvision.transforms import functional as F
try:
    import accimage
except ImportError:
    accimage = None
from PIL import Image


This file has been truncated. show original




  
  
    
    
  
  


and here’s a test script:

  
      gist.github.com
  
  
    https://gist.github.com/amirhfarzaneh/96bfc5ea66fc44757fa4a6a869bc3db9 165
test_custom_transform.py
import torchvision.datasets as datasets
import torchvision.transforms as transforms
import torch
import torchvision
import matplotlib.pyplot as plt
import numpy as np

from custom_transforms import NRandomCrop


This file has been truncated. show original