Exemplo n.º 1
0
def normalize_uint8_image(image, config='default'):
    from normalize_config import get_normalize_config
    mean, std = get_normalize_config(config)
    image = image - mean
    if std is not None:
        image /= std
    return image
Exemplo n.º 2
0
def get_val_data_iterator(args,
                          comm,
                          channels,
                          spatial_size=(224, 224),
                          norm_config='default'):
    # Pipelines and Iterators for validation
    mean, std = get_normalize_config(norm_config)
    if std is None:
        std = [1., 1., 1.]
    pad_output = get_pad_output_by_channels(channels)
    val_pipe = ValPipeline(args.batch_size,
                           args.dali_num_threads,
                           comm.rank,
                           args.val_dir,
                           args.val_list,
                           args.dali_nvjpeg_memory_padding,
                           seed=comm.rank + 1,
                           device_id=int(comm.ctx.device_id),
                           num_shards=comm.n_procs,
                           channel_last=args.channel_last,
                           spatial_size=spatial_size,
                           dtype=args.type_config,
                           mean=list(mean),
                           std=list(std),
                           pad_output=pad_output)
    vdata = dali_iterator.DaliIterator(val_pipe)
    vdata.size = int_div_ceil(val_pipe.epoch_size("Reader"), comm.n_procs)
    return vdata
Exemplo n.º 3
0
def get_train_data_iterator(args, comm, channels, norm_config='default'):
    # Pipelines and Iterators for training
    mean, std = get_normalize_config(norm_config)
    if std is None:
        std = [1., 1., 1.]
    pad_output = get_pad_output_by_channels(channels)
    train_pipe = TrainPipeline(args.batch_size,
                               args.dali_num_threads,
                               comm.rank,
                               args.train_dir,
                               args.train_list,
                               args.dali_nvjpeg_memory_padding,
                               seed=comm.rank + 1,
                               num_shards=comm.n_procs,
                               channel_last=args.channel_last,
                               dtype=args.type_config,
                               mean=list(mean),
                               std=list(std),
                               pad_output=pad_output)

    data = dali_iterator.DaliIterator(train_pipe)
    data.size = int_div_ceil(train_pipe.epoch_size("Reader"), comm.n_procs)
    return data