File size: 802 Bytes
204cb05
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import gradio as gr
from diffusers.utils import load_image

import os
import cv2
import numpy as np
from PIL import Image
from moviepy.editor import *

def get_canny_filter(image):
    image = load_image(image)
    
    image = np.array(image)

    low_threshold = 100
    high_threshold = 200

    image = cv2.Canny(image, low_threshold, high_threshold)
    image = image[:, :, None]
    image = np.concatenate([image, image, image], axis=2)
    image = Image.fromarray(image)
    return image

def infer(imported_gif):
    clip = VideoFileClip(imported_gif.name)
    clip.write_videofile("my_gif_video.mp4")
    
    return "my_gif_video.mp4"

inputs = [gr.File(label="import a GIF instead", file_types=['.gif'])]
outputs = [gr.Video()]
gr.Interface(fn=infer, inputs=inputs, outputs=outputs).launch()