Exemplo n.º 1
0
 def __init__(self,
              batch_size,
              num_threads,
              device_id,
              data_dir,
              rali_cpu=True,
              prefetch_queue_depth=2):
     super(HybridTrainPipe,
           self).__init__(batch_size,
                          num_threads,
                          device_id,
                          rali_cpu=rali_cpu,
                          prefetch_queue_depth=prefetch_queue_depth)
     world_size = 1
     local_rank = 0
     resize_width = 300
     resize_height = 300
     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'
     self.decode = ops.ImageDecoder(device=decoder_device,
                                    output_type=types.RGB)
     self.res = ops.Resize(device=rali_device,
                           resize_x=resize_width,
                           resize_y=resize_height)
     self.rain = ops.Rain(rain=0.5)
Exemplo n.º 2
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.rain = ops.Rain(rain=0.5)
		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))
Exemplo n.º 3
0
 def __init__(self,
              batch_size,
              num_threads,
              device_id,
              data_dir,
              crop,
              rali_cpu=False):
     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))