Spaces:
Runtime error
Runtime error
No generation mode
Browse files
app.py
CHANGED
|
@@ -1336,17 +1336,17 @@ def process(input_image,
|
|
| 1336 |
fps_number
|
| 1337 |
)
|
| 1338 |
|
| 1339 |
-
def get_duration_video(input_video, end_frame, prompts,
|
| 1340 |
return allocation_time
|
| 1341 |
|
| 1342 |
@spaces.GPU(duration=get_duration_video)
|
| 1343 |
-
def process_video_on_gpu(input_video, end_frame, prompts,
|
| 1344 |
start = time.time()
|
| 1345 |
global stream
|
| 1346 |
stream = AsyncStream()
|
| 1347 |
|
| 1348 |
# 20250506 pftq: Pass num_clean_frames, vae_batch, etc
|
| 1349 |
-
async_run(worker_video, input_video, end_frame
|
| 1350 |
|
| 1351 |
output_filename = None
|
| 1352 |
|
|
@@ -1376,7 +1376,7 @@ def process_video_on_gpu(input_video, end_frame, prompts, generation_mode, n_pro
|
|
| 1376 |
" You can upscale the result with https://huggingface.co/spaces/Nick088/Real-ESRGAN_Pytorch. To make all your generated scenes consistent, you can then apply a face swap on the main character. If you do not see the generated video above, the process may have failed. See the logs for more information. If you see an error like ''NVML_SUCCESS == r INTERNAL ASSERT FAILED'', you probably haven't enough VRAM. Test an example or other options to compare. You can share your inputs to the original space or set your space in public for a peer review.", '', gr.update(interactive=True), gr.update(interactive=False), gr.update(visible = False)
|
| 1377 |
break
|
| 1378 |
|
| 1379 |
-
def process_video(input_video, end_frame, prompt,
|
| 1380 |
global high_vram
|
| 1381 |
if auto_allocation:
|
| 1382 |
allocation_time = min(total_second_length * 60 * (2.5 if use_teacache else 3.5) * (1 + ((steps - 25) / 25))**2, 600)
|
|
@@ -1417,7 +1417,7 @@ def process_video(input_video, end_frame, prompt, generation_mode, n_prompt, ran
|
|
| 1417 |
if cfg > 1:
|
| 1418 |
gs = 1
|
| 1419 |
|
| 1420 |
-
yield from process_video_on_gpu(input_video, end_frame, prompt,
|
| 1421 |
|
| 1422 |
def end_process():
|
| 1423 |
stream.input_queue.push('end')
|
|
@@ -1487,7 +1487,7 @@ with block:
|
|
| 1487 |
local_storage = gr.BrowserState(default_local_storage)
|
| 1488 |
with gr.Row():
|
| 1489 |
with gr.Column():
|
| 1490 |
-
generation_mode = gr.Radio([["Text-to-Video", "text"], ["Image-to-Video", "image"], ["Start & end frames", "start_end"], ["Video Extension", "video"]
|
| 1491 |
text_to_video_hint = gr.HTML("Text-to-Video badly works with a flash effect at the start. I discourage to use the Text-to-Video feature. You should rather generate an image with Flux and use Image-to-Video. You will save time.")
|
| 1492 |
input_image = gr.Image(sources='upload', type="numpy", label="Image", height=320)
|
| 1493 |
image_position = gr.Slider(label="Image position", minimum=0, maximum=100, value=0, step=1, info='0=Video start; 100=Video end (lower quality)')
|
|
@@ -1793,7 +1793,6 @@ with block:
|
|
| 1793 |
"./img_examples/Example1.mp4", # input_video
|
| 1794 |
None, # end_image
|
| 1795 |
"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",
|
| 1796 |
-
"video", # generation_mode
|
| 1797 |
"Missing arm, long hand, unrealistic position, impossible contortion, visible bone, muscle contraction, poorly framed, blurred, blurry, over-smooth", # n_prompt
|
| 1798 |
True, # randomize_seed
|
| 1799 |
42, # seed
|
|
@@ -1819,7 +1818,6 @@ with block:
|
|
| 1819 |
"./img_examples/Example1.mp4", # input_video
|
| 1820 |
None, # end_image
|
| 1821 |
"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",
|
| 1822 |
-
"video", # generation_mode
|
| 1823 |
"Missing arm, long hand, unrealistic position, impossible contortion, visible bone, muscle contraction, poorly framed, blurred, blurry, over-smooth", # n_prompt
|
| 1824 |
True, # randomize_seed
|
| 1825 |
42, # seed
|
|
@@ -1857,7 +1855,6 @@ with block:
|
|
| 1857 |
"./img_examples/Example1.mp4", # input_video
|
| 1858 |
"./img_examples/Example1.png", # end_image
|
| 1859 |
"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",
|
| 1860 |
-
"video_end", # generation_mode
|
| 1861 |
"Missing arm, long hand, unrealistic position, impossible contortion, visible bone, muscle contraction, poorly framed, blurred, blurry, over-smooth", # n_prompt
|
| 1862 |
True, # randomize_seed
|
| 1863 |
42, # seed
|
|
@@ -1883,7 +1880,6 @@ with block:
|
|
| 1883 |
"./img_examples/Example1.mp4", # input_video
|
| 1884 |
"./img_examples/Example1.png", # end_image
|
| 1885 |
"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",
|
| 1886 |
-
"video_end", # generation_mode
|
| 1887 |
"Missing arm, long hand, unrealistic position, impossible contortion, visible bone, muscle contraction, poorly framed, blurred, blurry, over-smooth", # n_prompt
|
| 1888 |
True, # randomize_seed
|
| 1889 |
42, # seed
|
|
@@ -2121,7 +2117,6 @@ with block:
|
|
| 2121 |
"./img_examples/Example1.mp4", # input_video
|
| 2122 |
None, # end_image
|
| 2123 |
"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",
|
| 2124 |
-
"video_end", # generation_mode
|
| 2125 |
"Missing arm, long hand, unrealistic position, impossible contortion, visible bone, muscle contraction, poorly framed, blurred, blurry, over-smooth", # n_prompt
|
| 2126 |
True, # randomize_seed
|
| 2127 |
42, # seed
|
|
@@ -2158,7 +2153,6 @@ with block:
|
|
| 2158 |
"./img_examples/Example1.mp4", # input_video
|
| 2159 |
"./img_examples/Example1.png", # end_image
|
| 2160 |
"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",
|
| 2161 |
-
"video_end", # generation_mode
|
| 2162 |
"Missing arm, long hand, unrealistic position, impossible contortion, visible bone, muscle contraction, poorly framed, blurred, blurry, over-smooth", # n_prompt
|
| 2163 |
True, # randomize_seed
|
| 2164 |
42, # seed
|
|
@@ -2260,22 +2254,6 @@ with block:
|
|
| 2260 |
gr.update(visible = True) # fps_number
|
| 2261 |
]
|
| 2262 |
elif generation_mode_data == "video":
|
| 2263 |
-
return [
|
| 2264 |
-
gr.update(visible = False), # text_to_video_hint
|
| 2265 |
-
gr.update(visible = False), # image_position
|
| 2266 |
-
gr.update(visible = False), # input_image
|
| 2267 |
-
gr.update(visible = False), # end_image
|
| 2268 |
-
gr.update(visible = True), # input_video
|
| 2269 |
-
gr.update(visible = False), # start_button
|
| 2270 |
-
gr.update(visible = True), # start_button_video
|
| 2271 |
-
gr.update(visible = True), # no_resize
|
| 2272 |
-
gr.update(visible = True), # batch
|
| 2273 |
-
gr.update(visible = True), # num_clean_frames
|
| 2274 |
-
gr.update(visible = True), # vae_batch
|
| 2275 |
-
gr.update(visible = True), # prompt_hint
|
| 2276 |
-
gr.update(visible = False) # fps_number
|
| 2277 |
-
]
|
| 2278 |
-
elif generation_mode_data == "video_end":
|
| 2279 |
return [
|
| 2280 |
gr.update(visible = False), # text_to_video_hint
|
| 2281 |
gr.update(visible = False), # image_position
|
|
|
|
| 1336 |
fps_number
|
| 1337 |
)
|
| 1338 |
|
| 1339 |
+
def get_duration_video(input_video, end_frame, 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):
|
| 1340 |
return allocation_time
|
| 1341 |
|
| 1342 |
@spaces.GPU(duration=get_duration_video)
|
| 1343 |
+
def process_video_on_gpu(input_video, end_frame, 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):
|
| 1344 |
start = time.time()
|
| 1345 |
global stream
|
| 1346 |
stream = AsyncStream()
|
| 1347 |
|
| 1348 |
# 20250506 pftq: Pass num_clean_frames, vae_batch, etc
|
| 1349 |
+
async_run(worker_video, input_video, end_frame, prompts, n_prompt, seed, 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)
|
| 1350 |
|
| 1351 |
output_filename = None
|
| 1352 |
|
|
|
|
| 1376 |
" You can upscale the result with https://huggingface.co/spaces/Nick088/Real-ESRGAN_Pytorch. To make all your generated scenes consistent, you can then apply a face swap on the main character. If you do not see the generated video above, the process may have failed. See the logs for more information. If you see an error like ''NVML_SUCCESS == r INTERNAL ASSERT FAILED'', you probably haven't enough VRAM. Test an example or other options to compare. You can share your inputs to the original space or set your space in public for a peer review.", '', gr.update(interactive=True), gr.update(interactive=False), gr.update(visible = False)
|
| 1377 |
break
|
| 1378 |
|
| 1379 |
+
def process_video(input_video, end_frame, 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):
|
| 1380 |
global high_vram
|
| 1381 |
if auto_allocation:
|
| 1382 |
allocation_time = min(total_second_length * 60 * (2.5 if use_teacache else 3.5) * (1 + ((steps - 25) / 25))**2, 600)
|
|
|
|
| 1417 |
if cfg > 1:
|
| 1418 |
gs = 1
|
| 1419 |
|
| 1420 |
+
yield from process_video_on_gpu(input_video, end_frame, prompt, 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)
|
| 1421 |
|
| 1422 |
def end_process():
|
| 1423 |
stream.input_queue.push('end')
|
|
|
|
| 1487 |
local_storage = gr.BrowserState(default_local_storage)
|
| 1488 |
with gr.Row():
|
| 1489 |
with gr.Column():
|
| 1490 |
+
generation_mode = gr.Radio([["Text-to-Video", "text"], ["Image-to-Video", "image"], ["Start & end frames", "start_end"], ["Video Extension", "video"]], elem_id="generation-mode", label="Input mode", value = "image")
|
| 1491 |
text_to_video_hint = gr.HTML("Text-to-Video badly works with a flash effect at the start. I discourage to use the Text-to-Video feature. You should rather generate an image with Flux and use Image-to-Video. You will save time.")
|
| 1492 |
input_image = gr.Image(sources='upload', type="numpy", label="Image", height=320)
|
| 1493 |
image_position = gr.Slider(label="Image position", minimum=0, maximum=100, value=0, step=1, info='0=Video start; 100=Video end (lower quality)')
|
|
|
|
| 1793 |
"./img_examples/Example1.mp4", # input_video
|
| 1794 |
None, # end_image
|
| 1795 |
"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",
|
|
|
|
| 1796 |
"Missing arm, long hand, unrealistic position, impossible contortion, visible bone, muscle contraction, poorly framed, blurred, blurry, over-smooth", # n_prompt
|
| 1797 |
True, # randomize_seed
|
| 1798 |
42, # seed
|
|
|
|
| 1818 |
"./img_examples/Example1.mp4", # input_video
|
| 1819 |
None, # end_image
|
| 1820 |
"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",
|
|
|
|
| 1821 |
"Missing arm, long hand, unrealistic position, impossible contortion, visible bone, muscle contraction, poorly framed, blurred, blurry, over-smooth", # n_prompt
|
| 1822 |
True, # randomize_seed
|
| 1823 |
42, # seed
|
|
|
|
| 1855 |
"./img_examples/Example1.mp4", # input_video
|
| 1856 |
"./img_examples/Example1.png", # end_image
|
| 1857 |
"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",
|
|
|
|
| 1858 |
"Missing arm, long hand, unrealistic position, impossible contortion, visible bone, muscle contraction, poorly framed, blurred, blurry, over-smooth", # n_prompt
|
| 1859 |
True, # randomize_seed
|
| 1860 |
42, # seed
|
|
|
|
| 1880 |
"./img_examples/Example1.mp4", # input_video
|
| 1881 |
"./img_examples/Example1.png", # end_image
|
| 1882 |
"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",
|
|
|
|
| 1883 |
"Missing arm, long hand, unrealistic position, impossible contortion, visible bone, muscle contraction, poorly framed, blurred, blurry, over-smooth", # n_prompt
|
| 1884 |
True, # randomize_seed
|
| 1885 |
42, # seed
|
|
|
|
| 2117 |
"./img_examples/Example1.mp4", # input_video
|
| 2118 |
None, # end_image
|
| 2119 |
"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",
|
|
|
|
| 2120 |
"Missing arm, long hand, unrealistic position, impossible contortion, visible bone, muscle contraction, poorly framed, blurred, blurry, over-smooth", # n_prompt
|
| 2121 |
True, # randomize_seed
|
| 2122 |
42, # seed
|
|
|
|
| 2153 |
"./img_examples/Example1.mp4", # input_video
|
| 2154 |
"./img_examples/Example1.png", # end_image
|
| 2155 |
"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",
|
|
|
|
| 2156 |
"Missing arm, long hand, unrealistic position, impossible contortion, visible bone, muscle contraction, poorly framed, blurred, blurry, over-smooth", # n_prompt
|
| 2157 |
True, # randomize_seed
|
| 2158 |
42, # seed
|
|
|
|
| 2254 |
gr.update(visible = True) # fps_number
|
| 2255 |
]
|
| 2256 |
elif generation_mode_data == "video":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2257 |
return [
|
| 2258 |
gr.update(visible = False), # text_to_video_hint
|
| 2259 |
gr.update(visible = False), # image_position
|