MCPcopy Create free account
hub / github.com/Meshcapade/difflocks / CustomCrop

Class CustomCrop

utils/general_util.py:526–545  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

524
525
526class CustomCrop:
527 def __init__(self, crop_size,top_ratio, left_ratio):
528 self.top_ratio = top_ratio
529 self.left_ratio = left_ratio
530 self.crop_size = crop_size
531
532 def __call__(self, tensor):
533 _, h, w = tensor.shape
534
535 top_ratio = random.uniform(0.2,self.top_ratio)
536 left_ratio = random.uniform(0.3,0.7)
537
538 crop_size = random.randint(self.crop_size,h)
539
540 top = int((h-crop_size) * top_ratio)
541 left = int((w-crop_size) * left_ratio)
542
543 tensor_cropped = F.crop(tensor, top, left, self.crop_size, self.crop_size)
544
545 return tensor_cropped
546
547class HorizontalFlip(object):
548 def __call__(self, img):

Callers 1

get_transformFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected