Spaces:
Runtime error
Runtime error
Add end_image
Browse files
app.py
CHANGED
|
@@ -120,6 +120,7 @@ outputs_folder = './outputs/'
|
|
| 120 |
os.makedirs(outputs_folder, exist_ok=True)
|
| 121 |
|
| 122 |
input_image_debug_value = [None]
|
|
|
|
| 123 |
input_video_debug_value = [None]
|
| 124 |
prompt_debug_value = [None]
|
| 125 |
total_second_length_debug_value = [None]
|
|
@@ -315,7 +316,7 @@ def set_mp4_comments_imageio_ffmpeg(input_file, comments):
|
|
| 315 |
return False
|
| 316 |
|
| 317 |
@torch.no_grad()
|
| 318 |
-
def worker(input_image, image_position, prompts, n_prompt, seed, resolution, total_second_length, latent_window_size, steps, cfg, gs, rs, gpu_memory_preservation, enable_preview, use_teacache, mp4_crf, fps_number):
|
| 319 |
def encode_prompt(prompt, n_prompt):
|
| 320 |
llama_vec, clip_l_pooler = encode_prompt_conds(prompt, text_encoder, text_encoder_2, tokenizer, tokenizer_2)
|
| 321 |
|
|
@@ -864,18 +865,17 @@ def worker_video(input_video, prompts, n_prompt, seed, batch, resolution, total_
|
|
| 864 |
stream.output_queue.push(('end', None))
|
| 865 |
return
|
| 866 |
|
| 867 |
-
def get_duration(input_image, image_position, prompts, generation_mode, n_prompt, seed, resolution, total_second_length, allocation_time, latent_window_size, steps, cfg, gs, rs, gpu_memory_preservation, enable_preview, use_teacache, mp4_crf, fps_number):
|
| 868 |
return allocation_time
|
| 869 |
|
| 870 |
-
# Remove this decorator if you run on local
|
| 871 |
@spaces.GPU(duration=get_duration)
|
| 872 |
-
def process_on_gpu(input_image, image_position, prompts, generation_mode, n_prompt, seed, resolution, total_second_length, allocation_time, latent_window_size, steps, cfg, gs, rs, gpu_memory_preservation, enable_preview, use_teacache, mp4_crf, fps_number
|
| 873 |
):
|
| 874 |
start = time.time()
|
| 875 |
global stream
|
| 876 |
stream = AsyncStream()
|
| 877 |
|
| 878 |
-
async_run(worker, input_image, image_position, prompts, n_prompt, seed, resolution, total_second_length, latent_window_size, steps, cfg, gs, rs, gpu_memory_preservation, enable_preview, use_teacache, mp4_crf, fps_number)
|
| 879 |
|
| 880 |
output_filename = None
|
| 881 |
|
|
@@ -905,6 +905,7 @@ def process_on_gpu(input_image, image_position, prompts, generation_mode, n_prom
|
|
| 905 |
break
|
| 906 |
|
| 907 |
def process(input_image,
|
|
|
|
| 908 |
image_position=0,
|
| 909 |
prompt="",
|
| 910 |
generation_mode="image",
|
|
@@ -955,6 +956,7 @@ def process(input_image,
|
|
| 955 |
yield gr.update(label="Previewed Frames"), None, '', '', gr.update(interactive=False), gr.update(interactive=True), gr.skip()
|
| 956 |
|
| 957 |
yield from process_on_gpu(input_image,
|
|
|
|
| 958 |
image_position,
|
| 959 |
prompts,
|
| 960 |
generation_mode,
|
|
@@ -978,7 +980,6 @@ def process(input_image,
|
|
| 978 |
def get_duration_video(input_video, prompts, n_prompt, seed, batch, resolution, total_second_length, allocation_time, latent_window_size, steps, cfg, gs, rs, gpu_memory_preservation, enable_preview, use_teacache, no_resize, mp4_crf, num_clean_frames, vae_batch):
|
| 979 |
return allocation_time
|
| 980 |
|
| 981 |
-
# Remove this decorator if you run on local
|
| 982 |
@spaces.GPU(duration=get_duration_video)
|
| 983 |
def process_video_on_gpu(input_video, prompts, n_prompt, seed, batch, resolution, total_second_length, allocation_time, latent_window_size, steps, cfg, gs, rs, gpu_memory_preservation, enable_preview, use_teacache, no_resize, mp4_crf, num_clean_frames, vae_batch):
|
| 984 |
start = time.time()
|
|
@@ -1216,7 +1217,7 @@ with block:
|
|
| 1216 |
progress_bar = gr.HTML('', elem_classes='no-generating-animation')
|
| 1217 |
|
| 1218 |
# 20250506 pftq: Updated inputs to include num_clean_frames
|
| 1219 |
-
ips = [input_image, image_position, final_prompt, generation_mode, n_prompt, randomize_seed, seed, auto_allocation, allocation_time, resolution, total_second_length, latent_window_size, steps, cfg, gs, rs, gpu_memory_preservation, enable_preview, use_teacache, mp4_crf, fps_number]
|
| 1220 |
ips_video = [input_video, final_prompt, n_prompt, randomize_seed, seed, auto_allocation, allocation_time, batch, resolution, total_second_length, latent_window_size, steps, cfg, gs, rs, gpu_memory_preservation, enable_preview, use_teacache, no_resize, mp4_crf, num_clean_frames, vae_batch]
|
| 1221 |
|
| 1222 |
with gr.Row(elem_id="text_examples", visible=False):
|
|
@@ -1225,6 +1226,7 @@ with block:
|
|
| 1225 |
examples = [
|
| 1226 |
[
|
| 1227 |
None, # input_image
|
|
|
|
| 1228 |
0, # image_position
|
| 1229 |
"Overcrowed street in Japan, photorealistic, realistic, intricate details, 8k, insanely detailed",
|
| 1230 |
"text", # generation_mode
|
|
@@ -1260,6 +1262,7 @@ with block:
|
|
| 1260 |
examples = [
|
| 1261 |
[
|
| 1262 |
"./img_examples/Example2.webp", # input_image
|
|
|
|
| 1263 |
0, # image_position
|
| 1264 |
"A man on the left and a woman on the right face each other ready to start a conversation, large space between the persons, full view, full-length view, 3D, pixar, 3D render, CGI. The man talks and the woman listens; A man on the left and a woman on the right face each other ready to start a conversation, large space between the persons, full view, full-length view, 3D, pixar, 3D render, CGI. The woman talks, the man stops talking and the man listens; A man on the left and a woman on the right face each other ready to start a conversation, large space between the persons, full view, full-length view, 3D, pixar, 3D render, CGI. The woman talks and the man listens",
|
| 1265 |
"image", # generation_mode
|
|
@@ -1283,6 +1286,7 @@ with block:
|
|
| 1283 |
],
|
| 1284 |
[
|
| 1285 |
"./img_examples/Example1.png", # input_image
|
|
|
|
| 1286 |
0, # image_position
|
| 1287 |
"A dolphin emerges from the water, photorealistic, realistic, intricate details, 8k, insanely detailed",
|
| 1288 |
"image", # generation_mode
|
|
@@ -1306,6 +1310,7 @@ with block:
|
|
| 1306 |
],
|
| 1307 |
[
|
| 1308 |
"./img_examples/Example4.webp", # input_image
|
|
|
|
| 1309 |
1, # image_position
|
| 1310 |
"A building starting to explode, photorealistic, realisitc, 8k, insanely detailed",
|
| 1311 |
"image", # generation_mode
|
|
@@ -1329,6 +1334,7 @@ with block:
|
|
| 1329 |
],
|
| 1330 |
[
|
| 1331 |
"./img_examples/Example4.webp", # input_image
|
|
|
|
| 1332 |
50, # image_position
|
| 1333 |
"A building starting to explode, photorealistic, realisitc, 8k, insanely detailed",
|
| 1334 |
"image", # generation_mode
|
|
@@ -1352,6 +1358,7 @@ with block:
|
|
| 1352 |
],
|
| 1353 |
[
|
| 1354 |
"./img_examples/Example4.webp", # input_image
|
|
|
|
| 1355 |
100, # image_position
|
| 1356 |
"A building starting to explode, photorealistic, realisitc, 8k, insanely detailed",
|
| 1357 |
"image", # generation_mode
|
|
@@ -1446,6 +1453,7 @@ with block:
|
|
| 1446 |
examples = [
|
| 1447 |
[
|
| 1448 |
None, # input_image
|
|
|
|
| 1449 |
0, # image_position
|
| 1450 |
"Overcrowed street in Japan, photorealistic, realistic, intricate details, 8k, insanely detailed",
|
| 1451 |
"text", # generation_mode
|
|
@@ -1480,6 +1488,7 @@ with block:
|
|
| 1480 |
examples = [
|
| 1481 |
[
|
| 1482 |
"./img_examples/Example1.png", # input_image
|
|
|
|
| 1483 |
0, # image_position
|
| 1484 |
"A dolphin emerges from the water, photorealistic, realistic, intricate details, 8k, insanely detailed",
|
| 1485 |
"image", # generation_mode
|
|
@@ -1503,6 +1512,7 @@ with block:
|
|
| 1503 |
],
|
| 1504 |
[
|
| 1505 |
"./img_examples/Example2.webp", # input_image
|
|
|
|
| 1506 |
0, # image_position
|
| 1507 |
"A man on the left and a woman on the right face each other ready to start a conversation, large space between the persons, full view, full-length view, 3D, pixar, 3D render, CGI. The man talks and the woman listens; A man on the left and a woman on the right face each other ready to start a conversation, large space between the persons, full view, full-length view, 3D, pixar, 3D render, CGI. The woman talks, the man stops talking and the man listens; A man on the left and a woman on the right face each other ready to start a conversation, large space between the persons, full view, full-length view, 3D, pixar, 3D render, CGI. The woman talks and the man listens",
|
| 1508 |
"image", # generation_mode
|
|
@@ -1526,6 +1536,7 @@ with block:
|
|
| 1526 |
],
|
| 1527 |
[
|
| 1528 |
"./img_examples/Example2.webp", # input_image
|
|
|
|
| 1529 |
0, # image_position
|
| 1530 |
"A man on the left and a woman on the right face each other ready to start a conversation, large space between the persons, full view, full-length view, 3D, pixar, 3D render, CGI. The woman talks and the man listens; A man on the left and a woman on the right face each other ready to start a conversation, large space between the persons, full view, full-length view, 3D, pixar, 3D render, CGI. The man talks, the woman stops talking and the woman listens A man on the left and a woman on the right face each other ready to start a conversation, large space between the persons, full view, full-length view, 3D, pixar, 3D render, CGI. The man talks and the woman listens",
|
| 1531 |
"image", # generation_mode
|
|
@@ -1549,6 +1560,7 @@ with block:
|
|
| 1549 |
],
|
| 1550 |
[
|
| 1551 |
"./img_examples/Example3.jpg", # input_image
|
|
|
|
| 1552 |
0, # image_position
|
| 1553 |
"A boy is walking to the right, full view, full-length view, cartoon",
|
| 1554 |
"image", # generation_mode
|
|
@@ -1572,6 +1584,7 @@ with block:
|
|
| 1572 |
],
|
| 1573 |
[
|
| 1574 |
"./img_examples/Example4.webp", # input_image
|
|
|
|
| 1575 |
100, # image_position
|
| 1576 |
"A building starting to explode, photorealistic, realisitc, 8k, insanely detailed",
|
| 1577 |
"image", # generation_mode
|
|
|
|
| 120 |
os.makedirs(outputs_folder, exist_ok=True)
|
| 121 |
|
| 122 |
input_image_debug_value = [None]
|
| 123 |
+
end_image_debug_value = [None]
|
| 124 |
input_video_debug_value = [None]
|
| 125 |
prompt_debug_value = [None]
|
| 126 |
total_second_length_debug_value = [None]
|
|
|
|
| 316 |
return False
|
| 317 |
|
| 318 |
@torch.no_grad()
|
| 319 |
+
def worker(input_image, end_image, image_position, prompts, n_prompt, seed, resolution, total_second_length, latent_window_size, steps, cfg, gs, rs, gpu_memory_preservation, enable_preview, use_teacache, mp4_crf, fps_number):
|
| 320 |
def encode_prompt(prompt, n_prompt):
|
| 321 |
llama_vec, clip_l_pooler = encode_prompt_conds(prompt, text_encoder, text_encoder_2, tokenizer, tokenizer_2)
|
| 322 |
|
|
|
|
| 865 |
stream.output_queue.push(('end', None))
|
| 866 |
return
|
| 867 |
|
| 868 |
+
def get_duration(input_image, end_image, image_position, prompts, generation_mode, n_prompt, seed, resolution, total_second_length, allocation_time, latent_window_size, steps, cfg, gs, rs, gpu_memory_preservation, enable_preview, use_teacache, mp4_crf, fps_number):
|
| 869 |
return allocation_time
|
| 870 |
|
|
|
|
| 871 |
@spaces.GPU(duration=get_duration)
|
| 872 |
+
def process_on_gpu(input_image, end_image, image_position, prompts, generation_mode, n_prompt, seed, resolution, total_second_length, allocation_time, latent_window_size, steps, cfg, gs, rs, gpu_memory_preservation, enable_preview, use_teacache, mp4_crf, fps_number
|
| 873 |
):
|
| 874 |
start = time.time()
|
| 875 |
global stream
|
| 876 |
stream = AsyncStream()
|
| 877 |
|
| 878 |
+
async_run(worker, input_image, end_image, image_position, prompts, n_prompt, seed, resolution, total_second_length, latent_window_size, steps, cfg, gs, rs, gpu_memory_preservation, enable_preview, use_teacache, mp4_crf, fps_number)
|
| 879 |
|
| 880 |
output_filename = None
|
| 881 |
|
|
|
|
| 905 |
break
|
| 906 |
|
| 907 |
def process(input_image,
|
| 908 |
+
end_image,
|
| 909 |
image_position=0,
|
| 910 |
prompt="",
|
| 911 |
generation_mode="image",
|
|
|
|
| 956 |
yield gr.update(label="Previewed Frames"), None, '', '', gr.update(interactive=False), gr.update(interactive=True), gr.skip()
|
| 957 |
|
| 958 |
yield from process_on_gpu(input_image,
|
| 959 |
+
end_image,
|
| 960 |
image_position,
|
| 961 |
prompts,
|
| 962 |
generation_mode,
|
|
|
|
| 980 |
def get_duration_video(input_video, prompts, n_prompt, seed, batch, resolution, total_second_length, allocation_time, latent_window_size, steps, cfg, gs, rs, gpu_memory_preservation, enable_preview, use_teacache, no_resize, mp4_crf, num_clean_frames, vae_batch):
|
| 981 |
return allocation_time
|
| 982 |
|
|
|
|
| 983 |
@spaces.GPU(duration=get_duration_video)
|
| 984 |
def process_video_on_gpu(input_video, prompts, n_prompt, seed, batch, resolution, total_second_length, allocation_time, latent_window_size, steps, cfg, gs, rs, gpu_memory_preservation, enable_preview, use_teacache, no_resize, mp4_crf, num_clean_frames, vae_batch):
|
| 985 |
start = time.time()
|
|
|
|
| 1217 |
progress_bar = gr.HTML('', elem_classes='no-generating-animation')
|
| 1218 |
|
| 1219 |
# 20250506 pftq: Updated inputs to include num_clean_frames
|
| 1220 |
+
ips = [input_image, end_image, image_position, final_prompt, generation_mode, n_prompt, randomize_seed, seed, auto_allocation, allocation_time, resolution, total_second_length, latent_window_size, steps, cfg, gs, rs, gpu_memory_preservation, enable_preview, use_teacache, mp4_crf, fps_number]
|
| 1221 |
ips_video = [input_video, final_prompt, n_prompt, randomize_seed, seed, auto_allocation, allocation_time, batch, resolution, total_second_length, latent_window_size, steps, cfg, gs, rs, gpu_memory_preservation, enable_preview, use_teacache, no_resize, mp4_crf, num_clean_frames, vae_batch]
|
| 1222 |
|
| 1223 |
with gr.Row(elem_id="text_examples", visible=False):
|
|
|
|
| 1226 |
examples = [
|
| 1227 |
[
|
| 1228 |
None, # input_image
|
| 1229 |
+
None, # end_image
|
| 1230 |
0, # image_position
|
| 1231 |
"Overcrowed street in Japan, photorealistic, realistic, intricate details, 8k, insanely detailed",
|
| 1232 |
"text", # generation_mode
|
|
|
|
| 1262 |
examples = [
|
| 1263 |
[
|
| 1264 |
"./img_examples/Example2.webp", # input_image
|
| 1265 |
+
None, # end_image
|
| 1266 |
0, # image_position
|
| 1267 |
"A man on the left and a woman on the right face each other ready to start a conversation, large space between the persons, full view, full-length view, 3D, pixar, 3D render, CGI. The man talks and the woman listens; A man on the left and a woman on the right face each other ready to start a conversation, large space between the persons, full view, full-length view, 3D, pixar, 3D render, CGI. The woman talks, the man stops talking and the man listens; A man on the left and a woman on the right face each other ready to start a conversation, large space between the persons, full view, full-length view, 3D, pixar, 3D render, CGI. The woman talks and the man listens",
|
| 1268 |
"image", # generation_mode
|
|
|
|
| 1286 |
],
|
| 1287 |
[
|
| 1288 |
"./img_examples/Example1.png", # input_image
|
| 1289 |
+
None, # end_image
|
| 1290 |
0, # image_position
|
| 1291 |
"A dolphin emerges from the water, photorealistic, realistic, intricate details, 8k, insanely detailed",
|
| 1292 |
"image", # generation_mode
|
|
|
|
| 1310 |
],
|
| 1311 |
[
|
| 1312 |
"./img_examples/Example4.webp", # input_image
|
| 1313 |
+
None, # end_image
|
| 1314 |
1, # image_position
|
| 1315 |
"A building starting to explode, photorealistic, realisitc, 8k, insanely detailed",
|
| 1316 |
"image", # generation_mode
|
|
|
|
| 1334 |
],
|
| 1335 |
[
|
| 1336 |
"./img_examples/Example4.webp", # input_image
|
| 1337 |
+
None, # end_image
|
| 1338 |
50, # image_position
|
| 1339 |
"A building starting to explode, photorealistic, realisitc, 8k, insanely detailed",
|
| 1340 |
"image", # generation_mode
|
|
|
|
| 1358 |
],
|
| 1359 |
[
|
| 1360 |
"./img_examples/Example4.webp", # input_image
|
| 1361 |
+
None, # end_image
|
| 1362 |
100, # image_position
|
| 1363 |
"A building starting to explode, photorealistic, realisitc, 8k, insanely detailed",
|
| 1364 |
"image", # generation_mode
|
|
|
|
| 1453 |
examples = [
|
| 1454 |
[
|
| 1455 |
None, # input_image
|
| 1456 |
+
None, # end_image
|
| 1457 |
0, # image_position
|
| 1458 |
"Overcrowed street in Japan, photorealistic, realistic, intricate details, 8k, insanely detailed",
|
| 1459 |
"text", # generation_mode
|
|
|
|
| 1488 |
examples = [
|
| 1489 |
[
|
| 1490 |
"./img_examples/Example1.png", # input_image
|
| 1491 |
+
None, # end_image
|
| 1492 |
0, # image_position
|
| 1493 |
"A dolphin emerges from the water, photorealistic, realistic, intricate details, 8k, insanely detailed",
|
| 1494 |
"image", # generation_mode
|
|
|
|
| 1512 |
],
|
| 1513 |
[
|
| 1514 |
"./img_examples/Example2.webp", # input_image
|
| 1515 |
+
None, # end_image
|
| 1516 |
0, # image_position
|
| 1517 |
"A man on the left and a woman on the right face each other ready to start a conversation, large space between the persons, full view, full-length view, 3D, pixar, 3D render, CGI. The man talks and the woman listens; A man on the left and a woman on the right face each other ready to start a conversation, large space between the persons, full view, full-length view, 3D, pixar, 3D render, CGI. The woman talks, the man stops talking and the man listens; A man on the left and a woman on the right face each other ready to start a conversation, large space between the persons, full view, full-length view, 3D, pixar, 3D render, CGI. The woman talks and the man listens",
|
| 1518 |
"image", # generation_mode
|
|
|
|
| 1536 |
],
|
| 1537 |
[
|
| 1538 |
"./img_examples/Example2.webp", # input_image
|
| 1539 |
+
None, # end_image
|
| 1540 |
0, # image_position
|
| 1541 |
"A man on the left and a woman on the right face each other ready to start a conversation, large space between the persons, full view, full-length view, 3D, pixar, 3D render, CGI. The woman talks and the man listens; A man on the left and a woman on the right face each other ready to start a conversation, large space between the persons, full view, full-length view, 3D, pixar, 3D render, CGI. The man talks, the woman stops talking and the woman listens A man on the left and a woman on the right face each other ready to start a conversation, large space between the persons, full view, full-length view, 3D, pixar, 3D render, CGI. The man talks and the woman listens",
|
| 1542 |
"image", # generation_mode
|
|
|
|
| 1560 |
],
|
| 1561 |
[
|
| 1562 |
"./img_examples/Example3.jpg", # input_image
|
| 1563 |
+
None, # end_image
|
| 1564 |
0, # image_position
|
| 1565 |
"A boy is walking to the right, full view, full-length view, cartoon",
|
| 1566 |
"image", # generation_mode
|
|
|
|
| 1584 |
],
|
| 1585 |
[
|
| 1586 |
"./img_examples/Example4.webp", # input_image
|
| 1587 |
+
None, # end_image
|
| 1588 |
100, # image_position
|
| 1589 |
"A building starting to explode, photorealistic, realisitc, 8k, insanely detailed",
|
| 1590 |
"image", # generation_mode
|