def _get_dataflow_onlyread(path, is_train, img_path=None): ds = OpenOoseHand(path, is_train) # read data from lmdb ds = MapData(ds, read_image_url) ds = MapDataComponent(ds, crop_hand_roi_big) ds = MapDataComponent(ds, hand_random_scale) ds = MapDataComponent(ds, pose_rotation) ds = MapDataComponent(ds, pose_flip) ds = MapDataComponent(ds, crop_hand_roi) # ds = MapDataComponent(ds, pose_resize_shortestedge_fixed) # ds = MapDataComponent(ds, pose_crop_random) ds = MapData(ds, pose_to_img) ds = PrefetchData(ds, 10, 2) return ds
def _get_dataflow_onlyread(path, is_train, img_path=None): print('CocoPose-------------') ds = CocoPose(path, img_path, is_train) # read data from lmdb print('CocoPose======') ds = MapData(ds, read_image_url) ds = MapDataComponent(ds, pose_random_scale) ds = MapDataComponent(ds, pose_rotation) ds = MapDataComponent(ds, pose_flip) ds = MapDataComponent(ds, pose_resize_shortestedge_random) ds = MapDataComponent(ds, pose_crop_random) print('MapData-------------') ds = MapData(ds, pose_to_img) print('MapData======') # ds = PrefetchData(ds, 1000, multiprocessing.cpu_count() * 4) return ds
def get_dataflow(path, is_train, img_path=None): ds = CocoPose(path, img_path, is_train) # read data from lmdb if is_train: ds = MapData(ds, read_image_url) ds = MapDataComponent(ds, pose_random_scale) ds = MapDataComponent(ds, pose_rotation) ds = MapDataComponent(ds, pose_flip) ds = MapDataComponent(ds, pose_resize_shortestedge_random) ds = MapDataComponent(ds, pose_crop_random) ds = MapData(ds, pose_to_img) # augs = [ # imgaug.RandomApplyAug(imgaug.RandomChooseAug([ # imgaug.GaussianBlur(max_size=3) # ]), 0.7) # ] # ds = AugmentImageComponent(ds, augs) ds = PrefetchData(ds, 1000, multiprocessing.cpu_count() * 1) else: ds = MultiThreadMapData(ds, nr_thread=16, map_func=read_image_url, buffer_size=1000) ds = MapDataComponent(ds, pose_resize_shortestedge_fixed) ds = MapDataComponent(ds, pose_crop_center) ds = MapData(ds, pose_to_img) ds = PrefetchData(ds, 100, multiprocessing.cpu_count() // 4) return ds
def get_dataflow(path, is_train): ds = CocoPoseLMDB(path, is_train) # read data from lmdb if is_train: ds = MapDataComponent(ds, pose_random_scale) ds = MapDataComponent(ds, pose_rotation) ds = MapDataComponent(ds, pose_flip) ds = MapDataComponent(ds, pose_resize_shortestedge_random) ds = MapDataComponent(ds, pose_crop_random) ds = MapData(ds, pose_to_img) augs = [ imgaug.RandomApplyAug( imgaug.RandomChooseAug([ imgaug.BrightnessScale((0.6, 1.4), clip=False), imgaug.Contrast((0.7, 1.4), clip=False), imgaug.GaussianBlur(max_size=3) ]), 0.7), ] ds = AugmentImageComponent(ds, augs) else: ds = MapDataComponent(ds, pose_resize_shortestedge_fixed) ds = MapDataComponent(ds, pose_crop_center) ds = MapData(ds, pose_to_img) ds = PrefetchData(ds, 1000, multiprocessing.cpu_count()) return ds
def get_dataflow(path, is_train): ds = CocoPoseLMDB(path, is_train) # read data from lmdb if is_train: ds = MapDataComponent(ds, pose_random_scale) ds = MapDataComponent(ds, pose_rotation) ds = MapDataComponent(ds, pose_flip) ds = MapDataComponent(ds, pose_resize_shortestedge_random) ds = MapDataComponent(ds, pose_crop_random) ds = MapData(ds, pose_to_img) augs = [ imgaug.RandomApplyAug( imgaug.RandomChooseAug([ imgaug.SaltPepperNoise(white_prob=0.01, black_prob=0.01), imgaug.RandomOrderAug([ imgaug.BrightnessScale((0.8, 1.2), clip=False), imgaug.Contrast((0.8, 1.2), clip=False), # imgaug.Saturation(0.4, rgb=True), ]), ]), 0.7), ] ds = AugmentImageComponent(ds, augs) else: ds = MapDataComponent(ds, pose_resize_shortestedge_fixed) ds = MapDataComponent(ds, pose_crop_center) ds = MapData(ds, pose_to_img) ds = PrefetchData(ds, 1000, multiprocessing.cpu_count()) return ds
def get_dataflow(is_train): ds = CocoPoseLMDB('/data/public/rw/coco-pose-estimation-lmdb/', is_train) if is_train: ds = MapDataComponent(ds, pose_rotation) ds = MapDataComponent(ds, pose_flip) ds = MapDataComponent(ds, pose_resize_shortestedge_random) ds = MapDataComponent(ds, pose_crop_random) ds = MapData(ds, pose_to_img) augs = [ imgaug.RandomApplyAug(imgaug.RandomChooseAug([ imgaug.SaltPepperNoise(white_prob=0.01, black_prob=0.01), imgaug.RandomOrderAug([ imgaug.BrightnessScale((0.8, 1.2), clip=False), imgaug.Contrast((0.8, 1.2), clip=False), # imgaug.Saturation(0.4, rgb=True), ]), ]), 0.7), ] ds = AugmentImageComponent(ds, augs) else: ds = MapDataComponent(ds, pose_resize_shortestedge_fixed) ds = MapDataComponent(ds, pose_crop_center) ds = MapData(ds, pose_to_img) return ds
def get_dataflow(path, is_train=True, img_path=None,sigma=8.0,output_shape=(1440,2560), numparts=5,translation=False,scale=False,rotation=True, mins=0.25,maxs=1.2,mina=-np.pi,maxa=np.pi ,ilumination=0.0,image_type='RGB'): print('Creating images from',path) numparts, skeleton = get_skeleton_from_json(path) #numparts + 1 because need to the background ds = CocoPose(path, img_path, is_train, numparts=numparts + 1, sigma=sigma,skeleton=skeleton, output_shape=output_shape, translation=translation,scale=scale,rotation=rotation, mins=mins,maxs=maxs,mina=mina,maxa=maxa, ilumination=ilumination,image_type=image_type ) # read data from lmdb if is_train: #ds = MapData(ds, read_image_url) ds = MultiThreadMapData(ds, nr_thread=8, map_func=read_image_url, buffer_size=10) ds = MapDataComponent(ds, get_augmented_image) #ds = MapDataComponent(ds, pose_rotation) #ds = MapDataComponent(ds, pose_flip) #ds = MapDataComponent(ds, pose_resize_shortestedge_random) #ds = MapDataComponent(ds, pose_crop_random) #logger.info('Out of new augmenter') ds = MapData(ds, pose_to_img) #logger.info('Out pose to img') # augs = [ # imgaug.RandomApplyAug(imgaug.RandomChooseAug([ # imgaug.GaussianBlur(max_size=3) # ]), 0.7) # ] # ds = AugmentImageComponent(ds, augs) ds = PrefetchData(ds, 10, multiprocessing.cpu_count() * 1) else: #ds = MultiThreadMapData(ds, nr_thread=4, map_func=read_image_url, buffer_size=10) ds = MapData(ds, read_image_url) #ds = MapDataComponent(ds, pose_resize_shortestedge_fixed) #ds = MapDataComponent(ds, pose_crop_center) ds = MapData(ds, pose_to_img) ds = PrefetchData(ds, 10, multiprocessing.cpu_count() // 4) return ds
def get_dataflow(path, is_train, img_path=None): ds = OpenOoseHand(path, is_train) # read data from lmdb # if is_train: # ''' # ds is a DataFlow Object which must implement get_data() function # MapData(ds, func) will apply func to data returned by ds.get_data() # 1. create an obj # 2. obj.ds = ds # 2. obj.get_data(): # data = self.ds.get_data() # yield self.func(data) # MapDataComponent(ds, func) will do similar thing # the main different is the target of MapDataComponent(...) # is the returned data of get_data() # ''' # ds = MapData(ds, read_image_url) # ds = MapDataComponent(ds, pose_random_scale) # ds = MapDataComponent(ds, pose_rotation) # ds = MapDataComponent(ds, pose_flip) # ds = MapDataComponent(ds, pose_resize_shortestedge_random) # ds = MapDataComponent(ds, pose_crop_random) # # use joint_list to draw two point and vector heatmap # ds = MapData(ds, pose_to_img) # # augs = [ # # imgaug.RandomApplyAug(imgaug.RandomChooseAug([ # # imgaug.GaussianBlur(max_size=3) # # ]), 0.7) # # ] # # ds = AugmentImageComponent(ds, augs) # # ds = PrefetchData(ds, 10, multiprocessing.cpu_count() * 4) # ds = PrefetchData(ds, 2, 1) # else: # ds = MultiThreadMapData(ds, nr_thread=16, map_func=read_image_url, buffer_size=1000) # ds = MapDataComponent(ds, pose_resize_shortestedge_fixed) # ds = MapDataComponent(ds, pose_crop_center) # ds = MapData(ds, pose_to_img) # ds = PrefetchData(ds, 10, multiprocessing.cpu_count() // 4) if is_train: ''' ds is a DataFlow Object which must implement get_data() function MapData(ds, func) will apply func to data returned by ds.get_data() 1. create an obj 2. obj.ds = ds 2. obj.get_data(): data = self.ds.get_data() yield self.func(data) MapDataComponent(ds, func) will do similar thing the main different is the target of MapDataComponent(...) is the returned data of get_data() ''' ds = MapData(ds, read_image_url) ds = MapDataComponent(ds, crop_hand_roi_big) ds = MapDataComponent(ds, hand_random_scale) ds = MapDataComponent(ds, pose_rotation) ds = MapDataComponent(ds, pose_flip) ds = MapDataComponent(ds, crop_hand_roi) # ds = MapDataComponent(ds, pose_resize_shortestedge_fixed) # ds = MapDataComponent(ds, pose_crop_random) ds = MapData(ds, pose_to_img) ds = PrefetchData(ds, 20, 1) else: ds = MultiThreadMapData(ds, nr_thread=1, map_func=read_image_url, buffer_size=5) ds = MapDataComponent(ds, crop_hand_roi_big) ds = MapDataComponent(ds, pose_resize_shortestedge_fixed) ds = MapDataComponent(ds, pose_crop_center) ds = MapData(ds, pose_to_img) ds = PrefetchData(ds, 2, 2) return ds