Spaces:
Running
on
Zero
Running
on
Zero
alex
commited on
Commit
·
33e0319
1
Parent(s):
e04a1e2
unused parameter removed
Browse files
app.py
CHANGED
|
@@ -114,7 +114,7 @@ def restore_inductor_cache_from_hub(repo_id: str, filename: str = "torch_compile
|
|
| 114 |
# restore_inductor_cache_from_hub("alexnasa/humo-compiled")
|
| 115 |
|
| 116 |
|
| 117 |
-
def get_duration(prompt_text, steps, image_file, audio_file_path,
|
| 118 |
|
| 119 |
return calculate_required_time(steps, max_duration)
|
| 120 |
|
|
@@ -125,7 +125,7 @@ def calculate_required_time(steps, max_duration):
|
|
| 125 |
max_duration_duration_mapping = {
|
| 126 |
1: 8,
|
| 127 |
2: 8,
|
| 128 |
-
3:
|
| 129 |
4: 20,
|
| 130 |
}
|
| 131 |
each_step_s = max_duration_duration_mapping[max_duration]
|
|
@@ -147,7 +147,7 @@ def update_required_time(steps, max_duration):
|
|
| 147 |
return get_required_time_string(steps, max_duration)
|
| 148 |
|
| 149 |
|
| 150 |
-
def generate_scene(prompt_text, steps, image_paths, audio_file_path,
|
| 151 |
|
| 152 |
print(image_paths)
|
| 153 |
prompt_text_check = (prompt_text or "").strip()
|
|
@@ -157,7 +157,7 @@ def generate_scene(prompt_text, steps, image_paths, audio_file_path, tea_cache_l
|
|
| 157 |
if not audio_file_path and not image_paths:
|
| 158 |
raise gr.Error("Please provide a reference image or a lipsync audio.")
|
| 159 |
|
| 160 |
-
return run_pipeline(prompt_text, steps, image_paths, audio_file_path,
|
| 161 |
|
| 162 |
def upload_inductor_cache_to_hub(
|
| 163 |
repo_id: str,
|
|
@@ -211,7 +211,7 @@ def upload_inductor_cache_to_hub(
|
|
| 211 |
|
| 212 |
|
| 213 |
@spaces.GPU(duration=get_duration)
|
| 214 |
-
def run_pipeline(prompt_text, steps, image_paths, audio_file_path,
|
| 215 |
|
| 216 |
if session_id is None:
|
| 217 |
session_id = uuid.uuid4().hex
|
|
@@ -266,7 +266,7 @@ def run_pipeline(prompt_text, steps, image_paths, audio_file_path, tea_cache_l1_
|
|
| 266 |
height,
|
| 267 |
steps,
|
| 268 |
frames = int(duration_frame_mapping[max_duration]),
|
| 269 |
-
tea_cache_l1_thresh =
|
| 270 |
)
|
| 271 |
|
| 272 |
# Return resulting video path
|
|
@@ -347,7 +347,6 @@ with gr.Blocks(css=css) as demo:
|
|
| 347 |
|
| 348 |
max_duration = gr.Slider(minimum=2, maximum=4, value=default_max_duration, step=1, label="Max Duration")
|
| 349 |
steps_input = gr.Slider(minimum=10, maximum=50, value=default_steps, step=5, label="Diffusion Steps")
|
| 350 |
-
tea_cache_l1_thresh = gr.Slider(minimum=0.0, maximum=1.0, value=0.0, step=0.01, label="Cache", visible=False)
|
| 351 |
|
| 352 |
|
| 353 |
|
|
@@ -386,32 +385,36 @@ with gr.Blocks(css=css) as demo:
|
|
| 386 |
"A handheld tracking shot follows a female through a science lab. Her determined eyes are locked straight ahead. The clip is in black and white and patchy as she is explaining something to someone standing opposite her",
|
| 387 |
10,
|
| 388 |
["./examples/naomi.png"],
|
| 389 |
-
"./examples/science.wav",
|
|
|
|
| 390 |
],
|
| 391 |
|
| 392 |
[
|
| 393 |
"A reddish-brown haired woman sits pensively against swirling blue-and-white brushstrokes, dressed in a blue coat and dark waistcoat. The artistic backdrop and her thoughtful pose evoke a Post-Impressionist style in a studio-like setting.",
|
| 394 |
10,
|
| 395 |
["./examples/art.png"],
|
| 396 |
-
"./examples/art.wav",
|
|
|
|
| 397 |
],
|
| 398 |
|
| 399 |
[
|
| 400 |
-
"A handheld tracking shot follows a female warrior walking through a cave. Her determined eyes are locked straight ahead. She speaks with intensity.",
|
| 401 |
-
|
| 402 |
["./examples/naomi.png"],
|
| 403 |
-
"./examples/dream.mp3",
|
|
|
|
| 404 |
],
|
| 405 |
|
| 406 |
[
|
| 407 |
"A woman with long, wavy dark hair looking at a person sitting opposite her whilst holding a book, wearing a leather jacket, long-sleeved jacket with a semi purple color one seen on a photo. Warm, window-like light bathes her figure, highlighting the outfit's elegant design and her graceful movements.",
|
| 408 |
30,
|
| 409 |
["./examples/amber.png", "./examples/jacket.png"],
|
| 410 |
-
"./examples/fictional.wav",
|
|
|
|
| 411 |
],
|
| 412 |
|
| 413 |
],
|
| 414 |
-
inputs=[prompt_tb, steps_input, img_input, audio_input],
|
| 415 |
outputs=[video_output],
|
| 416 |
fn=run_pipeline,
|
| 417 |
cache_examples=True,
|
|
@@ -421,7 +424,7 @@ with gr.Blocks(css=css) as demo:
|
|
| 421 |
|
| 422 |
run_btn.click(
|
| 423 |
fn=generate_scene,
|
| 424 |
-
inputs=[prompt_tb, steps_input, img_input, audio_input,
|
| 425 |
outputs=[video_output],
|
| 426 |
)
|
| 427 |
|
|
|
|
| 114 |
# restore_inductor_cache_from_hub("alexnasa/humo-compiled")
|
| 115 |
|
| 116 |
|
| 117 |
+
def get_duration(prompt_text, steps, image_file, audio_file_path, max_duration, session_id):
|
| 118 |
|
| 119 |
return calculate_required_time(steps, max_duration)
|
| 120 |
|
|
|
|
| 125 |
max_duration_duration_mapping = {
|
| 126 |
1: 8,
|
| 127 |
2: 8,
|
| 128 |
+
3: 12,
|
| 129 |
4: 20,
|
| 130 |
}
|
| 131 |
each_step_s = max_duration_duration_mapping[max_duration]
|
|
|
|
| 147 |
return get_required_time_string(steps, max_duration)
|
| 148 |
|
| 149 |
|
| 150 |
+
def generate_scene(prompt_text, steps, image_paths, audio_file_path, max_duration = 3, session_id = None):
|
| 151 |
|
| 152 |
print(image_paths)
|
| 153 |
prompt_text_check = (prompt_text or "").strip()
|
|
|
|
| 157 |
if not audio_file_path and not image_paths:
|
| 158 |
raise gr.Error("Please provide a reference image or a lipsync audio.")
|
| 159 |
|
| 160 |
+
return run_pipeline(prompt_text, steps, image_paths, audio_file_path, max_duration, session_id)
|
| 161 |
|
| 162 |
def upload_inductor_cache_to_hub(
|
| 163 |
repo_id: str,
|
|
|
|
| 211 |
|
| 212 |
|
| 213 |
@spaces.GPU(duration=get_duration)
|
| 214 |
+
def run_pipeline(prompt_text, steps, image_paths, audio_file_path, max_duration = 3, session_id = None):
|
| 215 |
|
| 216 |
if session_id is None:
|
| 217 |
session_id = uuid.uuid4().hex
|
|
|
|
| 266 |
height,
|
| 267 |
steps,
|
| 268 |
frames = int(duration_frame_mapping[max_duration]),
|
| 269 |
+
tea_cache_l1_thresh = 0.0,
|
| 270 |
)
|
| 271 |
|
| 272 |
# Return resulting video path
|
|
|
|
| 347 |
|
| 348 |
max_duration = gr.Slider(minimum=2, maximum=4, value=default_max_duration, step=1, label="Max Duration")
|
| 349 |
steps_input = gr.Slider(minimum=10, maximum=50, value=default_steps, step=5, label="Diffusion Steps")
|
|
|
|
| 350 |
|
| 351 |
|
| 352 |
|
|
|
|
| 385 |
"A handheld tracking shot follows a female through a science lab. Her determined eyes are locked straight ahead. The clip is in black and white and patchy as she is explaining something to someone standing opposite her",
|
| 386 |
10,
|
| 387 |
["./examples/naomi.png"],
|
| 388 |
+
"./examples/science.wav",
|
| 389 |
+
3,
|
| 390 |
],
|
| 391 |
|
| 392 |
[
|
| 393 |
"A reddish-brown haired woman sits pensively against swirling blue-and-white brushstrokes, dressed in a blue coat and dark waistcoat. The artistic backdrop and her thoughtful pose evoke a Post-Impressionist style in a studio-like setting.",
|
| 394 |
10,
|
| 395 |
["./examples/art.png"],
|
| 396 |
+
"./examples/art.wav",
|
| 397 |
+
2,
|
| 398 |
],
|
| 399 |
|
| 400 |
[
|
| 401 |
+
"A handheld tracking shot follows a female warrior walking through a cave. Her determined eyes are locked straight ahead as she grips a blazing torch tightly in her hand. She speaks with intensity.",
|
| 402 |
+
5,
|
| 403 |
["./examples/naomi.png"],
|
| 404 |
+
"./examples/dream.mp3",
|
| 405 |
+
5,
|
| 406 |
],
|
| 407 |
|
| 408 |
[
|
| 409 |
"A woman with long, wavy dark hair looking at a person sitting opposite her whilst holding a book, wearing a leather jacket, long-sleeved jacket with a semi purple color one seen on a photo. Warm, window-like light bathes her figure, highlighting the outfit's elegant design and her graceful movements.",
|
| 410 |
30,
|
| 411 |
["./examples/amber.png", "./examples/jacket.png"],
|
| 412 |
+
"./examples/fictional.wav",
|
| 413 |
+
5,
|
| 414 |
],
|
| 415 |
|
| 416 |
],
|
| 417 |
+
inputs=[prompt_tb, steps_input, img_input, audio_input, max_duration],
|
| 418 |
outputs=[video_output],
|
| 419 |
fn=run_pipeline,
|
| 420 |
cache_examples=True,
|
|
|
|
| 424 |
|
| 425 |
run_btn.click(
|
| 426 |
fn=generate_scene,
|
| 427 |
+
inputs=[prompt_tb, steps_input, img_input, audio_input, max_duration, session_state],
|
| 428 |
outputs=[video_output],
|
| 429 |
)
|
| 430 |
|