Skip to content
Python

Fixe Sage test

DeepBeepMeep1c691919547a
diff --git a/README.md b/README.md
index e4480c2..3fabadc 100644
--- a/README.md
+++ b/README.md
@@ -19,25 +19,25 @@ In this repository, we present **Wan2.1**, a comprehensive and open suite of vid
## πŸ”₯ Latest News!!
-* Mar 19 2022: πŸ‘‹ Wan2.1GP v3.2:
+* Mar 19 2025: πŸ‘‹ Wan2.1GP v3.2:
- 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:**\
Dont hesitate to give them a star if you appreciate the results: https://github.com/WeichenFan/CFG-Zero-star
- Added back support for Pytorch compilation with Loras. It seems it had been broken for some time
- Added possibility to keep a number of pregenerated videos in the Video Gallery (useful to compare outputs of different settings)
You will need one more *pip install -r requirements.txt*
-* Mar 19 2022: πŸ‘‹ Wan2.1GP v3.1: Faster launch and RAM optimizations (should require less RAM to run)\
+* Mar 19 2025: πŸ‘‹ Wan2.1GP v3.1: Faster launch and RAM optimizations (should require less RAM to run)\
You will need one more *pip install -r requirements.txt*
-* Mar 18 2022: πŸ‘‹ Wan2.1GP v3.0:
+* Mar 18 2025: πŸ‘‹ Wan2.1GP v3.0:
- New Tab based interface, yon can switch from i2v to t2v conversely without restarting the app
- 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.
- 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)
- Slight acceleration with loras\
You will need one more *pip install -r requirements.txt*
Many thanks to *Tophness* who created the framework (and did a big part of the work) of the multitabs and saved settings features
-* 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\
-* Mar 18 2022: πŸ‘‹ Wan2.1GP v2.1: More Loras !: added support for 'Safetensors' and 'Replicate' Lora formats.\
+* 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\
+* Mar 18 2025: πŸ‘‹ Wan2.1GP v2.1: More Loras !: added support for 'Safetensors' and 'Replicate' Lora formats.\
You will need to refresh the requirements with a *pip install -r requirements.txt*
-* Mar 17 2022: πŸ‘‹ Wan2.1GP v2.0: The Lora festival continues:
+* Mar 17 2025: πŸ‘‹ Wan2.1GP v2.0: The Lora festival continues:
- Clearer user interface
- Download 30 Loras in one click to try them all (expand the info section)
- 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
diff --git a/gradio_server.py b/gradio_server.py
index 78076a2..37a65a1 100644
--- a/gradio_server.py
+++ b/gradio_server.py
@@ -847,14 +847,15 @@ def abort_generation(state):
def refresh_gallery(state, txt):
file_list = state.get("file_list", None)
+ choice = state.get("selected",0)
+ if "in_progress" in state:
+ if state.get("last_selected", True):
+ choice = max(len(file_list) - 1,0)
+
prompt = state.get("prompt", "")
if len(prompt) == 0:
return file_list, gr.Text(visible= False, value="")
else:
- choice = 0
- if "in_progress" in state:
- choice = state.get("selected",0)
-
prompts_max = state.get("prompts_max",0)
prompt_no = state.get("prompt_no",0)
if prompts_max >1 :
@@ -869,7 +870,9 @@ def finalize_gallery(state):
if "in_progress" in state:
del state["in_progress"]
choice = state.get("selected",0)
- # file_list = state.get("file_list", [])
+ if state.get("last_selected", True):
+ file_list = state.get("file_list", [])
+ choice = len(file_list) - 1
state["extra_orders"] = 0
@@ -881,7 +884,10 @@ def finalize_gallery(state):
def select_video(state , event_data: gr.EventData):
data= event_data._data
if data!=None:
- state["selected"] = data.get("index",0)
+ choice = data.get("index",0)
+ file_list = state.get("file_list", [])
+ state["last_selected"] = (choice + 1) >= len(file_list)
+ state["selected"] = choice
return
def expand_slist(slist, num_inference_steps ):
@@ -1199,6 +1205,7 @@ def generate_video(
state["selected"] = choice
state["file_list"] = file_list
+
global save_path
os.makedirs(save_path, exist_ok=True)
video_no = 0
diff --git a/wan/image2video.py b/wan/image2video.py
index e236bd7..67c7b07 100644
--- a/wan/image2video.py
+++ b/wan/image2video.py
@@ -409,11 +409,10 @@ class WanI2V:
if (i <= cfg_zero_step):
- noise_pred = noise_pred_text*0.
+ noise_pred *= 0. # it would be faster not to compute noise_pred...
else:
- noise_pred = noise_pred_uncond * alpha + guide_scale * (noise_pred_text - noise_pred_uncond * alpha)
- else:
- noise_pred = noise_pred_uncond + guide_scale * (noise_pred_text - noise_pred_uncond)
+ noise_pred_uncond *= alpha
+ noise_pred = noise_pred_uncond + guide_scale * (noise_pred_text - noise_pred_uncond)
del noise_pred_uncond
diff --git a/wan/modules/attention.py b/wan/modules/attention.py
index e19e387..b6764bb 100644
--- a/wan/modules/attention.py
+++ b/wan/modules/attention.py
@@ -39,12 +39,12 @@ import warnings
try:
from sageattention import sageattn
- from .sage2_core import sageattn as alt_sageattn, is_sage_supported
- sage_supported = is_sage_supported()
+ from .sage2_core import sageattn as alt_sageattn, is_sage2_supported
+ sage2_supported = is_sage2_supported()
except ImportError:
sageattn = None
alt_sageattn = None
- sage_supported = False
+ sage2_supported = False
# @torch.compiler.disable()
def sageattn_wrapper(
qkv_list,
@@ -134,9 +134,7 @@ def get_attention_modes():
def get_supported_attention_modes():
ret = get_attention_modes()
- if not sage_supported:
- if "sage" in ret:
- ret.remove("sage")
+ if not sage2_supported:
if "sage2" in ret:
ret.remove("sage2")
return ret
diff --git a/wan/modules/sage2_core.py b/wan/modules/sage2_core.py
index f6d23ee..2b7da50 100644
--- a/wan/modules/sage2_core.py
+++ b/wan/modules/sage2_core.py
@@ -53,7 +53,7 @@ from typing import Any, List, Literal, Optional, Tuple, Union
import warnings
import os
-def is_sage_supported():
+def is_sage2_supported():
device_count = torch.cuda.device_count()
for i in range(device_count):
major, minor = torch.cuda.get_device_capability(i)
diff --git a/wan/text2video.py b/wan/text2video.py
index 379954f..b37b383 100644
--- a/wan/text2video.py
+++ b/wan/text2video.py
@@ -305,13 +305,11 @@ class WanT2V:
alpha = optimized_scale(positive_flat,negative_flat)
alpha = alpha.view(batch_size, 1, 1, 1)
-
if (i <= cfg_zero_step):
- noise_pred = noise_pred_text*0.
+ noise_pred *= 0. # it would be faster not to compute noise_pred...
else:
- noise_pred = noise_pred_uncond * alpha + guide_scale * (noise_pred_text - noise_pred_uncond * alpha)
- else:
- noise_pred = noise_pred_uncond + guide_scale * (noise_pred_text - noise_pred_uncond)
+ noise_pred_uncond *= alpha
+ noise_pred = noise_pred_uncond + guide_scale * (noise_pred_text - noise_pred_uncond)
del noise_pred_uncond
temp_x0 = sample_scheduler.step(