本文整理汇总了Python中nvidia.dali.pipeline.Pipeline方法的典型用法代码示例。如果您正苦于以下问题:Python pipeline.Pipeline方法的具体用法?Python pipeline.Pipeline怎么用?Python pipeline.Pipeline使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nvidia.dali.pipeline
的用法示例。
在下文中一共展示了pipeline.Pipeline方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from nvidia.dali import pipeline [as 别名]
# 或者: from nvidia.dali.pipeline import Pipeline [as 别名]
def __init__(
self,
batch_size=1,
num_threads=1,
seed=3,
prefetch_queue_depth=2,
):
"""Create a ``Pipeline``
Parameters
----------
batch_size : int, optional, default=1
The number of examples in a batch.
num_threads : int, optional, default=1
The number of threads to execute the operations.
seed : int, optional, default=3
The seed for random generator.
prefetch_queue_depth : int, optional, default=2
The number of prefetch queues.
"""
self._batch_size = batch_size
self._num_threads = num_threads
示例2: __init__
# 需要导入模块: from nvidia.dali import pipeline [as 别名]
# 或者: from nvidia.dali.pipeline import Pipeline [as 别名]
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)
示例3: build
# 需要导入模块: from nvidia.dali import pipeline [as 别名]
# 或者: from nvidia.dali.pipeline import Pipeline [as 别名]
def build(self):
"""Build the pipeline."""
super(Pipeline, self).build()
示例4: define_graph
# 需要导入模块: from nvidia.dali import pipeline [as 别名]
# 或者: from nvidia.dali.pipeline import Pipeline [as 别名]
def define_graph(self):
"""Define the symbolic operations for pipeline."""
super(Pipeline, self).define_graph()
示例5: feed_input
# 需要导入模块: from nvidia.dali import pipeline [as 别名]
# 或者: from nvidia.dali.pipeline import Pipeline [as 别名]
def feed_input(self, ref, data):
"""Bind an array to the edge reference.
Parameters
----------
ref : _EdgeReference
The reference of a edge.
data : numpy.ndarray
The array data.
"""
super(Pipeline, self).feed_input(ref, data)