Randomize seed
Browse files- app_v2v.py +11 -5
app_v2v.py
CHANGED
|
@@ -11,6 +11,7 @@ import einops
|
|
| 11 |
import safetensors.torch as sf
|
| 12 |
import numpy as np
|
| 13 |
import argparse
|
|
|
|
| 14 |
import math
|
| 15 |
# 20250506 pftq: Added for video input loading
|
| 16 |
import decord
|
|
@@ -560,7 +561,7 @@ def worker(input_video, prompt, n_prompt, seed, batch, resolution, total_second_
|
|
| 560 |
stream.output_queue.push(('end', None))
|
| 561 |
return
|
| 562 |
|
| 563 |
-
def get_duration(input_video, prompt, n_prompt, seed, batch, resolution, total_second_length, latent_window_size, steps, cfg, gs, rs, gpu_memory_preservation, use_teacache, no_resize, mp4_crf, num_clean_frames, vae_batch):
|
| 564 |
global total_second_length_debug_value
|
| 565 |
if total_second_length_debug_value is not None:
|
| 566 |
return min(total_second_length_debug_value * 60 * 2, 600)
|
|
@@ -568,7 +569,7 @@ def get_duration(input_video, prompt, n_prompt, seed, batch, resolution, total_s
|
|
| 568 |
|
| 569 |
# 20250506 pftq: Modified process to pass clean frame count, etc from video_encode
|
| 570 |
@spaces.GPU(duration=get_duration)
|
| 571 |
-
def process(input_video, prompt, n_prompt, seed, batch, resolution, total_second_length, latent_window_size, steps, cfg, gs, rs, gpu_memory_preservation, use_teacache, no_resize, mp4_crf, num_clean_frames, vae_batch):
|
| 572 |
global stream, high_vram, input_video_debug_value, prompt_debug_value, total_second_length_debug_value
|
| 573 |
|
| 574 |
if torch.cuda.device_count() == 0:
|
|
@@ -587,6 +588,9 @@ def process(input_video, prompt, n_prompt, seed, batch, resolution, total_second
|
|
| 587 |
total_second_length = total_second_length_debug_value
|
| 588 |
total_second_length_debug_value = None
|
| 589 |
|
|
|
|
|
|
|
|
|
|
| 590 |
# 20250506 pftq: Updated assertion for video input
|
| 591 |
assert input_video is not None, 'No input video!'
|
| 592 |
|
|
@@ -654,11 +658,12 @@ with block:
|
|
| 654 |
start_button = gr.Button(value="Start Generation")
|
| 655 |
end_button = gr.Button(value="End Generation", interactive=False)
|
| 656 |
|
| 657 |
-
with gr.
|
| 658 |
with gr.Row():
|
| 659 |
use_teacache = gr.Checkbox(label='Use TeaCache', value=False, info='Faster speed, but often makes hands and fingers slightly worse.')
|
| 660 |
no_resize = gr.Checkbox(label='Force Original Video Resolution (No Resizing)', value=False, info='Might run out of VRAM (720p requires > 24GB VRAM).')
|
| 661 |
|
|
|
|
| 662 |
seed = gr.Number(label="Seed", value=31337, precision=0)
|
| 663 |
|
| 664 |
batch = gr.Slider(label="Batch Size (Number of Videos)", minimum=1, maximum=1000, value=1, step=1, info='Generate multiple videos each with a different seed.')
|
|
@@ -710,6 +715,7 @@ with block:
|
|
| 710 |
"./img_examples/Example1.mp4", # input_video
|
| 711 |
"View of the sea as far as the eye can see, from the seaside, a piece of land is barely visible on the horizon at the middle, the sky is radiant, reflections of the sun in the water, photorealistic, realistic, intricate details, 8k, insanely detailed",
|
| 712 |
"", # n_prompt
|
|
|
|
| 713 |
42, # seed
|
| 714 |
1, # batch
|
| 715 |
640, # resolution
|
|
@@ -729,7 +735,7 @@ with block:
|
|
| 729 |
],
|
| 730 |
run_on_click = True,
|
| 731 |
fn = process,
|
| 732 |
-
inputs = [input_video, prompt, n_prompt, seed, batch, resolution, total_second_length, latent_window_size, steps, cfg, gs, rs, gpu_memory_preservation, use_teacache, no_resize, mp4_crf, num_clean_frames, vae_batch],
|
| 733 |
outputs = [result_video, preview_image, progress_desc, progress_bar, start_button, end_button],
|
| 734 |
cache_examples = True,
|
| 735 |
)
|
|
@@ -739,7 +745,7 @@ with block:
|
|
| 739 |
""")
|
| 740 |
|
| 741 |
# 20250506 pftq: Updated inputs to include num_clean_frames
|
| 742 |
-
ips = [input_video, prompt, n_prompt, seed, batch, resolution, total_second_length, latent_window_size, steps, cfg, gs, rs, gpu_memory_preservation, use_teacache, no_resize, mp4_crf, num_clean_frames, vae_batch]
|
| 743 |
start_button.click(fn=process, inputs=ips, outputs=[result_video, preview_image, progress_desc, progress_bar, start_button, end_button])
|
| 744 |
end_button.click(fn=end_process)
|
| 745 |
|
|
|
|
| 11 |
import safetensors.torch as sf
|
| 12 |
import numpy as np
|
| 13 |
import argparse
|
| 14 |
+
import random
|
| 15 |
import math
|
| 16 |
# 20250506 pftq: Added for video input loading
|
| 17 |
import decord
|
|
|
|
| 561 |
stream.output_queue.push(('end', None))
|
| 562 |
return
|
| 563 |
|
| 564 |
+
def get_duration(input_video, prompt, n_prompt, randomize_seed, seed, batch, resolution, total_second_length, latent_window_size, steps, cfg, gs, rs, gpu_memory_preservation, use_teacache, no_resize, mp4_crf, num_clean_frames, vae_batch):
|
| 565 |
global total_second_length_debug_value
|
| 566 |
if total_second_length_debug_value is not None:
|
| 567 |
return min(total_second_length_debug_value * 60 * 2, 600)
|
|
|
|
| 569 |
|
| 570 |
# 20250506 pftq: Modified process to pass clean frame count, etc from video_encode
|
| 571 |
@spaces.GPU(duration=get_duration)
|
| 572 |
+
def process(input_video, prompt, n_prompt, randomize_seed, seed, batch, resolution, total_second_length, latent_window_size, steps, cfg, gs, rs, gpu_memory_preservation, use_teacache, no_resize, mp4_crf, num_clean_frames, vae_batch):
|
| 573 |
global stream, high_vram, input_video_debug_value, prompt_debug_value, total_second_length_debug_value
|
| 574 |
|
| 575 |
if torch.cuda.device_count() == 0:
|
|
|
|
| 588 |
total_second_length = total_second_length_debug_value
|
| 589 |
total_second_length_debug_value = None
|
| 590 |
|
| 591 |
+
if randomize_seed:
|
| 592 |
+
seed = random.randint(0, np.iinfo(np.int32).max)
|
| 593 |
+
|
| 594 |
# 20250506 pftq: Updated assertion for video input
|
| 595 |
assert input_video is not None, 'No input video!'
|
| 596 |
|
|
|
|
| 658 |
start_button = gr.Button(value="Start Generation")
|
| 659 |
end_button = gr.Button(value="End Generation", interactive=False)
|
| 660 |
|
| 661 |
+
with gr.Accordion("Advanced settings", open=False):
|
| 662 |
with gr.Row():
|
| 663 |
use_teacache = gr.Checkbox(label='Use TeaCache', value=False, info='Faster speed, but often makes hands and fingers slightly worse.')
|
| 664 |
no_resize = gr.Checkbox(label='Force Original Video Resolution (No Resizing)', value=False, info='Might run out of VRAM (720p requires > 24GB VRAM).')
|
| 665 |
|
| 666 |
+
randomize_seed = gr.Checkbox(label='Randomize seed', value=True, info='If checked, the seed is always different')
|
| 667 |
seed = gr.Number(label="Seed", value=31337, precision=0)
|
| 668 |
|
| 669 |
batch = gr.Slider(label="Batch Size (Number of Videos)", minimum=1, maximum=1000, value=1, step=1, info='Generate multiple videos each with a different seed.')
|
|
|
|
| 715 |
"./img_examples/Example1.mp4", # input_video
|
| 716 |
"View of the sea as far as the eye can see, from the seaside, a piece of land is barely visible on the horizon at the middle, the sky is radiant, reflections of the sun in the water, photorealistic, realistic, intricate details, 8k, insanely detailed",
|
| 717 |
"", # n_prompt
|
| 718 |
+
True, # randomize_seed
|
| 719 |
42, # seed
|
| 720 |
1, # batch
|
| 721 |
640, # resolution
|
|
|
|
| 735 |
],
|
| 736 |
run_on_click = True,
|
| 737 |
fn = process,
|
| 738 |
+
inputs = [input_video, prompt, n_prompt, randomize_seed, seed, batch, resolution, total_second_length, latent_window_size, steps, cfg, gs, rs, gpu_memory_preservation, use_teacache, no_resize, mp4_crf, num_clean_frames, vae_batch],
|
| 739 |
outputs = [result_video, preview_image, progress_desc, progress_bar, start_button, end_button],
|
| 740 |
cache_examples = True,
|
| 741 |
)
|
|
|
|
| 745 |
""")
|
| 746 |
|
| 747 |
# 20250506 pftq: Updated inputs to include num_clean_frames
|
| 748 |
+
ips = [input_video, prompt, n_prompt, randomize_seed, seed, batch, resolution, total_second_length, latent_window_size, steps, cfg, gs, rs, gpu_memory_preservation, use_teacache, no_resize, mp4_crf, num_clean_frames, vae_batch]
|
| 749 |
start_button.click(fn=process, inputs=ips, outputs=[result_video, preview_image, progress_desc, progress_bar, start_button, end_button])
|
| 750 |
end_button.click(fn=end_process)
|
| 751 |
|