DeepBeepMeep commited on
Commit
c001f3b
·
1 Parent(s): 941388c

Fixe Sage test

Browse files
README.md CHANGED
@@ -19,25 +19,25 @@ In this repository, we present **Wan2.1**, a comprehensive and open suite of vid
19
 
20
 
21
  ## 🔥 Latest News!!
22
- * Mar 19 2022: 👋 Wan2.1GP v3.2:
23
  - Added Classifier-Free Guidance Zero Star. The video should match better the text prompt (especially with text2video) at no performance cost: many thanks to the **CFG Zero * Team:**\
24
  Dont hesitate to give them a star if you appreciate the results: https://github.com/WeichenFan/CFG-Zero-star
25
  - Added back support for Pytorch compilation with Loras. It seems it had been broken for some time
26
  - Added possibility to keep a number of pregenerated videos in the Video Gallery (useful to compare outputs of different settings)
27
  You will need one more *pip install -r requirements.txt*
28
- * Mar 19 2022: 👋 Wan2.1GP v3.1: Faster launch and RAM optimizations (should require less RAM to run)\
29
  You will need one more *pip install -r requirements.txt*
30
- * Mar 18 2022: 👋 Wan2.1GP v3.0:
31
  - New Tab based interface, yon can switch from i2v to t2v conversely without restarting the app
32
  - Experimental Dual Frames mode for i2v, you can also specify an End frame. It doesn't always work, so you will need a few attempts.
33
  - You can save default settings in the files *i2v_settings.json* and *t2v_settings.json* that will be used when launching the app (you can also specify the path to different settings files)
34
  - Slight acceleration with loras\
35
  You will need one more *pip install -r requirements.txt*
36
  Many thanks to *Tophness* who created the framework (and did a big part of the work) of the multitabs and saved settings features
37
- * Mar 18 2022: 👋 Wan2.1GP v2.11: Added more command line parameters to prefill the generation settings + customizable output directory and choice of type of metadata for generated videos. Many thanks to *Tophness* for his contributions. You will need one more *pip install -r requirements.txt* to reflect new dependencies\
38
- * Mar 18 2022: 👋 Wan2.1GP v2.1: More Loras !: added support for 'Safetensors' and 'Replicate' Lora formats.\
39
  You will need to refresh the requirements with a *pip install -r requirements.txt*
40
- * Mar 17 2022: 👋 Wan2.1GP v2.0: The Lora festival continues:
41
  - Clearer user interface
42
  - Download 30 Loras in one click to try them all (expand the info section)
43
  - Very to use Loras as now Lora presets can input the subject (or other need terms) of the Lora so that you dont have to modify manually a prompt
 
19
 
20
 
21
  ## 🔥 Latest News!!
22
+ * Mar 19 2025: 👋 Wan2.1GP v3.2:
23
  - Added Classifier-Free Guidance Zero Star. The video should match better the text prompt (especially with text2video) at no performance cost: many thanks to the **CFG Zero * Team:**\
24
  Dont hesitate to give them a star if you appreciate the results: https://github.com/WeichenFan/CFG-Zero-star
25
  - Added back support for Pytorch compilation with Loras. It seems it had been broken for some time
26
  - Added possibility to keep a number of pregenerated videos in the Video Gallery (useful to compare outputs of different settings)
27
  You will need one more *pip install -r requirements.txt*
28
+ * Mar 19 2025: 👋 Wan2.1GP v3.1: Faster launch and RAM optimizations (should require less RAM to run)\
29
  You will need one more *pip install -r requirements.txt*
30
+ * Mar 18 2025: 👋 Wan2.1GP v3.0:
31
  - New Tab based interface, yon can switch from i2v to t2v conversely without restarting the app
32
  - Experimental Dual Frames mode for i2v, you can also specify an End frame. It doesn't always work, so you will need a few attempts.
33
  - You can save default settings in the files *i2v_settings.json* and *t2v_settings.json* that will be used when launching the app (you can also specify the path to different settings files)
34
  - Slight acceleration with loras\
35
  You will need one more *pip install -r requirements.txt*
36
  Many thanks to *Tophness* who created the framework (and did a big part of the work) of the multitabs and saved settings features
37
+ * Mar 18 2025: 👋 Wan2.1GP v2.11: Added more command line parameters to prefill the generation settings + customizable output directory and choice of type of metadata for generated videos. Many thanks to *Tophness* for his contributions. You will need one more *pip install -r requirements.txt* to reflect new dependencies\
38
+ * Mar 18 2025: 👋 Wan2.1GP v2.1: More Loras !: added support for 'Safetensors' and 'Replicate' Lora formats.\
39
  You will need to refresh the requirements with a *pip install -r requirements.txt*
40
+ * Mar 17 2025: 👋 Wan2.1GP v2.0: The Lora festival continues:
41
  - Clearer user interface
42
  - Download 30 Loras in one click to try them all (expand the info section)
43
  - Very to use Loras as now Lora presets can input the subject (or other need terms) of the Lora so that you dont have to modify manually a prompt
gradio_server.py CHANGED
@@ -847,14 +847,15 @@ def abort_generation(state):
847
 
848
  def refresh_gallery(state, txt):
849
  file_list = state.get("file_list", None)
 
 
 
 
 
850
  prompt = state.get("prompt", "")
851
  if len(prompt) == 0:
852
  return file_list, gr.Text(visible= False, value="")
853
  else:
854
- choice = 0
855
- if "in_progress" in state:
856
- choice = state.get("selected",0)
857
-
858
  prompts_max = state.get("prompts_max",0)
859
  prompt_no = state.get("prompt_no",0)
860
  if prompts_max >1 :
@@ -869,7 +870,9 @@ def finalize_gallery(state):
869
  if "in_progress" in state:
870
  del state["in_progress"]
871
  choice = state.get("selected",0)
872
- # file_list = state.get("file_list", [])
 
 
873
 
874
 
875
  state["extra_orders"] = 0
@@ -881,7 +884,10 @@ def finalize_gallery(state):
881
  def select_video(state , event_data: gr.EventData):
882
  data= event_data._data
883
  if data!=None:
884
- state["selected"] = data.get("index",0)
 
 
 
885
  return
886
 
887
  def expand_slist(slist, num_inference_steps ):
@@ -1199,6 +1205,7 @@ def generate_video(
1199
  state["selected"] = choice
1200
  state["file_list"] = file_list
1201
 
 
1202
  global save_path
1203
  os.makedirs(save_path, exist_ok=True)
1204
  video_no = 0
 
847
 
848
  def refresh_gallery(state, txt):
849
  file_list = state.get("file_list", None)
850
+ choice = state.get("selected",0)
851
+ if "in_progress" in state:
852
+ if state.get("last_selected", True):
853
+ choice = max(len(file_list) - 1,0)
854
+
855
  prompt = state.get("prompt", "")
856
  if len(prompt) == 0:
857
  return file_list, gr.Text(visible= False, value="")
858
  else:
 
 
 
 
859
  prompts_max = state.get("prompts_max",0)
860
  prompt_no = state.get("prompt_no",0)
861
  if prompts_max >1 :
 
870
  if "in_progress" in state:
871
  del state["in_progress"]
872
  choice = state.get("selected",0)
873
+ if state.get("last_selected", True):
874
+ file_list = state.get("file_list", [])
875
+ choice = len(file_list) - 1
876
 
877
 
878
  state["extra_orders"] = 0
 
884
  def select_video(state , event_data: gr.EventData):
885
  data= event_data._data
886
  if data!=None:
887
+ choice = data.get("index",0)
888
+ file_list = state.get("file_list", [])
889
+ state["last_selected"] = (choice + 1) >= len(file_list)
890
+ state["selected"] = choice
891
  return
892
 
893
  def expand_slist(slist, num_inference_steps ):
 
1205
  state["selected"] = choice
1206
  state["file_list"] = file_list
1207
 
1208
+
1209
  global save_path
1210
  os.makedirs(save_path, exist_ok=True)
1211
  video_no = 0
wan/image2video.py CHANGED
@@ -409,11 +409,10 @@ class WanI2V:
409
 
410
 
411
  if (i <= cfg_zero_step):
412
- noise_pred = noise_pred_text*0.
413
  else:
414
- noise_pred = noise_pred_uncond * alpha + guide_scale * (noise_pred_text - noise_pred_uncond * alpha)
415
- else:
416
- noise_pred = noise_pred_uncond + guide_scale * (noise_pred_text - noise_pred_uncond)
417
 
418
  del noise_pred_uncond
419
 
 
409
 
410
 
411
  if (i <= cfg_zero_step):
412
+ noise_pred *= 0. # it would be faster not to compute noise_pred...
413
  else:
414
+ noise_pred_uncond *= alpha
415
+ noise_pred = noise_pred_uncond + guide_scale * (noise_pred_text - noise_pred_uncond)
 
416
 
417
  del noise_pred_uncond
418
 
wan/modules/attention.py CHANGED
@@ -39,12 +39,12 @@ import warnings
39
 
40
  try:
41
  from sageattention import sageattn
42
- from .sage2_core import sageattn as alt_sageattn, is_sage_supported
43
- sage_supported = is_sage_supported()
44
  except ImportError:
45
  sageattn = None
46
  alt_sageattn = None
47
- sage_supported = False
48
  # @torch.compiler.disable()
49
  def sageattn_wrapper(
50
  qkv_list,
@@ -134,9 +134,7 @@ def get_attention_modes():
134
 
135
  def get_supported_attention_modes():
136
  ret = get_attention_modes()
137
- if not sage_supported:
138
- if "sage" in ret:
139
- ret.remove("sage")
140
  if "sage2" in ret:
141
  ret.remove("sage2")
142
  return ret
 
39
 
40
  try:
41
  from sageattention import sageattn
42
+ from .sage2_core import sageattn as alt_sageattn, is_sage2_supported
43
+ sage2_supported = is_sage2_supported()
44
  except ImportError:
45
  sageattn = None
46
  alt_sageattn = None
47
+ sage2_supported = False
48
  # @torch.compiler.disable()
49
  def sageattn_wrapper(
50
  qkv_list,
 
134
 
135
  def get_supported_attention_modes():
136
  ret = get_attention_modes()
137
+ if not sage2_supported:
 
 
138
  if "sage2" in ret:
139
  ret.remove("sage2")
140
  return ret
wan/modules/sage2_core.py CHANGED
@@ -53,7 +53,7 @@ from typing import Any, List, Literal, Optional, Tuple, Union
53
  import warnings
54
  import os
55
 
56
- def is_sage_supported():
57
  device_count = torch.cuda.device_count()
58
  for i in range(device_count):
59
  major, minor = torch.cuda.get_device_capability(i)
 
53
  import warnings
54
  import os
55
 
56
+ def is_sage2_supported():
57
  device_count = torch.cuda.device_count()
58
  for i in range(device_count):
59
  major, minor = torch.cuda.get_device_capability(i)
wan/text2video.py CHANGED
@@ -305,13 +305,11 @@ class WanT2V:
305
  alpha = optimized_scale(positive_flat,negative_flat)
306
  alpha = alpha.view(batch_size, 1, 1, 1)
307
 
308
-
309
  if (i <= cfg_zero_step):
310
- noise_pred = noise_pred_text*0.
311
  else:
312
- noise_pred = noise_pred_uncond * alpha + guide_scale * (noise_pred_text - noise_pred_uncond * alpha)
313
- else:
314
- noise_pred = noise_pred_uncond + guide_scale * (noise_pred_text - noise_pred_uncond)
315
  del noise_pred_uncond
316
 
317
  temp_x0 = sample_scheduler.step(
 
305
  alpha = optimized_scale(positive_flat,negative_flat)
306
  alpha = alpha.view(batch_size, 1, 1, 1)
307
 
 
308
  if (i <= cfg_zero_step):
309
+ noise_pred *= 0. # it would be faster not to compute noise_pred...
310
  else:
311
+ noise_pred_uncond *= alpha
312
+ noise_pred = noise_pred_uncond + guide_scale * (noise_pred_text - noise_pred_uncond)
 
313
  del noise_pred_uncond
314
 
315
  temp_x0 = sample_scheduler.step(