|
import os |
|
os.system("git clone https://github.com/google-research/frame-interpolation") |
|
import sys |
|
sys.path.append("frame-interpolation") |
|
|
|
import cv2 |
|
import numpy as np |
|
import tensorflow as tf |
|
import mediapy |
|
from PIL import Image |
|
from eval import interpolator, util |
|
import gradio as gr |
|
|
|
from huggingface_hub import snapshot_download |
|
|
|
from image_tools.sizes import resize_and_crop |
|
from moviepy.editor import * |
|
|
|
|
|
model = snapshot_download(repo_id="akhaliq/frame-interpolation-film-style") |
|
|
|
interpolator = interpolator.Interpolator(model, None) |
|
|
|
ffmpeg_path = util.get_ffmpeg_path() |
|
mediapy.set_ffmpeg(ffmpeg_path) |
|
|
|
|
|
|
|
def interpolate(frame1, frame2): |
|
|
|
input_frames = [frame1, frame2] |
|
times_to_interpolate = 2 |
|
frames = list( |
|
util.interpolate_recursively_from_files( |
|
input_frames, times_to_interpolate, interpolator)) |
|
print(frames) |
|
|
|
return "done" |
|
|
|
|
|
|
|
title="sketch-frame-interpolation" |
|
description="<p style='text-align: center'>This is a fork of the Gradio demo for FILM: Frame Interpolation for Large Scene Motion from @akhaliq, but using sketches instead of images. This could be very useful for the animation industry :) <br /> To use it, simply draw your sketches and add the times to interpolate number. Read more at the links below. <br /> <img id='visitor-badge' alt='visitor badge' src='https://visitor-badge.glitch.me/badge?page_id=gradio-blocks.sketch_frame_interpolation' style='display: inline-block'/></p>" |
|
article = "<p style='text-align: center'><a href='https://film-net.github.io/' target='_blank'>FILM: Frame Interpolation for Large Motion</a> | <a href='https://github.com/google-research/frame-interpolation' target='_blank'>Github Repo</a></p>" |
|
custom_css = "style.css" |
|
|
|
gr.Interface(interpolate,[gr.Image(source="upload", type="filepath"),gr.Image(source="upload", type="filepath")],outputs=[gr.Textbox()],title=title,description=description,article=article,css=custom_css).launch(enable_queue=True) |