Spaces:
Sleeping
Sleeping
Commit
•
beb0b25
1
Parent(s):
e26c748
Update app.py
Browse files
app.py
CHANGED
@@ -13,6 +13,8 @@ import uuid
|
|
13 |
import subprocess
|
14 |
subprocess.run('pip install flash-attn --no-build-isolation', env={'FLASH_ATTENTION_SKIP_CUDA_BUILD': "TRUE"}, shell=True)
|
15 |
|
|
|
|
|
16 |
# Constants
|
17 |
MODEL_PATH = "pyramid-flow-model"
|
18 |
MODEL_REPO = "rain1011/pyramid-flow-sd3"
|
@@ -62,8 +64,9 @@ def load_model():
|
|
62 |
model = load_model()
|
63 |
|
64 |
# Text-to-video generation function
|
65 |
-
@spaces.GPU(duration=
|
66 |
def generate_video(image, prompt, duration, guidance_scale, video_guidance_scale):
|
|
|
67 |
temp = int(duration * 0.8) # Convert seconds to temp value (assuming 24 FPS)
|
68 |
torch_dtype = torch.bfloat16 if MODEL_DTYPE == "bf16" else torch.float32
|
69 |
if(image):
|
@@ -135,13 +138,22 @@ with gr.Blocks() as demo:
|
|
135 |
i2v_image = gr.Image(type="pil", label="Input Image")
|
136 |
t2v_prompt = gr.Textbox(label="Prompt")
|
137 |
with gr.Accordion("Advanced settings", open=False):
|
138 |
-
t2v_duration = gr.Slider(minimum=1, maximum=10, value=5, step=1, label="Duration (seconds)")
|
139 |
t2v_guidance_scale = gr.Slider(minimum=1, maximum=15, value=9, step=0.1, label="Guidance Scale")
|
140 |
t2v_video_guidance_scale = gr.Slider(minimum=1, maximum=15, value=5, step=0.1, label="Video Guidance Scale")
|
141 |
t2v_generate_btn = gr.Button("Generate Video")
|
142 |
with gr.Column():
|
143 |
t2v_output = gr.Video(label="Generated Video")
|
144 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
145 |
t2v_generate_btn.click(
|
146 |
generate_video,
|
147 |
inputs=[i2v_image, t2v_prompt, t2v_duration, t2v_guidance_scale, t2v_video_guidance_scale],
|
|
|
13 |
import subprocess
|
14 |
subprocess.run('pip install flash-attn --no-build-isolation', env={'FLASH_ATTENTION_SKIP_CUDA_BUILD': "TRUE"}, shell=True)
|
15 |
|
16 |
+
is_canonical = True if os.environ.get("SPACE_ID") == "multimodalart/pyramid-flow" else False
|
17 |
+
|
18 |
# Constants
|
19 |
MODEL_PATH = "pyramid-flow-model"
|
20 |
MODEL_REPO = "rain1011/pyramid-flow-sd3"
|
|
|
64 |
model = load_model()
|
65 |
|
66 |
# Text-to-video generation function
|
67 |
+
@spaces.GPU(duration=120)
|
68 |
def generate_video(image, prompt, duration, guidance_scale, video_guidance_scale):
|
69 |
+
multiplier = 0.8 if is_canonical else 2.4
|
70 |
temp = int(duration * 0.8) # Convert seconds to temp value (assuming 24 FPS)
|
71 |
torch_dtype = torch.bfloat16 if MODEL_DTYPE == "bf16" else torch.float32
|
72 |
if(image):
|
|
|
138 |
i2v_image = gr.Image(type="pil", label="Input Image")
|
139 |
t2v_prompt = gr.Textbox(label="Prompt")
|
140 |
with gr.Accordion("Advanced settings", open=False):
|
141 |
+
t2v_duration = gr.Slider(minimum=1, maximum=10, value=5, step=1, label="Duration (seconds)", visible=not is_canonical)
|
142 |
t2v_guidance_scale = gr.Slider(minimum=1, maximum=15, value=9, step=0.1, label="Guidance Scale")
|
143 |
t2v_video_guidance_scale = gr.Slider(minimum=1, maximum=15, value=5, step=0.1, label="Video Guidance Scale")
|
144 |
t2v_generate_btn = gr.Button("Generate Video")
|
145 |
with gr.Column():
|
146 |
t2v_output = gr.Video(label="Generated Video")
|
147 |
+
gr.HTML("""
|
148 |
+
<div style="display: flex; flex-direction: column;justify-content: center; align-items: center; text-align: center;">
|
149 |
+
<p style="display: flex;gap: 6px;">
|
150 |
+
<a href="https://huggingface.co/spaces/multimodalart/pyramid-flow?duplicate=true">
|
151 |
+
<img src="https://huggingface.co/datasets/huggingface/badges/resolve/main/duplicate-this-space-lg.svg" alt="Duplicate this Space">
|
152 |
+
</a>
|
153 |
+
</p>
|
154 |
+
<p>to use privately and generate videos up to 10s</p>
|
155 |
+
</div>
|
156 |
+
""")
|
157 |
t2v_generate_btn.click(
|
158 |
generate_video,
|
159 |
inputs=[i2v_image, t2v_prompt, t2v_duration, t2v_guidance_scale, t2v_video_guidance_scale],
|