MCPcopy Create free account
hub / github.com/OpenGVLab/HumanBench / __call__

Method __call__

PATH/core/augmentation.py:676–706  ·  view source on GitHub ↗
(self, img)

Source from the content-addressed store, hash-verified

674 self.p = p
675
676 def __call__(self, img):
677 p1 = random.uniform(-1, 1.0)
678 H, W = img.shape[:2]
679 area = H * W
680
681 if p1 > self.p:
682 return img
683 else:
684 gen = True
685 while gen:
686 Se = random.uniform(self.sl, self.sh)*area
687 re = random.uniform(self.asratio, 1/self.asratio)
688 He = np.sqrt(Se*re)
689 We = np.sqrt(Se/re)
690 xe = random.uniform(0, W-We)
691 ye = random.uniform(0, H-He)
692 if xe+We <= W and ye+He <= H and xe>0 and ye>0:
693 x1 = int(np.ceil(xe))
694 y1 = int(np.ceil(ye))
695 x2 = int(np.floor(x1+We))
696 y2 = int(np.floor(y1+He))
697 part1 = img[y1:y2, x1:x2]
698 Rc = random.randint(0, 255)
699 Gc = random.randint(0, 255)
700 Bc = random.randint(0, 255)
701 I = np.asarray(part1).astype(np.int8)
702 I[:,:,0] = Rc
703 I[:,:,1] = Gc
704 I[:,:,2] = Bc
705 img[y1:y2, x1:x2] = I
706 return img
707
708class BodySplit(object):
709 def __init__(self,extra_info=None,bg_type=0,aug_type=-1,split_prob=0.5):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected