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

Method __call__

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

Source from the content-addressed store, hash-verified

18 self.trans_aug = trans_aug
19 self.flip = flip
20 def __call__(self, img):
21 ## transform
22 scale_diff_h = (np.random.rand()*2-1)*self.scale_aug
23 scale_diff_w = (np.random.rand()*2-1)*self.scale_aug
24 crop_aug_h = self.crop_size*(1+scale_diff_h)
25 crop_aug_w = self.crop_size*(1+scale_diff_w)
26
27 trans_diff_h = (np.random.rand()*2-1)*self.trans_aug
28 trans_diff_w = (np.random.rand()*2-1)*self.trans_aug
29
30 w, h = img.size
31 ct_x = w/2*(1+trans_diff_w)
32 ct_y = (h/2+self.crop_center_y_offset)*(1+trans_diff_h)
33
34 if ct_x < crop_aug_w/2:
35 crop_aug_w = ct_x*2 - 0.5
36 if ct_y < crop_aug_h/2:
37 crop_aug_h = ct_y*2 - 0.5
38 if ct_x + crop_aug_w/2 >= w:
39 crop_aug_w = (w-ct_x)*2 - 0.5
40 if ct_y + crop_aug_h/2 >= h:
41 crop_aug_h = (h-ct_y)*2 - 0.5
42
43 rect = (ct_x-crop_aug_w/2, ct_y-crop_aug_h/2, ct_x+crop_aug_w/2, ct_y+crop_aug_h/2)
44 img = img.resize((self.final_size, self.final_size), box=rect)
45
46 ## to BGR
47 img = np.array(img)
48 img = img[:,:,[2,1,0]]
49
50 return img
51
52class FaceAugmentationCV2(object):
53 def __init__(self, crop_size, final_size, crop_center_x_offset, \

Callers

nothing calls this directly

Calls 1

resizeMethod · 0.80

Tested by

no test coverage detected