Spaces:
Paused
Paused
fix film bugs
Browse files- libs/film/predict.py +11 -7
libs/film/predict.py
CHANGED
|
@@ -6,6 +6,7 @@ import tensorflow as tf
|
|
| 6 |
import mediapy
|
| 7 |
from PIL import Image
|
| 8 |
import cog
|
|
|
|
| 9 |
|
| 10 |
from .eval import interpolator, util
|
| 11 |
|
|
@@ -16,20 +17,23 @@ class Predictor(cog.BasePredictor):
|
|
| 16 |
def setup(self):
|
| 17 |
import tensorflow as tf
|
| 18 |
print("Num GPUs Available: ", len(tf.config.list_physical_devices('GPU')))
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
# Batched time.
|
| 22 |
self.batch_dt = np.full(shape=(1,), fill_value=0.5, dtype=np.float32)
|
| 23 |
|
| 24 |
|
| 25 |
-
def predict(self,
|
| 26 |
-
INPUT_EXT = ['.png', '.jpg', '.jpeg']
|
| 27 |
-
assert os.path.splitext(str(frame1))[-1] in INPUT_EXT and os.path.splitext(str(frame2))[-1] in INPUT_EXT, \
|
| 28 |
-
|
| 29 |
|
| 30 |
# make sure 2 images are the same size
|
| 31 |
-
img1 = Image.open(str(frame1))
|
| 32 |
-
img2 = Image.open(str(frame2))
|
| 33 |
if not img1.size == img2.size:
|
| 34 |
img1 = img1.crop((0, 0, min(img1.size[0], img2.size[0]), min(img1.size[1], img2.size[1])))
|
| 35 |
img2 = img2.crop((0, 0, min(img1.size[0], img2.size[0]), min(img1.size[1], img2.size[1])))
|
|
|
|
| 6 |
import mediapy
|
| 7 |
from PIL import Image
|
| 8 |
import cog
|
| 9 |
+
from huggingface_hub import snapshot_download
|
| 10 |
|
| 11 |
from .eval import interpolator, util
|
| 12 |
|
|
|
|
| 17 |
def setup(self):
|
| 18 |
import tensorflow as tf
|
| 19 |
print("Num GPUs Available: ", len(tf.config.list_physical_devices('GPU')))
|
| 20 |
+
|
| 21 |
+
snapshot_download(repo_id="acmyu/FILM", local_dir="libs/film")
|
| 22 |
+
|
| 23 |
+
self.interpolator = interpolator.Interpolator("libs/film/pretrained_models/film_net/Style/saved_model", None)
|
| 24 |
|
| 25 |
# Batched time.
|
| 26 |
self.batch_dt = np.full(shape=(1,), fill_value=0.5, dtype=np.float32)
|
| 27 |
|
| 28 |
|
| 29 |
+
def predict(self, img1, img2, times_to_interpolate):
|
| 30 |
+
#INPUT_EXT = ['.png', '.jpg', '.jpeg']
|
| 31 |
+
#assert os.path.splitext(str(frame1))[-1] in INPUT_EXT and os.path.splitext(str(frame2))[-1] in INPUT_EXT, \
|
| 32 |
+
# "Please provide png, jpg or jpeg images."
|
| 33 |
|
| 34 |
# make sure 2 images are the same size
|
| 35 |
+
#img1 = Image.open(str(frame1))
|
| 36 |
+
#img2 = Image.open(str(frame2))
|
| 37 |
if not img1.size == img2.size:
|
| 38 |
img1 = img1.crop((0, 0, min(img1.size[0], img2.size[0]), min(img1.size[1], img2.size[1])))
|
| 39 |
img2 = img2.crop((0, 0, min(img1.size[0], img2.size[0]), min(img1.size[1], img2.size[1])))
|