Ejemplo n.º 1
0
 def __init__(self, data_path, batch_size, num_thread, crop, rali_cpu=True):
     super(trainPipeline, self).__init__(batch_size,
                                         num_thread,
                                         rali_cpu=rali_cpu)
     world_size = 1
     local_rank = 0
     self.input = ops.FileReader(file_root=data_path,
                                 shard_id=local_rank,
                                 num_shards=world_size,
                                 random_shuffle=True)
     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.coin = ops.CoinFlip(probability=0.5)
     print('rali "{0}" variant'.format(rali_device))
Ejemplo n.º 2
0
	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))
Ejemplo n.º 3
0
 def __init__(self,
              batch_size,
              num_threads,
              device_id,
              data_dir,
              crop,
              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="",
                                     features={
                                         'image/encoded':
                                         tf.FixedLenFeature((), tf.string,
                                                            ""),
                                         'image/class/label':
                                         tf.FixedLenFeature([1], tf.int64,
                                                            -1),
                                         'image/class/text':
                                         tf.FixedLenFeature([], tf.string,
                                                            ''),
                                         'image/object/bbox/xmin':
                                         tf.VarLenFeature(dtype=tf.float32),
                                         'image/object/bbox/ymin':
                                         tf.VarLenFeature(dtype=tf.float32),
                                         'image/object/bbox/xmax':
                                         tf.VarLenFeature(dtype=tf.float32),
                                         'image/object/bbox/ymax':
                                         tf.VarLenFeature(dtype=tf.float32)
                                     })
     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.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.coin = ops.CoinFlip(probability=0.5)
     print('rali "{0}" variant'.format(rali_device))
Ejemplo n.º 4
0
 def __init__(self,
              batch_size,
              num_threads,
              device_id,
              data_dir,
              crop,
              rali_cpu=True):
     super(HybridTrainPipe, self).__init__(batch_size,
                                           num_threads,
                                           device_id,
                                           seed=12 + device_id,
                                           rali_cpu=rali_cpu)
     world_size = 1
     local_rank = 0
     self.input = ops.FileReader(file_root=data_dir,
                                 shard_id=local_rank,
                                 num_shards=world_size,
                                 random_shuffle=True)
     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.res = ops.Crop(crop=(crop, crop))
     # self.rain = ops.Rain(rain=0.5)
     # self.blur = ops.Blur(blur=0.5)
     # self.jitter = ops.Jitter()
     # self.contrast =ops.Rotate(angle=20)
     # self.hue = ops.Hue()
     # self.blend = ops.Blend(blend=0.5)
     # self.snp = ops.SnPNoise(snpNoise = 0.5)
     # self.ving = ops.Vignette(vignette = 0.2)
     # self.exp = ops.Exposure(exposure = 0.2)
     # #self.wf = ops.WarpAffine()
     # self.sat = ops.Saturation()
     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.coin = ops.CoinFlip(probability=0.5)
     print('rali "{0}" variant'.format(rali_device))