Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -13,6 +13,9 @@ import gradio as gr
|
|
| 13 |
from huggingface_hub import snapshot_download
|
| 14 |
|
| 15 |
from PIL import PngImagePlugin
|
|
|
|
|
|
|
|
|
|
| 16 |
LARGE_ENOUGH_NUMBER = 100
|
| 17 |
PngImagePlugin.MAX_TEXT_CHUNK = LARGE_ENOUGH_NUMBER * (1024**2)
|
| 18 |
|
|
@@ -28,6 +31,16 @@ def resize(width,img):
|
|
| 28 |
hsize = int((float(img.size[1])*float(wpercent)))
|
| 29 |
img = img.resize((basewidth,hsize), Image.ANTIALIAS)
|
| 30 |
return img
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
def predict(frame1, frame2, times_to_interpolate):
|
| 33 |
|
|
@@ -37,8 +50,8 @@ def predict(frame1, frame2, times_to_interpolate):
|
|
| 37 |
frame1.save("test1.png")
|
| 38 |
frame2.save("test2.png")
|
| 39 |
|
| 40 |
-
|
| 41 |
-
input_frames = ["test1.png", "
|
| 42 |
|
| 43 |
frames = list(
|
| 44 |
util.interpolate_recursively_from_files(
|
|
|
|
| 13 |
from huggingface_hub import snapshot_download
|
| 14 |
|
| 15 |
from PIL import PngImagePlugin
|
| 16 |
+
|
| 17 |
+
from image_tools.sizes import resize_and_crop
|
| 18 |
+
|
| 19 |
LARGE_ENOUGH_NUMBER = 100
|
| 20 |
PngImagePlugin.MAX_TEXT_CHUNK = LARGE_ENOUGH_NUMBER * (1024**2)
|
| 21 |
|
|
|
|
| 31 |
hsize = int((float(img.size[1])*float(wpercent)))
|
| 32 |
img = img.resize((basewidth,hsize), Image.ANTIALIAS)
|
| 33 |
return img
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
def resize_img(img1,img2):
|
| 37 |
+
img_target_size = Image.open(img1)
|
| 38 |
+
img_to_resize = resize_and_crop(
|
| 39 |
+
img2,
|
| 40 |
+
(img_origin_size.size[0],img_origin_size.size[1]), #set width and height to match img1
|
| 41 |
+
crop_origin="middle"
|
| 42 |
+
)
|
| 43 |
+
img_to_resize.save('resized_img2.png')
|
| 44 |
|
| 45 |
def predict(frame1, frame2, times_to_interpolate):
|
| 46 |
|
|
|
|
| 50 |
frame1.save("test1.png")
|
| 51 |
frame2.save("test2.png")
|
| 52 |
|
| 53 |
+
resize_img("test1.png","test2.png")
|
| 54 |
+
input_frames = ["test1.png", "resized_img2.png"]
|
| 55 |
|
| 56 |
frames = list(
|
| 57 |
util.interpolate_recursively_from_files(
|