def jpeg_distortion_pipe(device='cpu', quality=None):
     iii = InputImagesIter(seq_len)
     inputs = fn.external_source(source=iii, layout='FHWC', batch=False)
     if device == 'gpu':
         inputs = inputs.gpu()
     if quality is None:
         quality = fn.random.uniform(range=[1, 99], dtype=types.INT32)
     tmp = fn.jpeg_compression_distortion(inputs, quality=quality)
     outs = []
     for i in range(seq_len):
         # First, slice of the distorted sequence
         outs.append(fn.slice(tmp, axes=(0, ), start=(i, ), end=(i + 1, )))
         # Second, distorted slice of the input
         slice_in = fn.slice(inputs, axes=(0, ), start=(i, ), end=(i + 1, ))
         outs.append(
             fn.jpeg_compression_distortion(slice_in, quality=quality))
     return tuple(outs)
Exemple #2
0
 def jpeg_distortion_pipe(device='cpu', quality=None):
   encoded, _ = fn.readers.file(file_root=images_dir)
   in_images = fn.decoders.image(encoded, device='cpu')
   if quality is None:
     quality = fn.random.uniform(range=[1, 99], dtype=types.INT32)
   images = in_images.gpu() if device == 'gpu' else in_images
   out_images = fn.jpeg_compression_distortion(images, quality=quality)
   return out_images, in_images, quality
    def jpeg_distortion_pipe(device='cpu', quality=None):
        if layout == 'FHWC':
            iii = InputImagesIter(sequence_length)
            in_tensors = fn.external_source(source=iii,
                                            layout='FHWC',
                                            batch=False)
        else:
            encoded, _ = fn.readers.file(file_root=images_dir)
            in_tensors = fn.decoders.image(encoded, device='cpu')

        inputs = in_tensors.gpu() if device == 'gpu' else in_tensors
        if quality is None:
            quality = fn.random.uniform(range=[1, 99], dtype=types.INT32)
        out_tensors = fn.jpeg_compression_distortion(inputs, quality=quality)
        return (out_tensors, in_tensors, quality)