本文整理汇总了Python中nvidia.dali.ops.nvJPEGDecoder方法的典型用法代码示例。如果您正苦于以下问题:Python ops.nvJPEGDecoder方法的具体用法?Python ops.nvJPEGDecoder怎么用?Python ops.nvJPEGDecoder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nvidia.dali.ops
的用法示例。
在下文中一共展示了ops.nvJPEGDecoder方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from nvidia.dali import ops [as 别名]
# 或者: from nvidia.dali.ops import nvJPEGDecoder [as 别名]
def __init__(self, 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'):
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)
self.decode = ops.nvJPEGDecoder(device = "mixed", output_type = types.RGB,
device_memory_padding = nvjpeg_padding,
host_memory_padding = nvjpeg_padding)
self.rrc = ops.RandomResizedCrop(device = "gpu", size = crop_shape)
self.cmnp = ops.CropMirrorNormalize(device = "gpu",
output_dtype = types.FLOAT16 if dtype == 'float16' else types.FLOAT,
output_layout = output_layout,
crop = crop_shape,
pad_output = pad_output,
image_type = types.RGB,
mean = _mean_pixel,
std = _std_pixel)
self.coin = ops.CoinFlip(probability = 0.5)
示例2: __init__
# 需要导入模块: from nvidia.dali import ops [as 别名]
# 或者: from nvidia.dali.ops import nvJPEGDecoder [as 别名]
def __init__(self, batch_size, num_threads, device_id, data_dir, crop, size):
super(HybridValPipe, self).__init__(batch_size, num_threads, device_id, seed = 12 + device_id)
if torch.distributed.is_initialized():
local_rank = torch.distributed.get_rank()
world_size = torch.distributed.get_world_size()
else:
local_rank = 0
world_size = 1
self.input = ops.FileReader(
file_root = data_dir,
shard_id = local_rank,
num_shards = world_size,
random_shuffle = False)
self.decode = ops.nvJPEGDecoder(device = "mixed", output_type = types.RGB)
self.res = ops.Resize(device = "gpu", resize_shorter = size)
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])
示例3: __init__
# 需要导入模块: from nvidia.dali import ops [as 别名]
# 或者: from nvidia.dali.ops import nvJPEGDecoder [as 别名]
def __init__(self, name, batch_size, num_workers, device_id, num_gpu,
root=os.path.expanduser('~/.mxnet/datasets/face')):
super().__init__(batch_size, num_workers, device_id, seed=12 + device_id)
idx_files = [os.path.join(root, name, "train.idx")]
rec_files = [os.path.join(root, name, "train.rec")]
prop = open(os.path.join(root, name, "property"), "r").read().strip().split(',')
assert len(prop) == 3
self.num_classes = int(prop[0])
self.image_size = [int(prop[1]), int(prop[2])]
self._input = ops.MXNetReader(path=rec_files, index_path=idx_files, random_shuffle=True,
num_shards=num_gpu, tensor_init_bytes=self.image_size[0] * self.image_size[1] * 8)
self._decode = ops.nvJPEGDecoder(device="mixed", output_type=types.RGB)
self._cmnp = ops.CropMirrorNormalize(device="gpu", output_dtype=types.FLOAT, output_layout=types.NCHW,
crop=self.image_size, image_type=types.RGB,
mean=[127.5, 127.5, 127.5], std=[127.5, 127.5, 127.5])
self._contrast = ops.Contrast(device="gpu", )
self._saturation = ops.Saturation(device="gpu", )
self._brightness = ops.Brightness(device="gpu", )
self._uniform = ops.Uniform(range=(0.7, 1.3))
self._coin = ops.CoinFlip(probability=0.5)
self.iter = 0
示例4: __init__
# 需要导入模块: from nvidia.dali import ops [as 别名]
# 或者: from nvidia.dali.ops import nvJPEGDecoder [as 别名]
def __init__(self, batch_size, num_threads, device_id, rec_path, idx_path,
shard_id, num_shards, crop_shape,
nvjpeg_padding, prefetch_queue=3,
seed=12, resize_shp=None,
output_layout=types.NCHW, pad_output=True, dtype='float16',
mlperf_print=True):
super(HybridValPipe, self).__init__(
batch_size, num_threads, device_id,
seed = seed + device_id,
prefetch_queue_depth = prefetch_queue)
self.input = ops.MXNetReader(path = [rec_path], index_path=[idx_path],
random_shuffle=False, shard_id=shard_id, num_shards=num_shards)
self.decode = ops.nvJPEGDecoder(device = "mixed", output_type = types.RGB,
device_memory_padding = nvjpeg_padding,
host_memory_padding = nvjpeg_padding)
self.resize = ops.Resize(device = "gpu", resize_shorter=resize_shp) if resize_shp else None
self.cmnp = ops.CropMirrorNormalize(device = "gpu",
output_dtype = types.FLOAT16 if dtype == 'float16' else types.FLOAT,
output_layout = output_layout,
crop = crop_shape,
pad_output = pad_output,
image_type = types.RGB,
mean = _mean_pixel,
std = _std_pixel)
if mlperf_print:
mx_resnet_print(
key=mlperf_log.INPUT_MEAN_SUBTRACTION,
val=_mean_pixel)
mx_resnet_print(
key=mlperf_log.INPUT_RESIZE_ASPECT_PRESERVING)
mx_resnet_print(
key=mlperf_log.INPUT_CENTRAL_CROP)