Update app.py
Browse files
app.py
CHANGED
@@ -10,8 +10,6 @@ from diffusers.utils import export_to_video
|
|
10 |
import spaces
|
11 |
import uuid
|
12 |
|
13 |
-
is_canonical = True if os.environ.get("SPACE_ID") == "Pyramid-Flow/pyramid-flow" else False
|
14 |
-
|
15 |
# Constants
|
16 |
MODEL_PATH = "pyramid-flow-model"
|
17 |
MODEL_REPO = "rain1011/pyramid-flow-sd3"
|
@@ -62,7 +60,7 @@ model = load_model()
|
|
62 |
|
63 |
# Text-to-video generation function
|
64 |
@spaces.GPU(duration=120)
|
65 |
-
def generate_video(prompt, image=None, duration=
|
66 |
multiplier = 3
|
67 |
temp = int(duration * multiplier) + 1 # Convert seconds to temp value (assuming 24 FPS)
|
68 |
torch_dtype = torch.bfloat16 if MODEL_DTYPE == "bf16" else torch.float32
|
@@ -109,26 +107,16 @@ with gr.Blocks() as demo:
|
|
109 |
i2v_image = gr.Image(type="pil", label="Input Image")
|
110 |
t2v_prompt = gr.Textbox(label="Prompt")
|
111 |
with gr.Accordion("Advanced settings", open=False):
|
112 |
-
t2v_duration = gr.Slider(minimum=1, maximum=
|
113 |
t2v_guidance_scale = gr.Slider(minimum=1, maximum=15, value=7, step=0.1, label="Guidance Scale")
|
114 |
t2v_video_guidance_scale = gr.Slider(minimum=1, maximum=15, value=5, step=0.1, label="Video Guidance Scale")
|
115 |
t2v_generate_btn = gr.Button("Generate Video")
|
116 |
with gr.Column():
|
117 |
t2v_output = gr.Video(label="Generated Video")
|
118 |
-
gr.HTML("""
|
119 |
-
<div style="display: flex; flex-direction: column;justify-content: center; align-items: center; text-align: center;">
|
120 |
-
<p style="display: flex;gap: 6px;">
|
121 |
-
<a href="https://huggingface.co/spaces/Pyramid-Flow/pyramid-flow?duplicate=true">
|
122 |
-
<img src="https://huggingface.co/datasets/huggingface/badges/resolve/main/duplicate-this-space-lg.svg" alt="Duplicate this Space">
|
123 |
-
</a>
|
124 |
-
</p>
|
125 |
-
<p>to use privately and generate videos up to 10s</p>
|
126 |
-
</div>
|
127 |
-
""")
|
128 |
gr.Examples(
|
129 |
examples=[
|
130 |
-
"A
|
131 |
-
"
|
132 |
],
|
133 |
fn=generate_video,
|
134 |
inputs=t2v_prompt,
|
|
|
10 |
import spaces
|
11 |
import uuid
|
12 |
|
|
|
|
|
13 |
# Constants
|
14 |
MODEL_PATH = "pyramid-flow-model"
|
15 |
MODEL_REPO = "rain1011/pyramid-flow-sd3"
|
|
|
60 |
|
61 |
# Text-to-video generation function
|
62 |
@spaces.GPU(duration=120)
|
63 |
+
def generate_video(prompt, image=None, duration=5, guidance_scale=9, video_guidance_scale=5, progress=gr.Progress(track_tqdm=True)):
|
64 |
multiplier = 3
|
65 |
temp = int(duration * multiplier) + 1 # Convert seconds to temp value (assuming 24 FPS)
|
66 |
torch_dtype = torch.bfloat16 if MODEL_DTYPE == "bf16" else torch.float32
|
|
|
107 |
i2v_image = gr.Image(type="pil", label="Input Image")
|
108 |
t2v_prompt = gr.Textbox(label="Prompt")
|
109 |
with gr.Accordion("Advanced settings", open=False):
|
110 |
+
t2v_duration = gr.Slider(minimum=1, maximum=10, value=5, step=1, label="Duration (seconds)")
|
111 |
t2v_guidance_scale = gr.Slider(minimum=1, maximum=15, value=7, step=0.1, label="Guidance Scale")
|
112 |
t2v_video_guidance_scale = gr.Slider(minimum=1, maximum=15, value=5, step=0.1, label="Video Guidance Scale")
|
113 |
t2v_generate_btn = gr.Button("Generate Video")
|
114 |
with gr.Column():
|
115 |
t2v_output = gr.Video(label="Generated Video")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
gr.Examples(
|
117 |
examples=[
|
118 |
+
"A futuristic explorer, 30 years old, travels across distant galaxies in a sleek silver space suit, gliding through a glowing nebula. The scene is illuminated by vibrant starbursts and cosmic dust, captured with a futuristic drone in ultra-high-definition, showcasing vibrant purples and blues",
|
119 |
+
"In a serene winter landscape, a futuristic metropolis hums with life. The camera glides along an icy street as citizens, wrapped in advanced thermal suits, enjoy the wintry scene. Holographic advertisements flicker above snow-covered buildings, while sleek flying vehicles zip overhead. In the background, delicate crystalline structures refract light through the snowflakes."
|
120 |
],
|
121 |
fn=generate_video,
|
122 |
inputs=t2v_prompt,
|