r3gm commited on
Commit
3412b85
·
verified ·
1 Parent(s): 3dc741d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -8
app.py CHANGED
@@ -1,4 +1,4 @@
1
- import os
2
  import spaces
3
  import shutil
4
  import subprocess
@@ -293,8 +293,14 @@ torch._dynamo.reset()
293
  quantize_(pipe.transformer_2, Float8DynamicActivationFloat8WeightConfig())
294
  torch._dynamo.reset()
295
 
296
- aoti.aoti_blocks_load(pipe.transformer, 'zerogpu-aoti/Wan2', variant='fp8da')
297
- aoti.aoti_blocks_load(pipe.transformer_2, 'zerogpu-aoti/Wan2', variant='fp8da')
 
 
 
 
 
 
298
 
299
  # pipe.vae.enable_slicing()
300
  # pipe.vae.enable_tiling()
@@ -380,14 +386,14 @@ def get_inference_duration(
380
  progress
381
  ):
382
  BASE_FRAMES_HEIGHT_WIDTH = 81 * 832 * 624
383
- BASE_STEP_DURATION = 8.
384
  width, height = resized_image.size
385
  factor = num_frames * width * height / BASE_FRAMES_HEIGHT_WIDTH
386
  step_duration = BASE_STEP_DURATION * factor ** 1.5
387
  gen_time = int(steps) * step_duration
388
 
389
  if guidance_scale > 1:
390
- gen_time = gen_time * 1.9
391
 
392
  frame_factor = frame_multiplier // FIXED_FPS
393
  if frame_factor > 1:
@@ -397,7 +403,7 @@ def get_inference_duration(
397
 
398
  total_time = 15 + gen_time
399
  if safe_mode:
400
- total_time = total_time * 1.25
401
 
402
  return total_time
403
 
@@ -588,7 +594,7 @@ def generate_video(
588
  )
589
 
590
  if is_nsfw:
591
- raise gr.Error("Generation blocked by guardrails: The resulting video may contain explicit content.")
592
 
593
  print(f"GPU complete: {task_n}")
594
 
@@ -628,7 +634,7 @@ with gr.Blocks(theme=gr.themes.Soft(), css=CSS, delete_cache=(3600, 3700)) as de
628
  safe_mode_checkbox = gr.Checkbox(
629
  label="🛠️ Safe Mode",
630
  value=True,
631
- info="Safe Mode: Requests 25% extra processing time to try to prevent unfinished tasks when the server is busy."
632
  )
633
  with gr.Accordion("Advanced Settings", open=False):
634
  last_image_component = gr.Image(type="pil", label="Last Image (Optional)", sources=["upload", "clipboard"])
 
1
+ import os; os.system('pip install --upgrade --no-deps spaces')
2
  import spaces
3
  import shutil
4
  import subprocess
 
293
  quantize_(pipe.transformer_2, Float8DynamicActivationFloat8WeightConfig())
294
  torch._dynamo.reset()
295
 
296
+ spaces.aoti_load(
297
+ module=pipe.transformer,
298
+ repo_id='cbensimon/WanTransformer3DModel-sm120-cu130-raa',
299
+ )
300
+ spaces.aoti_load(
301
+ module=pipe.transformer_2,
302
+ repo_id='cbensimon/WanTransformer3DModel-sm120-cu130-raa',
303
+ )
304
 
305
  # pipe.vae.enable_slicing()
306
  # pipe.vae.enable_tiling()
 
386
  progress
387
  ):
388
  BASE_FRAMES_HEIGHT_WIDTH = 81 * 832 * 624
389
+ BASE_STEP_DURATION = 5.
390
  width, height = resized_image.size
391
  factor = num_frames * width * height / BASE_FRAMES_HEIGHT_WIDTH
392
  step_duration = BASE_STEP_DURATION * factor ** 1.5
393
  gen_time = int(steps) * step_duration
394
 
395
  if guidance_scale > 1:
396
+ gen_time = gen_time * 2.4
397
 
398
  frame_factor = frame_multiplier // FIXED_FPS
399
  if frame_factor > 1:
 
403
 
404
  total_time = 15 + gen_time
405
  if safe_mode:
406
+ total_time = total_time * 1.3
407
 
408
  return total_time
409
 
 
594
  )
595
 
596
  if is_nsfw:
597
+ raise gr.Error("Generation blocked by guardrails: The resulting video may contain sensitive or explicit content.")
598
 
599
  print(f"GPU complete: {task_n}")
600
 
 
634
  safe_mode_checkbox = gr.Checkbox(
635
  label="🛠️ Safe Mode",
636
  value=True,
637
+ info="Safe Mode: Requests 30% extra processing time to try to prevent unfinished tasks when the server is busy."
638
  )
639
  with gr.Accordion("Advanced Settings", open=False):
640
  last_image_component = gr.Image(type="pil", label="Last Image (Optional)", sources=["upload", "clipboard"])