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

Method __call__

PATH/core/augmentation.py:747–801  ·  view source on GitHub ↗
(self, raw_img,fname)

Source from the content-addressed store, hash-verified

745 return raw_img
746
747 def __call__(self, raw_img,fname):
748 if self.extra_info is None:
749 return raw_img
750 #name = fname.split('/')[-1]
751
752 if fname not in self.info.keys():
753 print("="*80)
754 print(fname)
755 return raw_img
756
757 head, _, mid, foot = self.info[fname]
758 if head<0:
759 return raw_img
760 if self.aug_type==0: #crop from ori img
761 if np.random.rand() <= self.split_prob and mid<=1 and mid>0.15:
762 h, w, c = raw_img.shape
763 mid=int(mid*h)
764 raw_img=raw_img[:mid]
765 if self.debug:
766 cv2.imwrite('test_split.jpg',raw_img)
767 print('save debug img to test_split.jpg')
768 self.debug=0
769 return raw_img
770 if self.aug_type==2: #random
771 if np.random.rand() <= self.split_prob and mid<=1 and mid>0.15:
772 h, w, c = raw_img.shape
773 mid=max(int(mid*h)//2,1)
774 crop_line=np.random.randint(low=mid,high=h)
775 raw_img=raw_img[:crop_line]
776 return raw_img
777 if self.aug_type==3: #blind_split
778 return self.blind_split(raw_img)
779
780 h, w, c = raw_img.shape
781
782 img = np.zeros((3*h, w, c))
783 if self.bg_type == 0:
784 #add mean -->background
785 img[:,:,0],img[:,:,1],img[:,:,2]=np.mean(raw_img[:,:,0]),np.mean(raw_img[:,:,1]),np.mean(raw_img[:,:,2])
786 if self.bg_type == 1: #black
787 pass
788 if self.bg_type == 2:#imagenet mean
789 img[:,:,0],img[:,:,1],img[:,:,2]=self.mean[0],self.mean[1],self.mean[2]
790 img[h*3 // 2:h + (h*3 // 2), :, :] = raw_img
791 start = int((head + 1.5) * h)
792 end = int((foot + 1.5) * h)
793
794 if start < end:
795 img=img[start:end].astype(np.uint8)
796
797 if self.aug_type==1: #for data augmentation
798 if np.random.rand() <= self.split_prob and (mid-head)>0.15:
799 mid=int((mid-head)*h)
800 img=img[:mid]
801 return img
802
803
804class BodyAlign(object):

Callers

nothing calls this directly

Calls 1

blind_splitMethod · 0.95

Tested by

no test coverage detected