Fabrice-TIERCELIN
commited on
Adapt UI
Browse files- gradio_server.py +8 -10
gradio_server.py
CHANGED
@@ -5,6 +5,7 @@ from loguru import logger
|
|
5 |
from datetime import datetime
|
6 |
import gradio as gr
|
7 |
import random
|
|
|
8 |
|
9 |
from hyvideo.utils.file_utils import save_videos_grid
|
10 |
from hyvideo.config import parse_args
|
@@ -20,6 +21,7 @@ def initialize_model(model_path):
|
|
20 |
hunyuan_video_sampler = HunyuanVideoSampler.from_pretrained(models_root_path, args=args)
|
21 |
return hunyuan_video_sampler
|
22 |
|
|
|
23 |
def generate_video(
|
24 |
model,
|
25 |
prompt,
|
@@ -89,7 +91,7 @@ def create_demo(model_path, save_path):
|
|
89 |
("624x832 (3:4, 540p)", "624x832"),
|
90 |
("720x720 (1:1, 540p)", "720x720"),
|
91 |
],
|
92 |
-
value="
|
93 |
label="Resolution"
|
94 |
)
|
95 |
video_length = gr.Dropdown(
|
@@ -98,9 +100,9 @@ def create_demo(model_path, save_path):
|
|
98 |
("2s(65f)", 65),
|
99 |
("5s(129f)", 129),
|
100 |
],
|
101 |
-
value=
|
102 |
)
|
103 |
-
num_inference_steps = gr.Slider(1, 100, value=
|
104 |
show_advanced = gr.Checkbox(label="Show Advanced Options", value=False)
|
105 |
with gr.Row(visible=False) as advanced_row:
|
106 |
with gr.Column():
|
@@ -109,10 +111,10 @@ def create_demo(model_path, save_path):
|
|
109 |
flow_shift = gr.Slider(0.0, 10.0, value=7.0, step=0.1, label="Flow Shift")
|
110 |
embedded_guidance_scale = gr.Slider(1.0, 20.0, value=6.0, step=0.5, label="Embedded Guidance Scale")
|
111 |
show_advanced.change(fn=lambda x: gr.Row(visible=x), inputs=[show_advanced], outputs=[advanced_row])
|
112 |
-
generate_btn = gr.Button("Generate")
|
113 |
|
114 |
with gr.Column():
|
115 |
-
output = gr.Video(label="Generated Video")
|
116 |
|
117 |
generate_btn.click(
|
118 |
fn=lambda *inputs: generate_video(model, *inputs),
|
@@ -133,9 +135,5 @@ def create_demo(model_path, save_path):
|
|
133 |
|
134 |
if __name__ == "__main__":
|
135 |
os.environ["GRADIO_ANALYTICS_ENABLED"] = "False"
|
136 |
-
server_name = os.getenv("SERVER_NAME", "0.0.0.0")
|
137 |
-
server_port = int(os.getenv("SERVER_PORT", "8081"))
|
138 |
-
args = parse_args()
|
139 |
-
print(args)
|
140 |
demo = create_demo(args.model_base, args.save_path)
|
141 |
-
demo.launch(
|
|
|
5 |
from datetime import datetime
|
6 |
import gradio as gr
|
7 |
import random
|
8 |
+
import spaces
|
9 |
|
10 |
from hyvideo.utils.file_utils import save_videos_grid
|
11 |
from hyvideo.config import parse_args
|
|
|
21 |
hunyuan_video_sampler = HunyuanVideoSampler.from_pretrained(models_root_path, args=args)
|
22 |
return hunyuan_video_sampler
|
23 |
|
24 |
+
@spaces.GPU(duration=120)
|
25 |
def generate_video(
|
26 |
model,
|
27 |
prompt,
|
|
|
91 |
("624x832 (3:4, 540p)", "624x832"),
|
92 |
("720x720 (1:1, 540p)", "720x720"),
|
93 |
],
|
94 |
+
value="832x624",
|
95 |
label="Resolution"
|
96 |
)
|
97 |
video_length = gr.Dropdown(
|
|
|
100 |
("2s(65f)", 65),
|
101 |
("5s(129f)", 129),
|
102 |
],
|
103 |
+
value=65,
|
104 |
)
|
105 |
+
num_inference_steps = gr.Slider(1, 100, value=5, step=1, label="Number of Inference Steps")
|
106 |
show_advanced = gr.Checkbox(label="Show Advanced Options", value=False)
|
107 |
with gr.Row(visible=False) as advanced_row:
|
108 |
with gr.Column():
|
|
|
111 |
flow_shift = gr.Slider(0.0, 10.0, value=7.0, step=0.1, label="Flow Shift")
|
112 |
embedded_guidance_scale = gr.Slider(1.0, 20.0, value=6.0, step=0.5, label="Embedded Guidance Scale")
|
113 |
show_advanced.change(fn=lambda x: gr.Row(visible=x), inputs=[show_advanced], outputs=[advanced_row])
|
114 |
+
generate_btn = gr.Button(value = "🚀 Generate Video", variant = "primary")
|
115 |
|
116 |
with gr.Column():
|
117 |
+
output = gr.Video(label = "Generated Video", autoplay = True)
|
118 |
|
119 |
generate_btn.click(
|
120 |
fn=lambda *inputs: generate_video(model, *inputs),
|
|
|
135 |
|
136 |
if __name__ == "__main__":
|
137 |
os.environ["GRADIO_ANALYTICS_ENABLED"] = "False"
|
|
|
|
|
|
|
|
|
138 |
demo = create_demo(args.model_base, args.save_path)
|
139 |
+
demo.queue(10).launch()
|