Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -13,7 +13,6 @@ import tempfile
|
|
| 13 |
import gc
|
| 14 |
from PIL import Image
|
| 15 |
import numpy as np
|
| 16 |
-
from diffusers.utils import export_to_video
|
| 17 |
|
| 18 |
def pil_to_tempfile(image):
|
| 19 |
tmp = tempfile.NamedTemporaryFile(delete=False, suffix=".png")
|
|
@@ -77,29 +76,21 @@ def video_tool(video_image_input: Image.Image) -> str:
|
|
| 77 |
|
| 78 |
try:
|
| 79 |
FPS = 16
|
| 80 |
-
num_frames = aligned_num_frames(1
|
| 81 |
|
| 82 |
-
|
| 83 |
image=video_image_input.resize((480, 480)),
|
| 84 |
prompt="high quality",
|
| 85 |
negative_prompt="low quality, deformed, grainy",
|
| 86 |
num_frames=num_frames,
|
| 87 |
-
num_inference_steps=int(
|
| 88 |
-
guidance_scale=float(1),
|
| 89 |
)
|
| 90 |
|
| 91 |
-
np_frames = []
|
| 92 |
-
for f in frames:
|
| 93 |
-
if isinstance(f, Image.Image):
|
| 94 |
-
np_frames.append(np.array(f))
|
| 95 |
-
else:
|
| 96 |
-
np_frames.append(f)
|
| 97 |
-
|
| 98 |
-
|
| 99 |
out = tempfile.mktemp(suffix=".mp4")
|
| 100 |
-
|
|
|
|
| 101 |
|
| 102 |
-
gc.collect()
|
| 103 |
video_output = out
|
| 104 |
|
| 105 |
return "Video successfully generated and stored for Gradio UI."
|
|
|
|
| 13 |
import gc
|
| 14 |
from PIL import Image
|
| 15 |
import numpy as np
|
|
|
|
| 16 |
|
| 17 |
def pil_to_tempfile(image):
|
| 18 |
tmp = tempfile.NamedTemporaryFile(delete=False, suffix=".png")
|
|
|
|
| 76 |
|
| 77 |
try:
|
| 78 |
FPS = 16
|
| 79 |
+
num_frames = aligned_num_frames(1, FPS)
|
| 80 |
|
| 81 |
+
video_bytes = video_client.image_to_video(
|
| 82 |
image=video_image_input.resize((480, 480)),
|
| 83 |
prompt="high quality",
|
| 84 |
negative_prompt="low quality, deformed, grainy",
|
| 85 |
num_frames=num_frames,
|
| 86 |
+
num_inference_steps=int(20),
|
| 87 |
+
guidance_scale=float(1.4),
|
| 88 |
)
|
| 89 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
out = tempfile.mktemp(suffix=".mp4")
|
| 91 |
+
with open(out, "wb") as f:
|
| 92 |
+
f.write(video_bytes)
|
| 93 |
|
|
|
|
| 94 |
video_output = out
|
| 95 |
|
| 96 |
return "Video successfully generated and stored for Gradio UI."
|