Beispiel #1
0
    def __init__(self,
                 batch_size,
                 device,
                 data_dir,
                 mean,
                 std,
                 device_id=0,
                 shard_id=0,
                 num_shards=1,
                 num_threads=4,
                 seed=0):
        super(DaliTransformsValPipeline,
              self).__init__(batch_size, num_threads, device_id, seed)

        # should we make this drive the device flags?
        self.reader = ops.FileReader(file_root=data_dir,
                                     shard_id=shard_id,
                                     num_shards=num_shards,
                                     random_shuffle=False)

        self.decode = ops.ImageDecoder(device='mixed',
                                       output_type=types.RGB,
                                       memory_stats=True)
        self.resize = ops.Resize(device=device,
                                 size=[200, 300],
                                 interp_type=types.INTERP_TRIANGULAR)

        self.normalize = ops.CropMirrorNormalize(device=device,
                                                 dtype=types.FLOAT,
                                                 output_layout=types.NCHW)  #,
        #mean=mean*255, std=std*255)

        #self.normalize = ops.Normalize(device=device, dtype=types.FLOAT)#, mean=mean, stddev=std)
        self.to_int64 = ops.Cast(dtype=types.INT64, device=device)
Beispiel #2
0
    def __init__(self,
                 device,
                 batch_size,
                 pos_size_iter,
                 num_threads=1,
                 device_id=0,
                 is_fused_decoder=False,
                 axes=None,
                 axis_names=None,
                 normalized_anchor=True,
                 normalized_shape=True):
        super(SlicePipeline, self).__init__(batch_size,
                                            num_threads,
                                            device_id,
                                            seed=1234)
        self.is_fused_decoder = is_fused_decoder
        self.pos_size_iter = pos_size_iter
        self.device = device
        self.input = ops.CaffeReader(path=caffe_db_folder,
                                     random_shuffle=False)
        self.input_crop_pos = ops.ExternalSource()
        self.input_crop_size = ops.ExternalSource()

        if self.is_fused_decoder:
            if axis_names:
                self.decode = ops.ImageDecoderSlice(
                    device="cpu",
                    output_type=types.RGB,
                    normalized_anchor=normalized_anchor,
                    normalized_shape=normalized_shape,
                    axis_names=axis_names)
            elif axes:
                self.decode = ops.ImageDecoderSlice(
                    device="cpu",
                    output_type=types.RGB,
                    normalized_anchor=normalized_anchor,
                    normalized_shape=normalized_shape,
                    axes=axes)
            else:
                self.decode = ops.ImageDecoderSlice(
                    device="cpu",
                    output_type=types.RGB,
                    normalized_anchor=normalized_anchor,
                    normalized_shape=normalized_shape)
        else:
            self.decode = ops.ImageDecoder(device="cpu", output_type=types.RGB)
            if axis_names:
                self.slice = ops.Slice(device=self.device,
                                       normalized_anchor=normalized_anchor,
                                       normalized_shape=normalized_shape,
                                       axis_names=axis_names)
            elif axes:
                self.slice = ops.Slice(device=self.device,
                                       normalized_anchor=normalized_anchor,
                                       normalized_shape=normalized_shape,
                                       axes=axes)
            else:
                self.slice = ops.Slice(device=self.device,
                                       normalized_anchor=normalized_anchor,
                                       normalized_shape=normalized_shape)
Beispiel #3
0
    def __init__(self,
                 batch_size,
                 num_threads,
                 device_id,
                 data_dir,
                 crop,
                 size,
                 local_rank=0,
                 world_size=1):
        super(HybridValPipe, self).__init__(batch_size,
                                            num_threads,
                                            device_id,
                                            seed=12 + device_id)

        self.input = ops.FileReader(file_root=data_dir,
                                    shard_id=local_rank,
                                    num_shards=world_size,
                                    random_shuffle=False)

        self.decode = ops.ImageDecoder(device="mixed", output_type=types.RGB)

        self.res = ops.Resize(device="gpu",
                              resize_shorter=size,
                              interp_type=types.INTERP_TRIANGULAR)

        self.cmnp = ops.CropMirrorNormalize(
            device="gpu",
            output_dtype=types.FLOAT,
            output_layout=types.NCHW,
            crop=(crop, crop),
            image_type=types.RGB,
            mean=[0.485 * 255, 0.456 * 255, 0.406 * 255],
            std=[0.229 * 255, 0.224 * 255, 0.225 * 255])
Beispiel #4
0
 def __init__(self,
              batch_size,
              num_threads,
              device_id,
              pipelined=True,
              exec_async=True):
     super(HybridPipe, self).__init__(batch_size,
                                      num_threads,
                                      device_id,
                                      exec_pipelined=pipelined,
                                      exec_async=exec_async)
     self.input = ops.ExternalSource()
     self.decode = ops.ImageDecoder(device="mixed", output_type=types.RGB)
     self.resize = ops.Resize(device="gpu",
                              image_type=types.RGB,
                              interp_type=types.INTERP_LINEAR)
     self.cmnp = ops.CropMirrorNormalize(device="gpu",
                                         output_dtype=types.FLOAT16,
                                         crop=(224, 224),
                                         image_type=types.RGB,
                                         mean=[128., 128., 128.],
                                         std=[1., 1., 1.])
     self.uniform = ops.Uniform(range=(0., 1.))
     self.resize_uniform = ops.Uniform(range=(256., 480.))
     self.mirror = ops.CoinFlip(probability=0.5)
    def __init__(self, batch_size, num_threads, device_id):
        super(TFRecordPipeline, self).__init__(batch_size,
                                         num_threads,
                                         device_id)
        self.input = ops.TFRecordReader(path = tfrecord,
                                        index_path = tfrecord_idx,
                                        features = {"image/encoded" : tfrec.FixedLenFeature((), tfrec.string, ""),
                                         'image/filename':            tfrec.FixedLenFeature([ ], tfrec.string, ''),
                                         'image/height':              tfrec.FixedLenFeature([1], tfrec.int64,  -1),
                                         'image/width':               tfrec.FixedLenFeature([1], tfrec.int64,  -1),
                                         'image/colorspace':          tfrec.FixedLenFeature([ ], tfrec.string, ''),
                                         'image/channels':            tfrec.FixedLenFeature([1], tfrec.int64,  -1),
                                         'image/format':              tfrec.FixedLenFeature([ ], tfrec.string, ''),
                                         'image/class/label':         tfrec.FixedLenFeature([1], tfrec.int64,  -1),
                                         'image/class/synset':        tfrec.FixedLenFeature([ ], tfrec.string, ''),
                                         'image/class/text':          tfrec.FixedLenFeature([ ], tfrec.string, ''),
                                         'image/object/bbox/xmin':    tfrec.VarLenFeature(tfrec.float32, 0.0),
                                         'image/object/bbox/ymin':    tfrec.VarLenFeature(tfrec.float32, 0.0),
                                         'image/object/bbox/xmax':    tfrec.VarLenFeature(tfrec.float32, 0.0),
                                         'image/object/bbox/ymax':    tfrec.VarLenFeature(tfrec.float32, 0.0),
                                         'image/object/bbox/label':   tfrec.FixedLenFeature([1], tfrec.int64, -1)})
        self.decode = ops.ImageDecoder(device = "mixed", output_type = types.RGB)

        self.resize = ops.Resize(device = "gpu", resize_x = 1920.,resize_y=1920.)
        self.vert_flip = ops.Flip(device = "gpu", horizontal=0)
        self.vert_coin = ops.CoinFlip(probability=0.5)
        self.cmnp = ops.CropMirrorNormalize(device = "gpu",
                                            output_dtype = types.FLOAT,
                                            crop = (1920, 1920),
                                            image_type = types.RGB,
                                            mean = [0., 0., 0.],
                                            std = [1., 1., 1.])
        self.uniform = ops.Uniform(range = (0.0, 1.0))
        self.iter = 0
Beispiel #6
0
 def __init__(self,
              batch_size,
              num_threads,
              device,
              device_id=0,
              shard_id=0,
              num_shards=1,
              seed=0):
     super(TestPipeline, self).__init__(batch_size, num_threads, device_id,
                                        seed)
     self.device = device
     self.input = ops.COCOReader(file_root=file_root,
                                 annotations_file=annotations_file,
                                 shard_id=shard_id,
                                 num_shards=num_shards,
                                 ratio=False,
                                 save_img_ids=True)
     self.decode = ops.ImageDecoder(
         device='mixed' if device is 'gpu' else 'cpu',
         output_type=types.RGB)
     self.resize = ops.Resize(device=device,
                              image_type=types.RGB,
                              resize_x=224,
                              resize_y=224,
                              interp_type=types.INTERP_LINEAR)
     self.cmn = ops.CropMirrorNormalize(device=device,
                                        output_dtype=types.FLOAT,
                                        image_type=types.RGB,
                                        mean=[128., 128., 128.],
                                        std=[1., 1., 1.])
     self.cast = ops.Cast(device=device, dtype=types.INT16)
Beispiel #7
0
 def __init__(self,
              batch_size,
              num_threads,
              shard_id,
              image_dir,
              file_list,
              nvjpeg_padding,
              seed=1,
              num_shards=1,
              channel_last=True,
              dtype='half'):
     super(ValPipeline, self).__init__(batch_size,
                                       num_threads,
                                       shard_id,
                                       seed=seed)
     self.input = ops.FileReader(file_root=image_dir,
                                 file_list=file_list,
                                 random_shuffle=False,
                                 num_shards=num_shards,
                                 shard_id=shard_id)
     self.decode = ops.ImageDecoder(device="mixed",
                                    output_type=types.RGB,
                                    device_memory_padding=nvjpeg_padding,
                                    host_memory_padding=nvjpeg_padding)
     self.res = ops.Resize(device="gpu", resize_shorter=256)
     self.cmnp = ops.CropMirrorNormalize(
         device="gpu",
         output_dtype=types.FLOAT16 if dtype == "half" else types.FLOAT,
         output_layout=types.NHWC if channel_last else types.NCHW,
         crop=(224, 224),
         image_type=types.RGB,
         mean=_pixel_mean,
         std=_pixel_std,
         pad_output=True)
Beispiel #8
0
 def __init__(self,
              batch_size,
              num_threads,
              device_id,
              data_dir,
              crop,
              dali_cpu=False,
              local_rank=0,
              world_size=1):
     super(HybridTrainPipe, self).__init__(batch_size,
                                           num_threads,
                                           device_id,
                                           seed=12 + device_id)
     dali_device = "gpu"
     self.input = ops.FileReader(file_root=data_dir,
                                 shard_id=local_rank,
                                 num_shards=world_size,
                                 random_shuffle=True)
     self.decode = ops.ImageDecoder(device="mixed", output_type=types.RGB)
     self.res = ops.RandomResizedCrop(device="gpu",
                                      size=crop,
                                      random_area=[0.08, 1.25])
     self.cmnp = ops.CropMirrorNormalize(
         device="gpu",
         output_dtype=types.FLOAT,
         output_layout=types.NCHW,
         image_type=types.RGB,
         mean=[0.485 * 255, 0.456 * 255, 0.406 * 255],
         std=[0.229 * 255, 0.224 * 255, 0.225 * 255])
     self.coin = ops.CoinFlip(probability=0.5)
     print('DALI "{0}" variant'.format(dali_device))
Beispiel #9
0
    def __init__(self,
                 batch_size,
                 pos_size_iter,
                 num_threads=1,
                 device_id=0,
                 num_gpus=1,
                 axes=None,
                 axis_names=None,
                 normalized_anchor=True,
                 normalized_shape=True):
        super(SlicePythonOp, self).__init__(batch_size,
                                            num_threads,
                                            device_id,
                                            seed=12345,
                                            exec_async=False,
                                            exec_pipelined=False)
        self.device = "cpu"
        self.layout = "HWC"
        self.pos_size_iter = pos_size_iter

        self.input = ops.CaffeReader(path=caffe_db_folder,
                                     random_shuffle=False)
        self.decode = ops.ImageDecoder(device='cpu', output_type=types.RGB)

        self.input_crop_pos = ops.ExternalSource()
        self.input_crop_size = ops.ExternalSource()

        function = partial(slice_func_helper, axes, axis_names, self.layout,
                           normalized_anchor, normalized_shape)
        self.slice = ops.PythonFunction(function=function)
    def __init__(self,
                 batch_size,
                 num_threads,
                 device_id,
                 data_dir,
                 crop,
                 size=256,
                 dali_cpu=False,
                 local_rank=0,
                 world_size=1):
        super(HybridTrainPipe, self).__init__(batch_size,
                                              num_threads,
                                              device_id,
                                              seed=12 + device_id)
        dali_device = "gpu"
        self.input = ops.FileReader(file_root=data_dir,
                                    shard_id=local_rank,
                                    num_shards=world_size,
                                    random_shuffle=True)
        self.decode = ops.ImageDecoder(device="mixed", output_type=types.RGB)
        # self.res = ops.Resize(device="gpu", resize_x=size, resize_y=size, interp_type=types.INTERP_LINEAR)
        self.res = ops.Resize(device="gpu",
                              resize_shorter=size,
                              interp_type=types.INTERP_LINEAR)
        self.rescrop = ops.RandomResizedCrop(device="gpu",
                                             size=crop,
                                             random_area=[0.08, 1.25])
        self.bc = ops.BrightnessContrast(device="gpu",
                                         brightness=0.5,
                                         contrast=0.6)

        # Will flip vertically with prob of 0.1
        self.vert_flip = ops.Flip(device='gpu', horizontal=0)
        self.vert_coin = ops.CoinFlip(probability=0.4)

        self.transform_source = ops.ExternalSource()
        self.warp_keep_size = ops.WarpAffine(
            device="gpu",
            # size                              # keep original canvas size
            interp_type=types.INTERP_LINEAR  # use linear interpolation
        )

        # My workaround for Dali not supporting random affine transforms:
        # a "synthetic random" warp affine transform.

        # Rotate within a narrow range with probability of 0.075
        self.rotate = ops.Rotate(device='gpu')
        self.rotate_range = ops.Uniform(range=(-20.0, 20.0))
        self.rotate_coin = ops.CoinFlip(probability=0.075)

        self.cmnp = ops.CropMirrorNormalize(
            device="gpu",
            output_dtype=types.FLOAT,
            output_layout=types.NCHW,
            image_type=types.RGB,
            mean=[0.485 * 255, 0.456 * 255, 0.406 * 255],
            std=[0.229 * 255, 0.224 * 255, 0.225 * 255])
        self.coin = ops.CoinFlip(probability=0.5)
        print('DALI "{0}" variant'.format(dali_device))
Beispiel #11
0
    def __init__(self,
                 args,
                 batch_size,
                 num_threads,
                 device_id,
                 rec_path,
                 idx_path,
                 shard_id,
                 num_shards,
                 crop_shape,
                 nvjpeg_padding,
                 prefetch_queue=3,
                 output_layout=types.NCHW,
                 pad_output=True,
                 dtype='float16',
                 dali_cpu=False):
        super(HybridTrainPipe,
              self).__init__(batch_size,
                             num_threads,
                             device_id,
                             seed=12 + device_id,
                             prefetch_queue_depth=prefetch_queue)
        self.input = ops.MXNetReader(path=[rec_path],
                                     index_path=[idx_path],
                                     random_shuffle=True,
                                     shard_id=shard_id,
                                     num_shards=num_shards)

        dali_device, decoder_device = get_device_names(dali_cpu)
        if args.dali_fuse_decoder:
            self.decode = ops.ImageDecoderRandomCrop(
                device=decoder_device,
                output_type=types.RGB,
                device_memory_padding=nvjpeg_padding,
                host_memory_padding=nvjpeg_padding)
        else:
            self.decode = ops.ImageDecoder(
                device=decoder_device,
                output_type=types.RGB,
                device_memory_padding=nvjpeg_padding,
                host_memory_padding=nvjpeg_padding)

        if args.dali_fuse_decoder:
            self.resize = ops.Resize(device=dali_device,
                                     resize_x=crop_shape[1],
                                     resize_y=crop_shape[0])
        else:
            self.resize = ops.RandomResizedCrop(device=dali_device,
                                                size=crop_shape)

        self.cmnp = ops.CropMirrorNormalize(
            device="gpu",
            dtype=types.FLOAT16 if dtype == 'float16' else types.FLOAT,
            output_layout=output_layout,
            crop=crop_shape,
            pad_output=pad_output,
            mean=args.rgb_mean,
            std=args.rgb_std)
        self.coin = ops.random.CoinFlip(probability=0.5)
Beispiel #12
0
 def __init__(self, batch_size, output_type, input_type, fixed_size, num_threads=3, device_id=0, num_gpus=1):
     super(CVPipeline, self).__init__(batch_size, num_threads, device_id, seed=7865, exec_async=False, exec_pipelined=False)
     self.name = "cv"
     self.input = ops.CaffeReader(path = caffe_db_folder, shard_id = device_id, num_shards = num_gpus)
     self.decode = ops.ImageDecoder(device = "cpu", output_type = types.RGB)
     self.rotate = ops.PythonFunction(function=CVRotate(output_type, input_type, fixed_size))
     self.uniform = ops.Uniform(range = (-180.0, 180.0), seed = 42);
     self.iter = 0
Beispiel #13
0
 def __init__(self, batch_size, num_threads, device_id):
     super(SimplePipeline, self).__init__(batch_size,
                                          num_threads,
                                          device_id,
                                          seed=12)
     self.input = ops.FileReader(file_root=image_dir)
     self.decode = ops.ImageDecoder(device='cpu', output_type=types.RGB)
     self.custom = ops.CustomDummy(fn_ptr=hello_cfunc.address)
Beispiel #14
0
 def __init__(self, device, batch_size, num_threads=1, device_id=0, num_gpus=1, is_vertical=0, is_horizontal=1 ):
     super(FlipPipeline, self).__init__(batch_size,
                                        num_threads,
                                        device_id)
     self.device = device
     self.input = ops.CaffeReader(path = caffe_db_folder, shard_id = device_id, num_shards = num_gpus)
     self.decode = ops.ImageDecoder(device = "cpu", output_type = types.RGB)
     self.flip = ops.Flip(device = self.device, vertical=is_vertical, horizontal=is_horizontal)
Beispiel #15
0
 def __init__(self, device, batch_size, use_wildcard, num_threads=3, device_id=0, num_gpus=1):
     super(ReshapeWithInput, self).__init__(batch_size, num_threads, device_id, seed=7865, exec_async=False, exec_pipelined=False)
     self.device = device
     self.input = ops.CaffeReader(path = caffe_db_folder, shard_id = device_id, num_shards = num_gpus)
     self.decode = ops.ImageDecoder(device = "cpu", output_type = types.RGB)
     fn = CollapseChannelsWildcard if use_wildcard else CollapseChannels
     self.gen_shapes = ops.PythonFunction(function=fn)
     self.reshape = ops.Reshape(device = device, layout = "ab");
Beispiel #16
0
 def __init__(self, device):
     super(CommonPipeline, self).__init__(BATCH_SIZE, NUM_WORKERS, DEVICE_ID, seed=SEED,
                                          exec_async=False, exec_pipelined=False)
     self.input = ops.FileReader(file_root=images_dir)
     self.decode = ops.ImageDecoder(device='mixed' if device == 'gpu' else 'cpu',
                                    output_type=types.RGB)
     self.resize = ops.Resize(resize_x=400, resize_y=400, device=device)
     self.flip = ops.Flip(device=device)
Beispiel #17
0
    def __init__(self, target_size, preproc_param, training=False):
        self.training = training
        mean = preproc_param.MEAN
        std = preproc_param.STD
        bri_delta = preproc_param.BRI_DELTA
        hue_delta = preproc_param.HUE_DELTA
        max_expand_ratio = preproc_param.MAX_EXPAND_RATIO
        contrast_range = preproc_param.CONTRAST_RANGE
        saturation_range = preproc_param.SATURATION_RANGE
        crop_aspect_ratio = preproc_param.CROP_ASPECT_RATIO
        crop_scale = preproc_param.CROP_SCALE
        crop_attempts = preproc_param.CROP_ATTEMPTS

        # decoder
        self.decode_train = ops.ImageDecoderSlice(device="mixed", output_type=types.RGB)
        self.decode_infer = ops.ImageDecoder(device="mixed", output_type=types.RGB)

        # ssd crop
        self.bbox_crop = ops.RandomBBoxCrop(
            device="cpu",
            bbox_layout="xyXY",
            scaling=crop_scale,
            aspect_ratio=crop_aspect_ratio,
            allow_no_crop=True,
            thresholds=[0, 0.1, 0.3, 0.5, 0.7, 0.9],
            num_attempts=crop_attempts,
        )

        # color twist
        self.uniform_con = ops.Uniform(range=contrast_range)
        self.uniform_bri = ops.Uniform(
            range=(1.0 - bri_delta / 256.0, 1.0 + bri_delta / 256.0)
        )
        self.uniform_sat = ops.Uniform(range=saturation_range)
        self.uniform_hue = ops.Uniform(range=(-hue_delta, hue_delta))
        self.hsv = ops.Hsv(device="gpu")
        self.contrast = ops.BrightnessContrast(device="gpu")

        # hflip
        self.bbox_flip = ops.BbFlip(device="cpu", ltrb=True)
        self.img_flip = ops.Flip(device="gpu")
        self.coin_flip = ops.CoinFlip(probability=0.5)

        # past
        self.paste_pos = ops.Uniform(range=(0, 1))
        self.paste_ratio = ops.Uniform(range=(1, max_expand_ratio))
        self.paste = ops.Paste(device="gpu", fill_value=mean)
        self.bbox_paste = ops.BBoxPaste(device="cpu", ltrb=True)

        # resize and normalize
        self.resize = ops.Resize(
            device="gpu",
            interp_type=types.DALIInterpType.INTERP_CUBIC,
            resize_x=target_size[0],
            resize_y=target_size[1],
            save_attrs=True,
        )
        self.normalize = ops.CropMirrorNormalize(device="gpu", mean=mean, std=std)
 def __init__(self, batch_size, num_threads, device_id, img_dir):
     super(SimplePipeline, self).__init__(batch_size,
                                          num_threads,
                                          device_id,
                                          seed=12)
     self.input = ops.FileReader(file_root=img_dir)
     # instead of path to file directory file with pairs image_name image_label_value can be provided
     # self.input = ops.FileReader(file_root = image_dir, file_list = image_dir + '/file_list.txt')
     self.decode = ops.ImageDecoder(device='mixed', output_type=types.RGB)
 def __init__(self, data_path, batch_size, num_threads, device_id, device):
     super(DecoderPipeline, self).__init__(batch_size,
                                           num_threads,
                                           device_id,
                                           prefetch_queue_depth=1)
     self.input = ops.FileReader(file_root=data_path,
                                 shard_id=0,
                                 num_shards=1)
     self.decode = ops.ImageDecoder(device=device, output_type=types.RGB)
Beispiel #20
0
 def __init__(self,  batch_size,function,  num_threads=1, device_id=0, num_gpus=1 ):
     super(WaterPythonPipeline, self).__init__(batch_size,
                                        num_threads,
                                        device_id,
                                        exec_async=False,
                                        exec_pipelined=False)
     self.input = ops.CaffeReader(path = caffe_db_folder, shard_id = device_id, num_shards = num_gpus)
     self.decode = ops.ImageDecoder(device = "cpu", output_type = types.RGB)
     self.water = ops.PythonFunction(function=function)
Beispiel #21
0
 def __init__(self, device, batch_size, relative, use_wildcard, num_threads=3, device_id=0, num_gpus=1):
     super(ReshapeWithArgInput, self).__init__(batch_size, num_threads, device_id, seed=7865, exec_async=False, exec_pipelined=False)
     self.device = device
     self.input = ops.CaffeReader(path = caffe_db_folder, shard_id = device_id, num_shards = num_gpus)
     self.resize = ops.Resize(device = "cpu");
     self.decode = ops.ImageDecoder(device = "cpu", output_type = types.RGB)
     self.gen_shapes = ops.PythonFunction(function=MakeTallFunc(relative, use_wildcard))
     self.reshape = ops.Reshape(device = device);
     self.relative = relative
Beispiel #22
0
 def __init__(self, batch_size, num_threads, device_id, _seed, image_dir):
     super(CommonPipeline, self).__init__(batch_size,
                                          num_threads,
                                          device_id,
                                          seed=_seed,
                                          exec_async=False,
                                          exec_pipelined=False)
     self.input = ops.FileReader(file_root=image_dir)
     self.decode = ops.ImageDecoder(device='cpu', output_type=types.RGB)
Beispiel #23
0
    def __init__(self,
                 batch_size,
                 num_threads,
                 device_id,
                 data_dir,
                 crop,
                 size,
                 mean,
                 std,
                 local_rank=0,
                 world_size=1,
                 dali_cpu=False,
                 shuffle=False,
                 fp16=False):

        # As we're recreating the Pipeline at every epoch, the seed must be -1 (random seed)
        super(HybridValPipe, self).__init__(batch_size,
                                            num_threads,
                                            device_id,
                                            seed=-1)

        # Enabling read_ahead slowed down processing ~40%
        # Note: initial_fill is for the shuffle buffer.  As we only want to see every example once, this is set to 1
        self.input = ops.FileReader(file_root=data_dir,
                                    shard_id=local_rank,
                                    num_shards=world_size,
                                    random_shuffle=shuffle,
                                    initial_fill=1)
        if dali_cpu:
            decode_device = "cpu"
            self.dali_device = "cpu"
            self.crop = ops.Crop(device="cpu", crop=(crop, crop))

        else:
            decode_device = "mixed"
            self.dali_device = "gpu"

            output_dtype = types.FLOAT
            if fp16:
                output_dtype = types.FLOAT16

            self.cmnp = ops.CropMirrorNormalize(device="gpu",
                                                output_dtype=output_dtype,
                                                output_layout=types.NCHW,
                                                crop=(crop, crop),
                                                image_type=types.RGB,
                                                mean=mean,
                                                std=std)

        self.decode = ops.ImageDecoder(device=decode_device,
                                       output_type=types.RGB)

        # Resize to desired size.  To match torchvision dataloader, use triangular interpolation
        self.res = ops.Resize(device=self.dali_device,
                              resize_shorter=size,
                              interp_type=types.INTERP_TRIANGULAR)
Beispiel #24
0
 def define_graph(self):
     nvtx.range_push("Reading JPEG files into host memory")
     jpegs, labels = self.input()  # read in jpeg files
     nvtx.range_pop()
     nvtx.range_push("Start mixed decoding process")
     # images = self.decode(jpegs) # Do decoding process
     decode = ops.ImageDecoder(device="mixed", output_type=types.RGB)
     images = decode(jpegs)
     nvtx.range_pop()
     return (images, labels)
 def __init__(self, function, device, num_outputs=1):
     super(PythonFunctionPipeline, self).__init__(BATCH_SIZE, NUM_WORKERS, DEVICE_ID,
                                                  seed=SEED,
                                                  exec_async=False, exec_pipelined=False)
     self.device = device
     self.reader = ops.readers.File(file_root=images_dir)
     self.decode = ops.ImageDecoder(device='cpu',
                                    output_type=types.RGB)
     self.norm = ops.CropMirrorNormalize(std=255., mean=0., device=device, output_layout="HWC")
     self.func = ops.PythonFunction(device=device, function=function, num_outputs=num_outputs)
Beispiel #26
0
    def __init__(self, batch_size, num_threads, device_id):
        super(CommonPipeline, self).__init__(batch_size, num_threads, device_id)

        self.decode = ops.ImageDecoder(device = "mixed", output_type = types.RGB)
        self.cmn = ops.CropMirrorNormalize(device = "gpu",
                                            output_dtype = types.FLOAT,
                                            image_type = types.RGB,
                                            mean = [128., 128., 128.],
                                            std = [1., 1., 1.])
        self.uniform = ops.Uniform(range = (0.0, 1.0))
Beispiel #27
0
 def __init__(self, device, batch_size, phase_y, phase_x, freq_x, freq_y, ampl_x, ampl_y, num_threads=1, device_id=0, num_gpus=1):
     super(WaterPipeline, self).__init__(batch_size,
                                        num_threads,
                                        device_id)
     self.device = device
     self.input = ops.CaffeReader(path = caffe_db_folder, shard_id = device_id, num_shards = num_gpus)
     self.decode = ops.ImageDecoder(device = "cpu", output_type = types.RGB)
     self.water = ops.Water(device = self.device, ampl_x=ampl_x, ampl_y=ampl_y,
                            phase_x=phase_x, phase_y=phase_y, freq_x=freq_x, freq_y=freq_y,
                            interp_type = dali.types.INTERP_LINEAR)
Beispiel #28
0
 def __init__(self, file_list, batch_size, num_threads, device_id, external_data):
     super(ExternalSourcePipeline, self).__init__(batch_size, num_threads, device_id)
     self.input = ops.FileReader(file_list= file_list)
     self.label = ops.ExternalSource()
     self.crops = ops.ExternalSource()
     self.decode = ops.ImageDecoder(device="mixed", output_type=types.RGB)
     self.res = ops.Resize(device="gpu", resize_x=224, resize_y=224)
     self.cast = ops.Cast(device="cpu", dtype=types.INT32)
     self.external_data = external_data
     self.iterator = iter(self.external_data)
 def __init__(self, iterator, batch_size, num_threads, device_id):
     super(ExternalSourcePipeline, self).__init__(batch_size,
                                   num_threads,
                                   device_id,
                                   seed=12)
     self.iterator = iterator
     self.input = ops.ExternalSource()
     self.input_label = ops.ExternalSource()
     self.decode = ops.ImageDecoder(device = "mixed", output_type = types.RGB)
     self.cast = ops.Cast(device = "gpu",
                          dtype = types.INT32)
Beispiel #30
0
 def __init__(self, function, batch_size, num_threads=1, device_id=0):
     super(MultichannelPythonOpPipeline,
           self).__init__(batch_size,
                          num_threads,
                          device_id,
                          exec_async=False,
                          exec_pipelined=False)
     self.reader = ops.FileReader(file_root=multichannel_tiff_root)
     self.decoder = ops.ImageDecoder(device='cpu',
                                     output_type=types.ANY_DATA)
     self.oper = ops.PythonFunction(function=function)