Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,6 +4,8 @@ import torch
|
|
| 4 |
import spaces
|
| 5 |
import random
|
| 6 |
from PIL import Image
|
|
|
|
|
|
|
| 7 |
|
| 8 |
from glob import glob
|
| 9 |
from pathlib import Path
|
|
@@ -20,8 +22,7 @@ from huggingface_hub import hf_hub_download
|
|
| 20 |
os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"
|
| 21 |
HF_TOKEN = os.environ.get("HF_TOKEN", None)
|
| 22 |
# Constants
|
| 23 |
-
|
| 24 |
-
MAX_SEED = 2147483647
|
| 25 |
CSS = """
|
| 26 |
footer {
|
| 27 |
visibility: hidden;
|
|
@@ -56,13 +57,13 @@ def generate(
|
|
| 56 |
output_folder: str = "outputs",
|
| 57 |
progress=gr.Progress(track_tqdm=True)):
|
| 58 |
|
|
|
|
|
|
|
| 59 |
if seed == -1:
|
| 60 |
seed = random.randint(0, MAX_SEED)
|
| 61 |
|
| 62 |
image = Image.open(image)
|
| 63 |
-
|
| 64 |
-
image = image.convert("RGB")
|
| 65 |
-
|
| 66 |
torch.manual_seed(seed)
|
| 67 |
|
| 68 |
os.makedirs(output_folder, exist_ok=True)
|
|
@@ -101,7 +102,7 @@ with gr.Blocks(css=CSS, js=JS, theme="soft") as demo:
|
|
| 101 |
gr.HTML("<h1><center>Exvideoπ½οΈ</center></h1>")
|
| 102 |
gr.HTML("<p><center><a href='https://huggingface.co/ECNU-CILab/ExVideo-SVD-128f-v1'>ExVideo</a> image-to-video generation<br><b>Update</b>: first version</center></p>")
|
| 103 |
with gr.Row():
|
| 104 |
-
image = gr.Image(label='Upload Image', height=600, scale=2)
|
| 105 |
video = gr.Video(label="Generated Video", height=600, scale=2)
|
| 106 |
with gr.Accordion("Advanced Options", open=True):
|
| 107 |
with gr.Column(scale=1):
|
|
@@ -126,9 +127,9 @@ with gr.Blocks(css=CSS, js=JS, theme="soft") as demo:
|
|
| 126 |
minimum=5,
|
| 127 |
maximum=30
|
| 128 |
)
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
gr.Examples(
|
| 133 |
examples=examples,
|
| 134 |
inputs=image,
|
|
|
|
| 4 |
import spaces
|
| 5 |
import random
|
| 6 |
from PIL import Image
|
| 7 |
+
import icecream as ic
|
| 8 |
+
import numpy as np
|
| 9 |
|
| 10 |
from glob import glob
|
| 11 |
from pathlib import Path
|
|
|
|
| 22 |
os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"
|
| 23 |
HF_TOKEN = os.environ.get("HF_TOKEN", None)
|
| 24 |
# Constants
|
| 25 |
+
MAX_SEED = np.iinfo(np.int32).max
|
|
|
|
| 26 |
CSS = """
|
| 27 |
footer {
|
| 28 |
visibility: hidden;
|
|
|
|
| 57 |
output_folder: str = "outputs",
|
| 58 |
progress=gr.Progress(track_tqdm=True)):
|
| 59 |
|
| 60 |
+
ic(image)
|
| 61 |
+
|
| 62 |
if seed == -1:
|
| 63 |
seed = random.randint(0, MAX_SEED)
|
| 64 |
|
| 65 |
image = Image.open(image)
|
| 66 |
+
|
|
|
|
|
|
|
| 67 |
torch.manual_seed(seed)
|
| 68 |
|
| 69 |
os.makedirs(output_folder, exist_ok=True)
|
|
|
|
| 102 |
gr.HTML("<h1><center>Exvideoπ½οΈ</center></h1>")
|
| 103 |
gr.HTML("<p><center><a href='https://huggingface.co/ECNU-CILab/ExVideo-SVD-128f-v1'>ExVideo</a> image-to-video generation<br><b>Update</b>: first version</center></p>")
|
| 104 |
with gr.Row():
|
| 105 |
+
image = gr.Image(label='Upload Image', height=600, scale=2, image_mode="RGB", type="filepath")
|
| 106 |
video = gr.Video(label="Generated Video", height=600, scale=2)
|
| 107 |
with gr.Accordion("Advanced Options", open=True):
|
| 108 |
with gr.Column(scale=1):
|
|
|
|
| 127 |
minimum=5,
|
| 128 |
maximum=30
|
| 129 |
)
|
| 130 |
+
with gr.Row():
|
| 131 |
+
submit_btn = gr.Button(value="Generate")
|
| 132 |
+
clear_btn = gr.ClearButton([image, seed, video])
|
| 133 |
gr.Examples(
|
| 134 |
examples=examples,
|
| 135 |
inputs=image,
|