def __init__( self, device, batch_size, num_threads=1, device_id=0, num_gpus=1, crop_shape=(224, 224), crop_x=0.3, crop_y=0.2, is_fused_decoder=False, ): super(CropPipeline, self).__init__(batch_size, num_threads, device_id) self.is_fused_decoder = is_fused_decoder self.device = device self.input = ops.CaffeReader(path=caffe_db_folder, shard_id=device_id, num_shards=num_gpus) if self.is_fused_decoder: self.decode = ops.ImageDecoderCrop(device="cpu", crop=crop_shape, crop_pos_x=crop_x, crop_pos_y=crop_y, output_type=types.RGB) else: self.decode = ops.ImageDecoder(device="cpu", output_type=types.RGB) self.crop = ops.Crop(device=self.device, crop=crop_shape, crop_pos_x=crop_x, crop_pos_y=crop_y)
def __init__(self, path, batch_size, num_threads=1, device_id=0, num_gpus=1): super(CaffeReaderPipeline, self).__init__(batch_size, num_threads, device_id) self.input = ops.CaffeReader(path = path, shard_id = device_id, num_shards = num_gpus) self.decode = ops.ImageDecoderCrop(device = "cpu", crop = (224, 224), crop_pos_x = 0.3, crop_pos_y = 0.2, output_type = types.RGB)
def __init__( self, train=False, batch_size=16, size=384, num_threads=4, device_id=0 ): super(ExternalSourcePipeline, self).__init__( batch_size, num_threads, device_id, seed=42 ) self.eii = iter( ExternalInputIterator(train, batch_size) ) self.images_input = ops.ExternalSource() self.masks_input = ops.ExternalSource() if train: fixed_area = (size / 784)**2 self.decode = ops.ImageDecoderRandomCrop( device="mixed", random_area=[fixed_area*0.7, fixed_area*1.3], random_aspect_ratio=[0.7, 1.3], ) else: self.decode = ops.ImageDecoderCrop( device="mixed", crop=(size, size) ) self.resize = ops.Resize( device="gpu", interp_type=types.INTERP_TRIANGULAR, resize_x=size, resize_y=size ) self.mask_resize = ops.Resize( device="gpu", interp_type=types.INTERP_NN, resize_x=size, resize_y=size ) self.normalize = ops.CropMirrorNormalize( device="gpu", mean=[0.5 * 255], # 0.456 * 255, 0.406 * 255], std=[0.5 * 255], # , 0.224 * 255, 0.225 * 255], output_layout=types.NCHW ) self.mask_normalize = ops.CropMirrorNormalize( device="gpu", mean=[0], std=[255], output_layout=types.NCHW, image_type=types.GRAY, ) # extra augmentations self.to_gray = ops.ColorSpaceConversion( device="gpu", image_type=types.RGB, output_type=types.GRAY ) self.contrast = ops.BrightnessContrast(device="gpu") self.hsv = ops.Hsv(device="gpu") self.jitter = ops.Jitter(device ="gpu") # self.rng1 = ops.Uniform(range=[0, 1]) self.rng2 = ops.Uniform(range=[0.8,1.2]) self.rng3 = ops.Uniform(range=[-30, 30]) # for hue self.coin03 = ops.CoinFlip(probability=0.3) self.train = train