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

Method __call__

PATH/core/data/transforms/reid_transforms.py:443–497  ·  view source on GitHub ↗
(self, raw_img,fname)

Source from the content-addressed store, hash-verified

441 return raw_img
442
443 def __call__(self, raw_img,fname):
444 if self.extra_info is None:
445 return raw_img
446 #name = fname.split('/')[-1]
447
448 if fname not in self.info.keys():
449 print("="*80)
450 print(fname)
451 return raw_img
452
453 head, _, mid, foot = self.info[fname]
454 if head<0:
455 return raw_img
456 if self.aug_type==0: #crop from ori img
457 if np.random.rand() <= self.split_prob and mid<=1 and mid>0.15:
458 h, w, c = raw_img.shape
459 mid=int(mid*h)
460 raw_img=raw_img[:mid]
461 if self.debug:
462 cv2.imwrite('test_split.jpg',raw_img)
463 print('save debug img to test_split.jpg')
464 self.debug=0
465 return raw_img
466 if self.aug_type==2: #random
467 if np.random.rand() <= self.split_prob and mid<=1 and mid>0.15:
468 h, w, c = raw_img.shape
469 mid=max(int(mid*h)//2,1)
470 crop_line=np.random.randint(low=mid,high=h)
471 raw_img=raw_img[:crop_line]
472 return raw_img
473 if self.aug_type==3: #blind_split
474 return self.blind_split(raw_img)
475
476 h, w, c = raw_img.shape
477
478 img = np.zeros((3*h, w, c))
479 if self.bg_type == 0:
480 #add mean -->background
481 img[:,:,0],img[:,:,1],img[:,:,2]=np.mean(raw_img[:,:,0]),np.mean(raw_img[:,:,1]),np.mean(raw_img[:,:,2])
482 if self.bg_type == 1: #black
483 pass
484 if self.bg_type == 2:#imagenet mean
485 img[:,:,0],img[:,:,1],img[:,:,2]=self.mean[0],self.mean[1],self.mean[2]
486 img[h*3 // 2:h + (h*3 // 2), :, :] = raw_img
487 start = int((head + 1.5) * h)
488 end = int((foot + 1.5) * h)
489
490 if start < end:
491 img=img[start:end].astype(np.uint8)
492
493 if self.aug_type==1: #for data augmentation
494 if np.random.rand() <= self.split_prob and (mid-head)>0.15:
495 mid=int((mid-head)*h)
496 img=img[:mid]
497 return img
498
499
500class BodyAlign(object):

Callers

nothing calls this directly

Calls 1

blind_splitMethod · 0.95

Tested by

no test coverage detected