def run_decode(data_path, out_type): batch_size = 4 pipe = Pipeline(batch_size=batch_size, num_threads=4, device_id=0) input, _ = fn.file_reader(file_root=data_path, shard_id=0, num_shards=1, name="reader") decoded = fn.image_decoder(input, output_type=types.RGB) decoded_shape = fn.shapes(decoded) raw_shape = fn.peek_image_shape(input, type=out_type) pipe.set_outputs(decoded, decoded_shape, raw_shape) pipe.build() samples = 0 length = pipe.reader_meta(name="reader")['epoch_size'] while samples < length: samples += batch_size (images, decoded_shape, raw_shape) = pipe.run() for i in range(batch_size): # as we are asking for a particular color space it may differ from the source image, so don't compare it image = images.at(i) shape_type = dali_types_to_np(out_type) for d in range(len(image.shape) - 1): assert image.shape[d] == decoded_shape.at( i)[d], "{} vs {}".format(image.shape[d], decoded_shape.at(i)[d]) assert image.shape[d] == raw_shape.at(i)[d], "{} vs {}".format( image.shape[d], raw_shape.at(i)[d]) assert raw_shape.at( i)[d].dtype == shape_type, "{} vs {}".format( raw_shape.at(i)[d].dtyp, shape_type)
def check_container(cont): pipe = Pipeline(batch_size=1, num_threads=4, device_id=0) path = os.path.join(video_containers_data_root, cont) test_videos = [path + '/' + f for f in os.listdir(path)] with pipe: # mkv container for some reason fails in DALI VFR heuristics vid = fn.video_reader(device="gpu", filenames=test_videos, sequence_length=10, skip_vfr_check=True, stride=1, name="Reader") pipe.set_outputs(vid) pipe.build() iter_num = pipe.reader_meta("Reader")["epoch_size"] for _ in range(iter_num): pipe.run()