当前位置: 首页>>代码示例>>Python>>正文


Python ops.Uniform方法代码示例

本文整理汇总了Python中nvidia.dali.ops.Uniform方法的典型用法代码示例。如果您正苦于以下问题:Python ops.Uniform方法的具体用法?Python ops.Uniform怎么用?Python ops.Uniform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nvidia.dali.ops的用法示例。


在下文中一共展示了ops.Uniform方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from nvidia.dali import ops [as 别名]
# 或者: from nvidia.dali.ops import Uniform [as 别名]
def __init__(self, batch_size, num_threads, device_id, data_dir, crop, seed=12, local_rank=0, world_size=1,
                 spos_pre=False):
        super(HybridTrainPipe, self).__init__(batch_size, num_threads, device_id, seed=seed + device_id)
        color_space_type = types.BGR if spos_pre else types.RGB
        self.input = ops.FileReader(file_root=data_dir, shard_id=local_rank, num_shards=world_size, random_shuffle=True)
        self.decode = ops.ImageDecoder(device="mixed", output_type=color_space_type)
        self.res = ops.RandomResizedCrop(device="gpu", size=crop,
                                         interp_type=types.INTERP_LINEAR if spos_pre else types.INTERP_TRIANGULAR)
        self.twist = ops.ColorTwist(device="gpu")
        self.jitter_rng = ops.Uniform(range=[0.6, 1.4])
        self.cmnp = ops.CropMirrorNormalize(device="gpu",
                                            output_dtype=types.FLOAT,
                                            output_layout=types.NCHW,
                                            image_type=color_space_type,
                                            mean=0. if spos_pre else [0.485 * 255, 0.456 * 255, 0.406 * 255],
                                            std=1. if spos_pre else [0.229 * 255, 0.224 * 255, 0.225 * 255])
        self.coin = ops.CoinFlip(probability=0.5) 
开发者ID:microsoft,项目名称:nni,代码行数:19,代码来源:dataloader.py

示例2: __init__

# 需要导入模块: from nvidia.dali import ops [as 别名]
# 或者: from nvidia.dali.ops import Uniform [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 
开发者ID:THUFutureLab,项目名称:gluon-face,代码行数:27,代码来源:dali_utils.py

示例3: define_graph

# 需要导入模块: from nvidia.dali import ops [as 别名]
# 或者: from nvidia.dali.ops import Uniform [as 别名]
def define_graph(self):
        jpegs, labels = self.loader()
        images = self.decode(jpegs)
        images = self.resize(images.gpu())
        # images = self.hue(images, hue=ops.Uniform(range=(-3.0, 3.0))())
        # images = self.bright(images,
        #                      brightness=ops.Uniform(range=(0.9, 1.1))())
        # images = self.cntrst(images,
        #                      contrast=ops.Uniform(range=(0.9, 1.1))())
        # images = self.rotate(images,
        #                      angle=ops.Uniform(range=(-5.0, 5.0))())
        # images = self.jitter(images)
        images = self.rrcrop(images)
        images = self.cmnorm(images, mirror=self.coin())
        return images, labels 
开发者ID:chainer,项目名称:chainer,代码行数:17,代码来源:dali_util.py

示例4: __init__

# 需要导入模块: from nvidia.dali import ops [as 别名]
# 或者: from nvidia.dali.ops import Uniform [as 别名]
def __init__(self, batch_size, device_id, file_root, annotations_file, num_gpus,
            output_fp16=False, output_nhwc=False, pad_output=False, num_threads=1, seed=15):
        super(COCOPipeline, self).__init__(batch_size=batch_size, device_id=device_id,
                                           num_threads=num_threads, seed = seed)

        try:
            shard_id = torch.distributed.get_rank()
        except RuntimeError:
            shard_id = 0

        self.input = ops.COCOReader(file_root = file_root, annotations_file = annotations_file,
                            shard_id = shard_id, num_shards = num_gpus, ratio=True, ltrb=True, random_shuffle=True)
        self.decode = ops.HostDecoder(device = "cpu", output_type = types.RGB)

        # Augumentation techniques
        self.crop = ops.SSDRandomCrop(device="cpu", num_attempts=1)
        self.twist = ops.ColorTwist(device="gpu")

        self.resize = ops.Resize(device = "gpu", resize_x = 300, resize_y = 300)

        output_dtype = types.FLOAT16 if output_fp16 else types.FLOAT
        output_layout = types.NHWC if output_nhwc else types.NCHW

        self.normalize = ops.CropMirrorNormalize(device="gpu", crop=(300, 300),
                                                 mean=[0.0, 0.0, 0.0],
                                                 std=[255.0, 255.0, 255.0],
                                                 mirror=0,
                                                 output_dtype=output_dtype,
                                                 output_layout=output_layout,
                                                 pad_output=pad_output)

        # Random variables
        self.rng1 = ops.Uniform(range=[0.5, 1.5])
        self.rng2 = ops.Uniform(range=[0.875, 1.125])
        self.rng3 = ops.Uniform(range=[-0.5, 0.5]) 
开发者ID:mlperf,项目名称:training_results_v0.5,代码行数:37,代码来源:coco_pipeline.py

示例5: __init__

# 需要导入模块: from nvidia.dali import ops [as 别名]
# 或者: from nvidia.dali.ops import Uniform [as 别名]
def __init__(self, name, batch_size, num_threads, device_id, num_shards, shard_id,
                 root=os.path.expanduser('~/.mxnet/datasets/face'), ):
        super().__init__(batch_size, num_threads, device_id, seed=12)

        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.size = 0
        for idx_file in idx_files:
            with open(idx_file, "r") as f:
                self.size += len(list(f.readlines()))

        self._input = ops.MXNetReader(path=rec_files, index_path=idx_files, random_shuffle=True,
                                      num_shards=num_shards, shard_id=shard_id, seed=12,
                                      tensor_init_bytes=self.image_size[0] * self.image_size[1] * 8)
        self._decode = ops.ImageDecoder(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=[0., 0., 0.],
                                             std=[255., 255., 255.])
        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) 
开发者ID:THUFutureLab,项目名称:gluon-face,代码行数:35,代码来源:utils.py

示例6: __new__

# 需要导入模块: from nvidia.dali import ops [as 别名]
# 或者: from nvidia.dali.ops import Uniform [as 别名]
def __new__(cls, range=(-1., 1.)):
        """Create an ``Uniform`` operator.

        Parameters
        ----------
        range : Tuple[float, float], optional
            The lower and upper bound of distribution.

        Returns
        -------
        nvidia.dali.ops.Uniform
            The operator.

        """
        return ops.Uniform(range=range) 
开发者ID:seetaresearch,项目名称:dragon,代码行数:17,代码来源:random.py

示例7: __init__

# 需要导入模块: from nvidia.dali import ops [as 别名]
# 或者: from nvidia.dali.ops import Uniform [as 别名]
def __init__(self, batch_size, num_threads, path, training, annotations, world, device_id, mean, std, resize,
                 max_size, stride, rotate_augment=False,
                 augment_brightness=0.0,
                 augment_contrast=0.0, augment_hue=0.0,
                 augment_saturation=0.0):
        super().__init__(batch_size=batch_size, num_threads=num_threads, device_id=device_id,
                         prefetch_queue_depth=num_threads, seed=42)
        self.path = path
        self.training = training
        self.stride = stride
        self.iter = 0

        self.rotate_augment = rotate_augment
        self.augment_brightness = augment_brightness
        self.augment_contrast = augment_contrast
        self.augment_hue = augment_hue
        self.augment_saturation = augment_saturation

        self.reader = ops.COCOReader(annotations_file=annotations, file_root=path, num_shards=world,
                                     shard_id=torch.cuda.current_device(),
                                     ltrb=True, ratio=True, shuffle_after_epoch=True, save_img_ids=True)

        self.decode_train = ops.ImageDecoderSlice(device="mixed", output_type=types.RGB)
        self.decode_infer = ops.ImageDecoder(device="mixed", output_type=types.RGB)
        self.bbox_crop = ops.RandomBBoxCrop(device='cpu', bbox_layout="xyXY", scaling=[0.3, 1.0],
                                            thresholds=[0.1, 0.3, 0.5, 0.7, 0.9])

        self.bbox_flip = ops.BbFlip(device='cpu', ltrb=True)
        self.img_flip = ops.Flip(device='gpu')
        self.coin_flip = ops.CoinFlip(probability=0.5)
        self.bc = ops.BrightnessContrast(device='gpu')
        self.hsv = ops.Hsv(device='gpu')

        # Random number generation for augmentation
        self.brightness_dist = ops.NormalDistribution(mean=1.0, stddev=augment_brightness)
        self.contrast_dist = ops.NormalDistribution(mean=1.0, stddev=augment_contrast)
        self.hue_dist = ops.NormalDistribution(mean=0.0, stddev=augment_hue)
        self.saturation_dist = ops.NormalDistribution(mean=1.0, stddev=augment_saturation)

        if rotate_augment:
            raise RuntimeWarning("--augment-rotate current has no effect when using the DALI data loader.")

        if isinstance(resize, list): resize = max(resize)
        self.rand_resize = ops.Uniform(range=[resize, float(max_size)])

        self.resize_train = ops.Resize(device='gpu', interp_type=types.DALIInterpType.INTERP_CUBIC, save_attrs=True)
        self.resize_infer = ops.Resize(device='gpu', interp_type=types.DALIInterpType.INTERP_CUBIC,
                                       resize_longer=max_size, save_attrs=True)

        padded_size = max_size + ((self.stride - max_size % self.stride) % self.stride)

        self.pad = ops.Paste(device='gpu', fill_value=0, ratio=1.1, min_canvas_size=padded_size, paste_x=0, paste_y=0)
        self.normalize = ops.CropMirrorNormalize(device='gpu', mean=mean, std=std, crop=(padded_size, padded_size),
                                                 crop_pos_x=0, crop_pos_y=0) 
开发者ID:NVIDIA,项目名称:retinanet-examples,代码行数:56,代码来源:dali.py


注:本文中的nvidia.dali.ops.Uniform方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。