Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -17,21 +17,21 @@ KEEP_RUNING_TASK = 3600 * 2
|
|
| 17 |
# the total running task number in 1800 seconds
|
| 18 |
LIMIT_RUNING_TASK = 10
|
| 19 |
|
| 20 |
-
def t2v_generation(prompt, resolution,
|
| 21 |
seed = seed if seed >= 0 else random.randint(0, 2147483647)
|
| 22 |
if not allow_task_num():
|
| 23 |
gr.Info(f"Warning: The number of running tasks is too large, please wait for a while.")
|
| 24 |
return None, gr.Button(visible=True)
|
| 25 |
try:
|
| 26 |
rsp = VideoSynthesis.call(model="wanx2.1-t2v-plus", prompt=prompt, seed=seed,
|
| 27 |
-
watermark_wanx=
|
| 28 |
video_url = rsp.output.video_url
|
| 29 |
return video_url, gr.Button(visible=True)
|
| 30 |
except Exception as e:
|
| 31 |
gr.Warning(f"Warning: {e}")
|
| 32 |
return None, gr.Button(visible=True)
|
| 33 |
|
| 34 |
-
def t2v_generation_async(prompt, size,
|
| 35 |
print(seed)
|
| 36 |
seed = seed if seed >= 0 else random.randint(0, 2147483647)
|
| 37 |
print(seed)
|
|
@@ -43,7 +43,7 @@ def t2v_generation_async(prompt, size, watermark_wanx, seed = -1):
|
|
| 43 |
prompt=prompt,
|
| 44 |
size=size,
|
| 45 |
seed=seed,
|
| 46 |
-
watermark_wanx=
|
| 47 |
task_id = rsp.output.task_id
|
| 48 |
status = False
|
| 49 |
return task_id, status, gr.Button(visible=False)
|
|
@@ -51,27 +51,27 @@ def t2v_generation_async(prompt, size, watermark_wanx, seed = -1):
|
|
| 51 |
gr.Warning(f"Warning: {e}")
|
| 52 |
return None, True, gr.Button()
|
| 53 |
|
| 54 |
-
def i2v_generation(prompt, image,
|
| 55 |
seed = seed if seed >= 0 else random.randint(0, 2147483647)
|
| 56 |
video_url = None
|
| 57 |
try:
|
| 58 |
rsp = VideoSynthesis.call(model="wanx2.1-i2v-plus", prompt=prompt, img_url= image,
|
| 59 |
seed = seed,
|
| 60 |
-
watermark_wanx=
|
| 61 |
)
|
| 62 |
video_url = rsp.output.video_url
|
| 63 |
except Exception as e:
|
| 64 |
gr.Warning(f"Warning: {e}")
|
| 65 |
return video_url
|
| 66 |
|
| 67 |
-
def i2v_generation_async(prompt, image,
|
| 68 |
seed = seed if seed >= 0 else random.randint(0, 2147483647)
|
| 69 |
if not allow_task_num():
|
| 70 |
gr.Info(f"Warning: The number of running tasks is too large, please wait for a while.")
|
| 71 |
return "", None, gr.Button(visible=True)
|
| 72 |
try:
|
| 73 |
rsp = VideoSynthesis.async_call(model="wanx2.1-i2v-plus", prompt=prompt, seed=seed,
|
| 74 |
-
img_url= image, watermark_wanx=
|
| 75 |
print(rsp)
|
| 76 |
task_id = rsp.output.task_id
|
| 77 |
status = False
|
|
@@ -206,7 +206,7 @@ with gr.Blocks() as demo:
|
|
| 206 |
interactive=False,
|
| 207 |
height=500)
|
| 208 |
with gr.Row():
|
| 209 |
-
|
| 210 |
seed = gr.Number(label="Seed", value=-1, container=True)
|
| 211 |
cost_time = gr.Number(label="Cost Time(secs)", value=cost_time, interactive=False,
|
| 212 |
every=2, inputs=[task_id], container=True)
|
|
@@ -248,13 +248,13 @@ with gr.Blocks() as demo:
|
|
| 248 |
|
| 249 |
run_t2v_button.click(
|
| 250 |
fn=t2v_generation_async,
|
| 251 |
-
inputs=[txt2vid_prompt, resolution,
|
| 252 |
outputs=[task_id, status, run_t2v_button],
|
| 253 |
)
|
| 254 |
|
| 255 |
run_i2v_button.click(
|
| 256 |
fn=i2v_generation_async,
|
| 257 |
-
inputs=[img2vid_prompt, img2vid_image,
|
| 258 |
outputs=[task_id, status, run_i2v_button],
|
| 259 |
)
|
| 260 |
|
|
|
|
| 17 |
# the total running task number in 1800 seconds
|
| 18 |
LIMIT_RUNING_TASK = 10
|
| 19 |
|
| 20 |
+
def t2v_generation(prompt, resolution, watermark_wan, seed = -1):
|
| 21 |
seed = seed if seed >= 0 else random.randint(0, 2147483647)
|
| 22 |
if not allow_task_num():
|
| 23 |
gr.Info(f"Warning: The number of running tasks is too large, please wait for a while.")
|
| 24 |
return None, gr.Button(visible=True)
|
| 25 |
try:
|
| 26 |
rsp = VideoSynthesis.call(model="wanx2.1-t2v-plus", prompt=prompt, seed=seed,
|
| 27 |
+
watermark_wanx=watermark_wan, size=resolution)
|
| 28 |
video_url = rsp.output.video_url
|
| 29 |
return video_url, gr.Button(visible=True)
|
| 30 |
except Exception as e:
|
| 31 |
gr.Warning(f"Warning: {e}")
|
| 32 |
return None, gr.Button(visible=True)
|
| 33 |
|
| 34 |
+
def t2v_generation_async(prompt, size, watermark_wan, seed = -1):
|
| 35 |
print(seed)
|
| 36 |
seed = seed if seed >= 0 else random.randint(0, 2147483647)
|
| 37 |
print(seed)
|
|
|
|
| 43 |
prompt=prompt,
|
| 44 |
size=size,
|
| 45 |
seed=seed,
|
| 46 |
+
watermark_wanx=watermark_wan)
|
| 47 |
task_id = rsp.output.task_id
|
| 48 |
status = False
|
| 49 |
return task_id, status, gr.Button(visible=False)
|
|
|
|
| 51 |
gr.Warning(f"Warning: {e}")
|
| 52 |
return None, True, gr.Button()
|
| 53 |
|
| 54 |
+
def i2v_generation(prompt, image, watermark_wan, seed = -1):
|
| 55 |
seed = seed if seed >= 0 else random.randint(0, 2147483647)
|
| 56 |
video_url = None
|
| 57 |
try:
|
| 58 |
rsp = VideoSynthesis.call(model="wanx2.1-i2v-plus", prompt=prompt, img_url= image,
|
| 59 |
seed = seed,
|
| 60 |
+
watermark_wanx=watermark_wan
|
| 61 |
)
|
| 62 |
video_url = rsp.output.video_url
|
| 63 |
except Exception as e:
|
| 64 |
gr.Warning(f"Warning: {e}")
|
| 65 |
return video_url
|
| 66 |
|
| 67 |
+
def i2v_generation_async(prompt, image, watermark_wan, seed = -1):
|
| 68 |
seed = seed if seed >= 0 else random.randint(0, 2147483647)
|
| 69 |
if not allow_task_num():
|
| 70 |
gr.Info(f"Warning: The number of running tasks is too large, please wait for a while.")
|
| 71 |
return "", None, gr.Button(visible=True)
|
| 72 |
try:
|
| 73 |
rsp = VideoSynthesis.async_call(model="wanx2.1-i2v-plus", prompt=prompt, seed=seed,
|
| 74 |
+
img_url= image, watermark_wanx=watermark_wan)
|
| 75 |
print(rsp)
|
| 76 |
task_id = rsp.output.task_id
|
| 77 |
status = False
|
|
|
|
| 206 |
interactive=False,
|
| 207 |
height=500)
|
| 208 |
with gr.Row():
|
| 209 |
+
watermark_wan = gr.Checkbox(label="Watermark", value=True, container=False)
|
| 210 |
seed = gr.Number(label="Seed", value=-1, container=True)
|
| 211 |
cost_time = gr.Number(label="Cost Time(secs)", value=cost_time, interactive=False,
|
| 212 |
every=2, inputs=[task_id], container=True)
|
|
|
|
| 248 |
|
| 249 |
run_t2v_button.click(
|
| 250 |
fn=t2v_generation_async,
|
| 251 |
+
inputs=[txt2vid_prompt, resolution, watermark_wan, seed],
|
| 252 |
outputs=[task_id, status, run_t2v_button],
|
| 253 |
)
|
| 254 |
|
| 255 |
run_i2v_button.click(
|
| 256 |
fn=i2v_generation_async,
|
| 257 |
+
inputs=[img2vid_prompt, img2vid_image, watermark_wan, seed],
|
| 258 |
outputs=[task_id, status, run_i2v_button],
|
| 259 |
)
|
| 260 |
|