Exemple #1
0
 def __getitem__(self, idx):
     if self.videoFramesPath[idx].endswith(".webp"):
         frame = webp.load_image(self.videoFramesPath[idx], "RGB")
     else:
         frame = Image.open(self.videoFramesPath[idx]).convert('RGB')
     frame = self.transform(frame)
     return frame
Exemple #2
0
    def test_image_palette_opaque(self, image_bars_palette_opaque):
        with TemporaryDirectory() as tmpdir:
            file_name = os.path.join(tmpdir, 'image.webp')

            assert image_bars_palette_opaque.mode == 'P'
            webp.save_image(image_bars_palette_opaque, file_name, lossless=True)
            dec_img = webp.load_image(file_name, 'RGB')

            actual = np.asarray(dec_img, dtype=np.uint8)
            image_bars_rgb = image_bars_palette_opaque.convert('RGB')
            expected = np.asarray(image_bars_rgb, dtype=np.uint8)
            assert_array_equal(actual, expected)
 def __getitem__(self, idx):
     if self.videoFramesPath[idx].endswith(".webp"):
         frame = webp.load_image(self.videoFramesPath[idx], "RGB")
     else:
         frame = Image.open(self.videoFramesPath[idx]).convert('RGB')
     frame = self.transform(frame)
     flow = flowlib.readFlow(
         os.path.join(self.flow_dir, "{:06d}.flo".format(idx)))
     flow = transforms.ToTensor()(flow)
     occ = self.occTransform(
         Image.open(
             os.path.join(self.occlusion_dir,
                          "{:05d}.png".format(idx))).convert('RGB'))
     return (frame, flow, occ)
Exemple #4
0
    def test_image_simple(self):
        width = 256
        height = 64
        img = Image.new('RGB', (width, height))
        draw = ImageDraw.Draw(img)
        draw.rectangle([0, 0, width-1, height-1], fill=(0, 0, 255))
        draw.rectangle([0, 0, (width/4-1), height-1], fill=(255, 0, 0))

        with TemporaryDirectory() as tmpdir:
            file_name = os.path.join(tmpdir, 'image.webp')

            webp.save_image(img, file_name, lossless=True)
            dec_img = webp.load_image(file_name, 'RGB')

            actual = np.asarray(dec_img, dtype=np.uint8)
            expected = np.asarray(img, dtype=np.uint8)
            assert_array_equal(actual, expected)
Exemple #5
0
                source_video.start, source_video.start + args.duration)

    source_audio = source_video.audio
    source_fps = source_video.fps
    source_duration = source_video.duration
    print("Video Info:")
    print("Name:", driving_video_path)
    print("Dimensions:", 'x'.join([str(x) for x in source_video.size]))
    print("Start:", args.start or source_video.start)
    print("Duration:", source_duration)
    print("End:", (args.start or source_video.start) + source_duration)
    print("FPS:", source_fps)
    print()
    # Read Image
    if image_extension.lower() == 'webp':
        source_image = np.array(webp.load_image(source_image_path, 'RGBA'))
    else:
        source_image = imageio.imread(source_image_path)

    print("Image Info:")
    print("Name:", source_image_path)
    print("Dimensions:",
          'x'.join([str(x) for x in source_image.shape[:2]][::-1]))
    print()

    # Read and Resize image and video to 256x256
    if source_image.shape[:2] != [256, 256]:
        print("Resizing image to 256x256 with ", end='')
        if args.image_resize == 'fill':
            print("Mode: Fill")
            height, width = source_image.shape[:2]
Exemple #6
0
def load_webp(image):

    image = webp.load_image(image, 'RGB')

    return image