Fabrice-TIERCELIN commited on
Commit
a6e12fc
·
verified ·
1 Parent(s): 9382ddb

End stillness

Browse files
Files changed (1) hide show
  1. app.py +16 -7
app.py CHANGED
@@ -1338,11 +1338,11 @@ def process(input_image,
1338
  fps_number
1339
  )
1340
 
1341
- 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):
1342
  return allocation_time
1343
 
1344
  @spaces.GPU(duration=get_duration_video)
1345
- 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):
1346
  start = time.time()
1347
  global stream
1348
  stream = AsyncStream()
@@ -1378,7 +1378,7 @@ def process_video_on_gpu(input_video, end_frame, prompts, n_prompt, seed, batch,
1378
  " 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)
1379
  break
1380
 
1381
- 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):
1382
  global high_vram
1383
  if auto_allocation:
1384
  allocation_time = min(total_second_length * 60 * (2.5 if use_teacache else 3.5) * (1 + ((steps - 25) / 25))**2, 600)
@@ -1419,7 +1419,7 @@ def process_video(input_video, end_frame, prompt, n_prompt, randomize_seed, seed
1419
  if cfg > 1:
1420
  gs = 1
1421
 
1422
- 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)
1423
 
1424
  def end_process():
1425
  stream.input_queue.push('end')
@@ -1495,6 +1495,7 @@ with block:
1495
  image_position = gr.Slider(label="Image position", minimum=0, maximum=100, value=0, step=1, info='0=Video start; 100=Video end (lower quality)')
1496
  input_video = gr.Video(sources='upload', label="Input Video", height=320)
1497
  end_image = gr.Image(sources='upload', type="numpy", label="End Frame (optional; more a guidance than the exact end frame)", height=320)
 
1498
  timeless_prompt = gr.Textbox(label="Timeless prompt", info='Used on the whole duration of the generation', value='', placeholder="The creature starts to move, fast motion, fixed camera, focus motion, consistent arm, consistent position, mute colors, insanely detailed")
1499
  prompt_number = gr.Slider(label="Timed prompt number", minimum=0, maximum=1000, value=0, step=1, info='Prompts will automatically appear')
1500
 
@@ -1581,7 +1582,7 @@ with block:
1581
  progress_bar = gr.HTML('', elem_classes='no-generating-animation')
1582
 
1583
  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]
1584
- ips_video = [input_video, end_image, 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]
1585
 
1586
  with gr.Row(elem_id="text_examples", visible=False):
1587
  gr.Examples(
@@ -1794,6 +1795,7 @@ with block:
1794
  [
1795
  "./img_examples/Example1.mp4", # input_video
1796
  None, # end_image
 
1797
  "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",
1798
  "Missing arm, long hand, unrealistic position, impossible contortion, visible bone, muscle contraction, poorly framed, blurred, blurry, over-smooth", # n_prompt
1799
  True, # randomize_seed
@@ -1819,6 +1821,7 @@ with block:
1819
  [
1820
  "./img_examples/Example1.mp4", # input_video
1821
  None, # end_image
 
1822
  "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",
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
@@ -2056,6 +2059,7 @@ with block:
2056
  [
2057
  "./img_examples/Example1.mp4", # input_video
2058
  None, # end_image
 
2059
  "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",
2060
  "Missing arm, long hand, unrealistic position, impossible contortion, visible bone, muscle contraction, poorly framed, blurred, blurry, over-smooth", # n_prompt
2061
  True, # randomize_seed
@@ -2081,6 +2085,7 @@ with block:
2081
  [
2082
  "./img_examples/Example1.mp4", # input_video
2083
  "./img_examples/Example1.png", # end_image
 
2084
  "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",
2085
  "Missing arm, long hand, unrealistic position, impossible contortion, visible bone, muscle contraction, poorly framed, blurred, blurry, over-smooth", # n_prompt
2086
  True, # randomize_seed
@@ -2140,6 +2145,7 @@ with block:
2140
  gr.update(visible = False), # image_position
2141
  gr.update(visible = False), # input_image
2142
  gr.update(visible = False), # end_image
 
2143
  gr.update(visible = False), # input_video
2144
  gr.update(visible = True), # start_button
2145
  gr.update(visible = False), # start_button_video
@@ -2156,6 +2162,7 @@ with block:
2156
  gr.update(visible = True), # image_position
2157
  gr.update(visible = True), # input_image
2158
  gr.update(visible = False), # end_image
 
2159
  gr.update(visible = False), # input_video
2160
  gr.update(visible = True), # start_button
2161
  gr.update(visible = False), # start_button_video
@@ -2172,6 +2179,7 @@ with block:
2172
  gr.update(visible = False), # image_position
2173
  gr.update(visible = True), # input_image
2174
  gr.update(visible = True), # end_image
 
2175
  gr.update(visible = False), # input_video
2176
  gr.update(visible = True), # start_button
2177
  gr.update(visible = False), # start_button_video
@@ -2188,6 +2196,7 @@ with block:
2188
  gr.update(visible = False), # image_position
2189
  gr.update(visible = False), # input_image
2190
  gr.update(visible = True), # end_image
 
2191
  gr.update(visible = True), # input_video
2192
  gr.update(visible = False), # start_button
2193
  gr.update(visible = True), # start_button_video
@@ -2258,7 +2267,7 @@ with block:
2258
  generation_mode.change(
2259
  fn=handle_generation_mode_change,
2260
  inputs=[generation_mode],
2261
- outputs=[text_to_video_hint, image_position, input_image, end_image, input_video, start_button, start_button_video, no_resize, batch, num_clean_frames, vae_batch, prompt_hint, fps_number]
2262
  )
2263
 
2264
  # Update display when the page loads
@@ -2266,7 +2275,7 @@ with block:
2266
  fn=handle_generation_mode_change, inputs = [
2267
  generation_mode
2268
  ], outputs = [
2269
- text_to_video_hint, image_position, input_image, end_image, input_video, start_button, start_button_video, no_resize, batch, num_clean_frames, vae_batch, prompt_hint, fps_number
2270
  ]
2271
  )
2272
 
 
1338
  fps_number
1339
  )
1340
 
1341
+ def get_duration_video(input_video, end_frame, end_stillness, 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):
1342
  return allocation_time
1343
 
1344
  @spaces.GPU(duration=get_duration_video)
1345
+ def process_video_on_gpu(input_video, end_frame, end_stillness, 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):
1346
  start = time.time()
1347
  global stream
1348
  stream = AsyncStream()
 
1378
  " 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)
1379
  break
1380
 
1381
+ def process_video(input_video, end_frame, end_stillness, 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):
1382
  global high_vram
1383
  if auto_allocation:
1384
  allocation_time = min(total_second_length * 60 * (2.5 if use_teacache else 3.5) * (1 + ((steps - 25) / 25))**2, 600)
 
1419
  if cfg > 1:
1420
  gs = 1
1421
 
1422
+ yield from process_video_on_gpu(input_video, end_frame, end_stillness, 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)
1423
 
1424
  def end_process():
1425
  stream.input_queue.push('end')
 
1495
  image_position = gr.Slider(label="Image position", minimum=0, maximum=100, value=0, step=1, info='0=Video start; 100=Video end (lower quality)')
1496
  input_video = gr.Video(sources='upload', label="Input Video", height=320)
1497
  end_image = gr.Image(sources='upload', type="numpy", label="End Frame (optional; more a guidance than the exact end frame)", height=320)
1498
+ end_stillness = gr.Slider(label="End stillness", minimum=0, maximum=100, value=0, step=1, info='0=Realistic end; 100=Matches exactly the end image (but the time seems to freeze)')
1499
  timeless_prompt = gr.Textbox(label="Timeless prompt", info='Used on the whole duration of the generation', value='', placeholder="The creature starts to move, fast motion, fixed camera, focus motion, consistent arm, consistent position, mute colors, insanely detailed")
1500
  prompt_number = gr.Slider(label="Timed prompt number", minimum=0, maximum=1000, value=0, step=1, info='Prompts will automatically appear')
1501
 
 
1582
  progress_bar = gr.HTML('', elem_classes='no-generating-animation')
1583
 
1584
  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]
1585
+ ips_video = [input_video, end_image, end_stillness, 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]
1586
 
1587
  with gr.Row(elem_id="text_examples", visible=False):
1588
  gr.Examples(
 
1795
  [
1796
  "./img_examples/Example1.mp4", # input_video
1797
  None, # end_image
1798
+ 0, # end_stillness
1799
  "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",
1800
  "Missing arm, long hand, unrealistic position, impossible contortion, visible bone, muscle contraction, poorly framed, blurred, blurry, over-smooth", # n_prompt
1801
  True, # randomize_seed
 
1821
  [
1822
  "./img_examples/Example1.mp4", # input_video
1823
  None, # end_image
1824
+ 0, # end_stillness
1825
  "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",
1826
  "Missing arm, long hand, unrealistic position, impossible contortion, visible bone, muscle contraction, poorly framed, blurred, blurry, over-smooth", # n_prompt
1827
  True, # randomize_seed
 
2059
  [
2060
  "./img_examples/Example1.mp4", # input_video
2061
  None, # end_image
2062
+ 0, # end_stillness
2063
  "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",
2064
  "Missing arm, long hand, unrealistic position, impossible contortion, visible bone, muscle contraction, poorly framed, blurred, blurry, over-smooth", # n_prompt
2065
  True, # randomize_seed
 
2085
  [
2086
  "./img_examples/Example1.mp4", # input_video
2087
  "./img_examples/Example1.png", # end_image
2088
+ 0, # end_stillness
2089
  "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",
2090
  "Missing arm, long hand, unrealistic position, impossible contortion, visible bone, muscle contraction, poorly framed, blurred, blurry, over-smooth", # n_prompt
2091
  True, # randomize_seed
 
2145
  gr.update(visible = False), # image_position
2146
  gr.update(visible = False), # input_image
2147
  gr.update(visible = False), # end_image
2148
+ gr.update(visible = False), # end_stillness
2149
  gr.update(visible = False), # input_video
2150
  gr.update(visible = True), # start_button
2151
  gr.update(visible = False), # start_button_video
 
2162
  gr.update(visible = True), # image_position
2163
  gr.update(visible = True), # input_image
2164
  gr.update(visible = False), # end_image
2165
+ gr.update(visible = False), # end_stillness
2166
  gr.update(visible = False), # input_video
2167
  gr.update(visible = True), # start_button
2168
  gr.update(visible = False), # start_button_video
 
2179
  gr.update(visible = False), # image_position
2180
  gr.update(visible = True), # input_image
2181
  gr.update(visible = True), # end_image
2182
+ gr.update(visible = True), # end_stillness
2183
  gr.update(visible = False), # input_video
2184
  gr.update(visible = True), # start_button
2185
  gr.update(visible = False), # start_button_video
 
2196
  gr.update(visible = False), # image_position
2197
  gr.update(visible = False), # input_image
2198
  gr.update(visible = True), # end_image
2199
+ gr.update(visible = True), # end_stillness
2200
  gr.update(visible = True), # input_video
2201
  gr.update(visible = False), # start_button
2202
  gr.update(visible = True), # start_button_video
 
2267
  generation_mode.change(
2268
  fn=handle_generation_mode_change,
2269
  inputs=[generation_mode],
2270
+ outputs=[text_to_video_hint, image_position, input_image, end_image, end_stillness, input_video, start_button, start_button_video, no_resize, batch, num_clean_frames, vae_batch, prompt_hint, fps_number]
2271
  )
2272
 
2273
  # Update display when the page loads
 
2275
  fn=handle_generation_mode_change, inputs = [
2276
  generation_mode
2277
  ], outputs = [
2278
+ text_to_video_hint, image_position, input_image, end_image, end_stillness, input_video, start_button, start_button_video, no_resize, batch, num_clean_frames, vae_batch, prompt_hint, fps_number
2279
  ]
2280
  )
2281