def __init__(self, batch_size, num_threads, device_id, data_dir, crop, rali_cpu = True,rali_type=True ): super(HybridTrainPipe, self).__init__(batch_size, num_threads, device_id, seed=12 + device_id,rali_cpu=rali_cpu) self.box = False if rali_type else True self.input = ops.CaffeReader(path = data_dir, bbox=self.box,random_shuffle=True) self.rali_type = rali_type rali_device = 'cpu' if rali_cpu else 'gpu' decoder_device = 'cpu' if rali_cpu else 'mixed' device_memory_padding = 211025920 if decoder_device == 'mixed' else 0 host_memory_padding = 140544512 if decoder_device == 'mixed' else 0 self.decode = ops.ImageDecoderRandomCrop(device=decoder_device, output_type=types.RGB, device_memory_padding=device_memory_padding, host_memory_padding=host_memory_padding, random_aspect_ratio=[0.8, 1.25], random_area=[0.1, 1.0], num_attempts=100) self.res = ops.Resize(device=rali_device, resize_x=crop, resize_y=crop) 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]) self.one_hot_labels = ops.OneHot(num_classes=1000) self.coin = ops.CoinFlip(probability=0.5) print('rali "{0}" variant'.format(rali_device))
def __init__(self, feature_key_map, tfrecordreader_type, batch_size, num_threads, device_id, data_dir, crop, oneHotLabels=0, rali_cpu=True): super(HybridPipe, self).__init__(batch_size, num_threads, device_id, seed=12 + device_id, rali_cpu=rali_cpu) self.input = ops.TFRecordReader(path=data_dir, index_path="", reader_type=tfrecordreader_type, user_feature_key_map=feature_key_map, features={ 'image/encoded': tf.FixedLenFeature((), tf.string, ""), 'image/class/label': tf.FixedLenFeature([1], tf.int64, -1), 'image/filename': tf.FixedLenFeature((), tf.string, "") }) self._oneHotLabels = oneHotLabels rali_device = 'cpu' if rali_cpu else 'gpu' decoder_device = 'cpu' if rali_cpu else 'mixed' device_memory_padding = 211025920 if decoder_device == 'mixed' else 0 host_memory_padding = 140544512 if decoder_device == 'mixed' else 0 self.decode = ops.ImageDecoderRandomCrop( user_feature_key_map=feature_key_map, device=decoder_device, output_type=types.RGB, device_memory_padding=device_memory_padding, host_memory_padding=host_memory_padding, random_aspect_ratio=[0.8, 1.25], random_area=[0.1, 1.0], num_attempts=100) self.cmnp = ops.CropMirrorNormalize( device="cpu", 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]) self.one_hot_labels = ops.OneHot(num_classes=1000) self.coin = ops.CoinFlip(probability=0.5) print('rali "{0}" variant'.format(rali_device))