Skip to content
Python

convert all tabs to plugins

Chris Malone640e0e357f00
diff --git a/plugins/wan2gp-about/__init__.py b/plugins/wan2gp-about/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/plugins/wan2gp-about/plugin.py b/plugins/wan2gp-about/plugin.py
new file mode 100644
index 0000000..8f05b9b
--- /dev/null
+++ b/plugins/wan2gp-about/plugin.py
@@ -0,0 +1,40 @@
+import gradio as gr
+from shared.utils.plugins import WAN2GPPlugin
+
+class AboutPlugin(WAN2GPPlugin):
+ def __init__(self):
+ super().__init__()
+ self.name = "About Tab"
+ self.version = "1.0.0"
+
+ def setup_ui(self):
+ self.add_tab(
+ tab_id="about_tab",
+ label="About",
+ component_constructor=self.create_about_ui
+ )
+
+ def create_about_ui(self):
+ gr.Markdown("<H2>WanGP - AI Generative Models for the GPU Poor by <B>DeepBeepMeep</B> (<A HREF='https://github.com/deepbeepmeep/Wan2GP'>GitHub</A>)</H2>")
+ gr.Markdown("Many thanks to:")
+ gr.Markdown("- <B>Alibaba Wan Team</B> for the best open source video generators (https://github.com/Wan-Video/Wan2.1)")
+ gr.Markdown("- <B>Alibaba Vace, Multitalk and Fun Teams</B> for their incredible control net models (https://github.com/ali-vilab/VACE), (https://github.com/MeiGen-AI/MultiTalk) and (https://huggingface.co/alibaba-pai/Wan2.2-Fun-A14B-InP) ")
+ gr.Markdown("- <B>Tencent</B> for the impressive Hunyuan Video models (https://github.com/Tencent-Hunyuan/HunyuanVideo)")
+ gr.Markdown("- <B>Blackforest Labs</B> for the innovative Flux image generators (https://github.com/black-forest-labs/flux)")
+ gr.Markdown("- <B>Alibaba Qwen Team</B> for their state of the art Qwen Image generators (https://github.com/QwenLM/Qwen-Image)")
+ gr.Markdown("- <B>Lightricks</B> for their super fast LTX Video models (https://github.com/Lightricks/LTX-Video)")
+ gr.Markdown("- <B>Hugging Face</B> for providing hosting for the models and developing must have open source libraries such as Tranformers, Diffusers, Accelerate and Gradio (https://huggingface.co/)")
+ gr.Markdown("<BR>Huge acknowledgments to these great open source projects used in WanGP:")
+ gr.Markdown("- <B>Rife</B>: temporal upsampler (https://github.com/hzwer/ECCV2022-RIFE)")
+ gr.Markdown("- <B>DwPose</B>: Open Pose extractor (https://github.com/IDEA-Research/DWPose)")
+ gr.Markdown("- <B>DepthAnything</B> & <B>Midas</B>: Depth extractors (https://github.com/DepthAnything/Depth-Anything-V2) and (https://github.com/isl-org/MiDaS")
+ gr.Markdown("- <B>Matanyone</B> and <B>SAM2</B>: Mask Generation (https://github.com/pq-yang/MatAnyone) and (https://github.com/facebookresearch/sam2)")
+ gr.Markdown("- <B>Pyannote</B>: speaker diarization (https://github.com/pyannote/pyannote-audio)")
+
+ gr.Markdown("<BR>Special thanks to the following people for their support:")
+ gr.Markdown("- <B>Cocktail Peanuts</B> : QA dpand simple installation via Pinokio.computer")
+ gr.Markdown("- <B>Tophness</B> : created (former) multi tabs and queuing frameworks")
+ gr.Markdown("- <B>AmericanPresidentJimmyCarter</B> : added original support for Skip Layer Guidance")
+ gr.Markdown("- <B>Remade_AI</B> : for their awesome Loras collection")
+ gr.Markdown("- <B>Reevoy24</B> : for his repackaging / completing the documentation")
+ gr.Markdown("- <B>Redtash1</B> : for designing the protype of the RAM / VRAM stats viewer")
\ No newline at end of file
diff --git a/plugins/wan2gp-configuration/__init__.py b/plugins/wan2gp-configuration/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/plugins/wan2gp-configuration/plugin.py b/plugins/wan2gp-configuration/plugin.py
new file mode 100644
index 0000000..6172134
--- /dev/null
+++ b/plugins/wan2gp-configuration/plugin.py
@@ -0,0 +1,249 @@
+import gradio as gr
+from shared.utils.plugins import WAN2GPPlugin
+import json
+
+class ConfigTabPlugin(WAN2GPPlugin):
+ """
+ This plugin moves the original Configuration tab from the main UI into a modular plugin.
+ It reads the application's state and configuration, allows the user to modify them,
+ and provides options to save the new settings or save and restart the application.
+ """
+ def __init__(self):
+ super().__init__()
+ self.name = "Configuration Tab"
+ self.version = "1.0.0"
+
+ def setup_ui(self):
+ """
+ Declares all the necessary components and global variables this plugin
+ needs to access from the main wgp.py application.
+ """
+ # Request global variables and functions from wgp.py
+ self.request_global("args")
+ self.request_global("server_config")
+ self.request_global("server_config_filename")
+ self.request_global("attention_mode")
+ self.request_global("compile")
+ self.request_global("default_profile")
+ self.request_global("vae_config")
+ self.request_global("boost")
+ self.request_global("preload_model_policy")
+ self.request_global("transformer_quantization")
+ self.request_global("transformer_dtype_policy")
+ self.request_global("transformer_types")
+ self.request_global("text_encoder_quantization")
+ self.request_global("attention_modes_installed")
+ self.request_global("attention_modes_supported")
+ self.request_global("displayed_model_types")
+ self.request_global("memory_profile_choices")
+ self.request_global("save_path")
+ self.request_global("image_save_path")
+ self.request_global("quit_application")
+ self.request_global("release_model")
+ self.request_global("get_sorted_dropdown")
+
+ # Request components from the main UI that this plugin needs to interact with
+ self.request_component("state")
+ self.request_component("resolution")
+
+ # Register the new "Configuration" tab
+ self.add_tab(
+ tab_id="configuration",
+ label="Configuration",
+ component_constructor=self.create_config_ui
+ )
+
+ def create_config_ui(self):
+ """
+ Creates the Gradio UI for the Configuration tab.
+ The layout is based on the original `generate_configuration_tab` function.
+ """
+ gr.Markdown("Please click 'Save' or 'Save and Restart' for changes to take effect. Some choices may be locked if set via command-line arguments.")
+ with gr.Column():
+ with gr.Tabs():
+ with gr.Tab("General"):
+ _ , dropdown_choices = self.get_sorted_dropdown(self.displayed_model_types, None)
+
+ self.transformer_types_choices = gr.Dropdown(
+ choices=dropdown_choices, value=self.transformer_types,
+ label="Selectable Generative Models (leave empty for all)", multiselect=True
+ )
+ self.fit_canvas_choice = gr.Dropdown(
+ choices=[
+ ("Dimensions are Pixel Budget (preserves aspect ratio, may exceed dimensions)", 0),
+ ("Dimensions are Max Width/Height (preserves aspect ratio, fits within box)", 1),
+ ("Dimensions are Exact Output (crops input to fit exact dimensions)", 2),
+ ],
+ value=self.server_config.get("fit_canvas", 0),
+ label="Input Image/Video Sizing Behavior",
+ interactive=not self.args.lock_config
+ )
+
+ def check_attn(mode):
+ if mode not in self.attention_modes_installed: return " (NOT INSTALLED)"
+ if mode not in self.attention_modes_supported: return " (NOT SUPPORTED)"
+ return ""
+
+ self.attention_choice = gr.Dropdown(
+ choices=[
+ ("Auto: Best available (sage2 > sage > sdpa)", "auto"),
+ ("sdpa: Default, always available", "sdpa"),
+ (f'flash{check_attn("flash")}: High quality, requires manual install', "flash"),
+ (f'xformers{check_attn("xformers")}: Good quality, less VRAM, requires manual install', "xformers"),
+ (f'sage{check_attn("sage")}: ~30% faster, requires manual install', "sage"),
+ (f'sage2{check_attn("sage2")}: ~40% faster, requires manual install', "sage2"),
+ ],
+ value=self.attention_mode, label="Attention Type", interactive=not self.args.lock_config
+ )
+ self.metadata_choice = gr.Dropdown(
+ choices=[("Export JSON files", "json"), ("Embed metadata in file (Exif/tag)", "metadata"), ("None", "none")],
+ value=self.server_config.get("metadata_type", "metadata"), label="Metadata Handling"
+ )
+ self.preload_model_policy_choice = gr.CheckboxGroup(
+ [("Preload Model on App Launch","P"), ("Preload Model on Switch", "S"), ("Unload Model when Queue is Done", "U")],
+ value=self.preload_model_policy, label="Model Loading/Unloading Policy"
+ )
+ self.clear_file_list_choice = gr.Dropdown(
+ choices=[("None", 0), ("Keep last video", 1), ("Keep last 5 videos", 5), ("Keep last 10", 10), ("Keep last 20", 20)],
+ value=self.server_config.get("clear_file_list", 5), label="Keep Previous Generations in Gallery"
+ )
+ self.display_stats_choice = gr.Dropdown(
+ choices=[("Disabled", 0), ("Enabled", 1)],
+ value=self.server_config.get("display_stats", 0), label="Display real-time RAM/VRAM stats (requires restart)"
+ )
+ self.max_frames_multiplier_choice = gr.Dropdown(
+ choices=[("Default", 1), ("x2", 2), ("x3", 3), ("x4", 4), ("x5", 5)],
+ value=self.server_config.get("max_frames_multiplier", 1), label="Max Frames Multiplier (requires restart)"
+ )
+ self.UI_theme_choice = gr.Dropdown(
+ choices=[("Blue Sky (Default)", "default"), ("Classic Gradio", "gradio")],
+ value=self.server_config.get("UI_theme", "default"), label="UI Theme (requires restart)"
+ )
+
+ with gr.Tab("Performance"):
+ self.quantization_choice = gr.Dropdown(choices=[("Scaled Int8 (recommended)", "int8"), ("16-bit (no quantization)", "bf16")], value=self.transformer_quantization, label="Transformer Model Quantization (if available)")
+ self.transformer_dtype_policy_choice = gr.Dropdown(choices=[("Auto (Best for Hardware)", ""), ("FP16", "fp16"), ("BF16", "bf16")], value=self.transformer_dtype_policy, label="Transformer Data Type (if available)")
+ self.mixed_precision_choice = gr.Dropdown(choices=[("16-bit only (less VRAM)", "0"), ("Mixed 16/32-bit (better quality)", "1")], value=self.server_config.get("mixed_precision", "0"), label="Transformer Engine Precision")
+ self.text_encoder_quantization_choice = gr.Dropdown(choices=[("16-bit (more RAM, better quality)", "bf16"), ("8-bit (less RAM, slightly lower quality)", "int8")], value=self.text_encoder_quantization, label="Text Encoder Precision")
+ self.VAE_precision_choice = gr.Dropdown(choices=[("16-bit (faster, less VRAM)", "16"), ("32-bit (slower, better for sliding window)", "32")], value=self.server_config.get("vae_precision", "16"), label="VAE Encoding/Decoding Precision")
+ self.compile_choice = gr.Dropdown(choices=[("On (up to 20% faster, requires Triton)", "transformer"), ("Off", "")], value=self.compile, label="Compile Transformer Model", interactive=not self.args.lock_config)
+ self.depth_anything_v2_variant_choice = gr.Dropdown(choices=[("Large (more precise, slower)", "vitl"), ("Big (less precise, faster)", "vitb")], value=self.server_config.get("depth_anything_v2_variant", "vitl"), label="Depth Anything v2 VACE Preprocessor")
+ self.vae_config_choice = gr.Dropdown(choices=[("Auto", 0), ("Disabled (fastest, high VRAM)", 1), ("256x256 Tiles (for >=8GB VRAM)", 2), ("128x128 Tiles (for >=6GB VRAM)", 3)], value=self.vae_config, label="VAE Tiling (to reduce VRAM usage)")
+ self.boost_choice = gr.Dropdown(choices=[("ON", 1), ("OFF", 2)], value=self.boost, label="Boost (~10% speedup for ~1GB VRAM)")
+ self.profile_choice = gr.Dropdown(choices=self.memory_profile_choices, value=self.default_profile, label="Memory Profile (Advanced)")
+ self.preload_in_VRAM_choice = gr.Slider(0, 40000, value=self.server_config.get("preload_in_VRAM", 0), step=100, label="VRAM (MB) for Preloaded Models (0=profile default)")
+ self.release_RAM_btn = gr.Button("Force Unload Models from RAM")
+
+ with gr.Tab("Extensions"):
+ self.enhancer_enabled_choice = gr.Dropdown(choices=[("Off", 0), ("Florence 2 + LLama 3.2", 1), ("Florence 2 + Llama Joy (uncensored)", 2)], value=self.server_config.get("enhancer_enabled", 0), label="Prompt Enhancer (requires 8-14GB extra download)")
+ self.enhancer_mode_choice = gr.Dropdown(choices=[("Automatic on Generation", 0), ("On-Demand Button Only", 1)], value=self.server_config.get("enhancer_mode", 0), label="Prompt Enhancer Usage")
+ self.mmaudio_enabled_choice = gr.Dropdown(choices=[("Off", 0), ("Enabled (unloads after use)", 1), ("Enabled (persistent in RAM)", 2)], value=self.server_config.get("mmaudio_enabled", 0), label="MMAudio Soundtrack Generation (requires 10GB extra download)")
+
+ with gr.Tab("Outputs"):
+ self.video_output_codec_choice = gr.Dropdown(choices=[("x265 CRF 28 (Balanced)", 'libx265_28'), ("x264 Level 8 (Balanced)", 'libx264_8'), ("x265 CRF 8 (High Quality)", 'libx265_8'), ("x264 Level 10 (High Quality)", 'libx264_10'), ("x264 Lossless", 'libx264_lossless')], value=self.server_config.get("video_output_codec", "libx264_8"), label="Video Codec")
+ self.image_output_codec_choice = gr.Dropdown(choices=[("JPEG Q85", 'jpeg_85'), ("WEBP Q85", 'webp_85'), ("JPEG Q95", 'jpeg_95'), ("WEBP Q95", 'webp_95'), ("WEBP Lossless", 'webp_lossless'), ("PNG Lossless", 'png')], value=self.server_config.get("image_output_codec", "jpeg_95"), label="Image Codec")
+ self.audio_output_codec_choice = gr.Dropdown(choices=[("AAC 128 kbit", 'aac_128')], value=self.server_config.get("audio_output_codec", "aac_128"), visible=False, label="Audio Codec to use")
+ self.video_save_path_choice = gr.Textbox(label="Video Output Folder (requires restart)", value=self.save_path)
+ self.image_save_path_choice = gr.Textbox(label="Image Output Folder (requires restart)", value=self.image_save_path)
+
+ with gr.Tab("Notifications"):
+ self.notification_sound_enabled_choice = gr.Dropdown(choices=[("On", 1), ("Off", 0)], value=self.server_config.get("notification_sound_enabled", 0), label="Notification Sound")
+ self.notification_sound_volume_choice = gr.Slider(0, 100, value=self.server_config.get("notification_sound_volume", 50), step=5, label="Notification Volume")
+
+ self.msg = gr.Markdown()
+ with gr.Row():
+ self.apply_btn = gr.Button("Save Settings")
+ self.apply_and_restart_btn = gr.Button("Save and Restart", variant="primary")
+ return [self.release_RAM_btn]
+
+ def _save_changes(self, state, *args):
+ """Saves the configuration to the JSON file."""
+ if self.args.lock_config:
+ return "<div style='color:red; text-align:center;'>Configuration is locked by command-line arguments.</div>"
+
+ # Unpack arguments
+ (transformer_types_choices, transformer_dtype_policy_choice, text_encoder_quantization_choice,
+ VAE_precision_choice, mixed_precision_choice, save_path_choice, image_save_path_choice,
+ attention_choice, compile_choice, profile_choice, vae_config_choice, metadata_choice,
+ quantization_choice, boost_choice, clear_file_list_choice, preload_model_policy_choice,
+ UI_theme_choice, enhancer_enabled_choice, enhancer_mode_choice, mmaudio_enabled_choice,
+ fit_canvas_choice, preload_in_VRAM_choice, depth_anything_v2_variant_choice,
+ notification_sound_enabled_choice, notification_sound_volume_choice, max_frames_multiplier_choice,
+ display_stats_choice, video_output_codec_choice, image_output_codec_choice, audio_output_codec_choice,
+ last_resolution_choice) = args
+
+ new_server_config = {
+ "attention_mode": attention_choice, "transformer_types": transformer_types_choices,
+ "text_encoder_quantization": text_encoder_quantization_choice, "save_path": save_path_choice,
+ "image_save_path": image_save_path_choice, "compile": compile_choice, "profile": profile_choice,
+ "vae_config": vae_config_choice, "vae_precision": VAE_precision_choice,
+ "mixed_precision": mixed_precision_choice, "metadata_type": metadata_choice,
+ "transformer_quantization": quantization_choice, "transformer_dtype_policy": transformer_dtype_policy_choice,
+ "boost": boost_choice, "clear_file_list": clear_file_list_choice,
+ "preload_model_policy": preload_model_policy_choice, "UI_theme": UI_theme_choice,
+ "fit_canvas": fit_canvas_choice, "enhancer_enabled": enhancer_enabled_choice,
+ "enhancer_mode": enhancer_mode_choice, "mmaudio_enabled": mmaudio_enabled_choice,
+ "preload_in_VRAM": preload_in_VRAM_choice, "depth_anything_v2_variant": depth_anything_v2_variant_choice,
+ "notification_sound_enabled": notification_sound_enabled_choice,
+ "notification_sound_volume": notification_sound_volume_choice,
+ "max_frames_multiplier": max_frames_multiplier_choice, "display_stats": display_stats_choice,
+ "video_output_codec": video_output_codec_choice, "image_output_codec": image_output_codec_choice,
+ "audio_output_codec": audio_output_codec_choice,
+ "last_model_type": state["model_type"], "last_model_per_family": state["last_model_per_family"],
+ "last_advanced_choice": state["advanced"], "last_resolution_choice": last_resolution_choice,
+ "last_resolution_per_group": state["last_resolution_per_group"],
+ }
+
+ # Retain original values for settings locked by CLI arguments
+ if self.args.lock_config:
+ if "attention_mode" in self.server_config: new_server_config["attention_mode"] = self.server_config["attention_mode"]
+ if "compile" in self.server_config: new_server_config["compile"] = self.server_config["compile"]
+
+ with open(self.server_config_filename, "w", encoding="utf-8") as writer:
+ writer.write(json.dumps(new_server_config, indent=4))
+
+ return "<div style='color:green; text-align:center;'>Settings saved. Please restart the application for all changes to take effect.</div>"
+
+ def _save_and_restart(self, *args):
+ """Saves the configuration and then triggers the application shutdown."""
+ self._save_changes(*args)
+ gr.Info("Settings saved. Restarting application...")
+ # This function is requested from wgp.py and will handle the shutdown sequence
+ self.quit_application()
+
+ def post_ui_setup(self, components: dict):
+ """Connects the UI components to their corresponding functions after the main UI is built."""
+ state = components['state']
+ resolution = components['resolution']
+
+ # Gather all input components for the save functions in the correct order
+ inputs = [
+ state, self.transformer_types_choices, self.transformer_dtype_policy_choice,
+ self.text_encoder_quantization_choice, self.VAE_precision_choice, self.mixed_precision_choice,
+ self.video_save_path_choice, self.image_save_path_choice, self.attention_choice, self.compile_choice,
+ self.profile_choice, self.vae_config_choice, self.metadata_choice, self.quantization_choice,
+ self.boost_choice, self.clear_file_list_choice, self.preload_model_policy_choice, self.UI_theme_choice,
+ self.enhancer_enabled_choice, self.enhancer_mode_choice, self.mmaudio_enabled_choice, self.fit_canvas_choice,
+ self.preload_in_VRAM_choice, self.depth_anything_v2_variant_choice, self.notification_sound_enabled_choice,
+ self.notification_sound_volume_choice, self.max_frames_multiplier_choice, self.display_stats_choice,
+ self.video_output_codec_choice, self.image_output_codec_choice, self.audio_output_codec_choice, resolution
+ ]
+
+ self.apply_btn.click(
+ fn=self._save_changes,
+ inputs=inputs,
+ outputs=[self.msg]
+ )
+
+ self.apply_and_restart_btn.click(
+ fn=self._save_and_restart,
+ inputs=inputs,
+ outputs=None
+ )
+
+ def release_ram_and_notify():
+ self.release_model()
+ gr.Info("Models unloaded from RAM.")
+
+ self.release_RAM_btn.click(fn=release_ram_and_notify)
+ return {}
\ No newline at end of file
diff --git a/plugins/wan2gp-downloads/__init__.py b/plugins/wan2gp-downloads/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/plugins/wan2gp-downloads/plugin.py b/plugins/wan2gp-downloads/plugin.py
new file mode 100644
index 0000000..34ae230
--- /dev/null
+++ b/plugins/wan2gp-downloads/plugin.py
@@ -0,0 +1,75 @@
+import gradio as gr
+from shared.utils.plugins import WAN2GPPlugin
+import os
+import shutil
+from pathlib import Path
+
+class DownloadsPlugin(WAN2GPPlugin):
+ def __init__(self):
+ super().__init__()
+ self.name = "Downloads Tab"
+ self.version = "1.0.0"
+
+ def setup_ui(self):
+ self.request_global("get_lora_dir")
+ self.request_global("refresh_lora_list")
+
+ self.request_component("state")
+ self.request_component("lset_name")
+ self.request_component("loras_choices")
+
+ self.add_tab(
+ tab_id="downloads",
+ label="Downloads",
+ component_constructor=self.create_downloads_ui
+ )
+
+ def create_downloads_ui(self):
+ with gr.Row():
+ with gr.Row(scale=2):
+ gr.Markdown("<I>WanGP's Lora Festival ! Press the following button to download i2v <B>Remade_AI</B> Loras collection (and bonuses Loras).")
+ with gr.Row(scale=1):
+ self.download_loras_btn = gr.Button("---> Let the Lora's Festival Start !", scale=1)
+ with gr.Row(scale=1):
+ gr.Markdown("")
+ with gr.Row() as self.download_status_row:
+ self.download_status = gr.Markdown()
+
+ def download_loras_action(self):
+ from huggingface_hub import snapshot_download
+ yield gr.Row(visible=True), "<B><FONT SIZE=3>Please wait while the Loras are being downloaded</B></FONT>"
+ lora_dir = self.get_lora_dir("i2v")
+ log_path = os.path.join(lora_dir, "log.txt")
+ if not os.path.isfile(log_path):
+ tmp_path = os.path.join(lora_dir, "tmp_lora_dowload")
+ import glob
+ snapshot_download(repo_id="DeepBeepMeep/Wan2.1", allow_patterns="loras_i2v/*", local_dir=tmp_path)
+ for f in glob.glob(os.path.join(tmp_path, "loras_i2v", "*.*")):
+ target_file = os.path.join(lora_dir, Path(f).parts[-1])
+ if os.path.isfile(target_file):
+ os.remove(f)
+ else:
+ shutil.move(f, lora_dir)
+ try:
+ os.remove(tmp_path)
+ except:
+ pass
+ yield gr.Row(visible=True), "<B><FONT SIZE=3>Loras have been completely downloaded</B></FONT>"
+
+ from datetime import datetime
+ import time
+ dt = datetime.today().strftime('%Y-%m-%d')
+ with open(log_path, "w", encoding="utf-8") as writer:
+ writer.write(f"Loras downloaded on the {dt} at {time.time()} on the {time.time()}")
+ return
+
+ def post_ui_setup(self, components: dict):
+ self.download_loras_btn.click(
+ fn=self.download_loras_action,
+ inputs=[],
+ outputs=[self.download_status_row, self.download_status]
+ ).then(
+ fn=self.refresh_lora_list,
+ inputs=[self.state, self.lset_name, self.loras_choices],
+ outputs=[self.lset_name, self.loras_choices]
+ )
\ No newline at end of file
diff --git a/plugins/wan2gp-guides/__init__.py b/plugins/wan2gp-guides/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/plugins/wan2gp-guides/plugin.py b/plugins/wan2gp-guides/plugin.py
new file mode 100644
index 0000000..52af407
--- /dev/null
+++ b/plugins/wan2gp-guides/plugin.py
@@ -0,0 +1,38 @@
+import gradio as gr
+from shared.utils.plugins import WAN2GPPlugin
+
+class GuidesPlugin(WAN2GPPlugin):
+ def __init__(self):
+ super().__init__()
+ self.name = "Guides Tab"
+ self.version = "1.0.0"
+
+ def setup_ui(self):
+ self.add_tab(
+ tab_id="info",
+ label="Guides",
+ component_constructor=self.create_guides_ui
+ )
+
+ def create_guides_ui(self):
+ with open("docs/VACE.md", "r", encoding="utf-8") as reader:
+ vace= reader.read()
+
+ with open("docs/MODELS.md", "r", encoding="utf-8") as reader:
+ models = reader.read()
+
+ with open("docs/LORAS.md", "r", encoding="utf-8") as reader:
+ loras = reader.read()
+
+ with open("docs/FINETUNES.md", "r", encoding="utf-8") as reader:
+ finetunes = reader.read()
+
+ with gr.Tabs() :
+ with gr.Tab("Models", id="models"):
+ gr.Markdown(models)
+ with gr.Tab("Loras", id="loras"):
+ gr.Markdown(loras)
+ with gr.Tab("Vace", id="vace"):
+ gr.Markdown(vace)
+ with gr.Tab("Finetunes", id="finetunes"):
+ gr.Markdown(finetunes)
\ No newline at end of file
diff --git a/plugins/wan2gp-video-mask-creator/__init__.py b/plugins/wan2gp-video-mask-creator/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/plugins/wan2gp-video-mask-creator/plugin.py b/plugins/wan2gp-video-mask-creator/plugin.py
new file mode 100644
index 0000000..0a27acd
--- /dev/null
+++ b/plugins/wan2gp-video-mask-creator/plugin.py
@@ -0,0 +1,49 @@
+import gradio as gr
+from shared.utils.plugins import WAN2GPPlugin
+import os
+import json
+import traceback
+
+class VideoMaskCreatorPlugin(WAN2GPPlugin):
+ def __init__(self):
+ super().__init__()
+ self.name = "Video Mask Creator"
+ self.version = "1.0.0"
+
+ def setup_ui(self):
+ self.request_global("vmc_event_handler")
+ self.request_global("gen_in_progress")
+ self.request_global("download_shared_done")
+ self.request_global("download_models")
+ self.request_global("server_config")
+ self.request_global("get_current_model_settings")
+ self.request_global("matanyone_app")
+ self.request_component("main_tabs")
+ self.request_component("tab_state")
+ self.request_component("state")
+ self.request_component("refresh_form_trigger")
+ self.request_component("save_form_trigger")
+
+ self.add_tab(
+ tab_id="video_mask_creator",
+ label="Video Mask Creator",
+ component_constructor=self.create_mask_creator_ui,
+ position=3
+ )
+
+ def create_mask_creator_ui(self):
+ pass
+
+ def post_ui_setup(self, components: dict):
+ with self.main_tabs:
+ with gr.Tab("Video Mask Creator", id="video_mask_creator"):
+ self.matanyone_app.display(
+ self.main_tabs,
+ self.tab_state,
+ self.state,
+ self.refresh_form_trigger,
+ self.server_config,
+ self.get_current_model_settings
+ )
+
+ return {}
\ No newline at end of file
diff --git a/shared/utils/plugins.py b/shared/utils/plugins.py
index 367ac2c..06b5b8e 100644
--- a/shared/utils/plugins.py
+++ b/shared/utils/plugins.py
@@ -296,6 +296,14 @@ class PluginManager:
return data
def run_post_ui_setup(self, all_components: Dict[str, gr.components.Component]) -> None:
+ if 'tab_state' not in all_components and 'main_tabs' in all_components:
+ main_tabs = all_components.get('main_tabs')
+ root_blocks = getattr(main_tabs, 'parent', None)
+ if root_blocks:
+ for component in getattr(root_blocks, 'children', []):
+ if isinstance(component, gr.State):
+ all_components['tab_state'] = component
+ break
all_insert_requests: List[InsertAfterRequest] = []
for plugin_id, plugin in self.plugins.items():
diff --git a/wgp.py b/wgp.py
index 1027a61..cf5b031 100644
--- a/wgp.py
+++ b/wgp.py
@@ -1827,7 +1827,7 @@ if not Path(server_config_filename).is_file():
"profile" : profile_type.LowRAM_LowVRAM,
"preload_model_policy": [],
"UI_theme": "default",
- "enabled_plugins": ["wan2gp-gallery", "wan2gp-lora-multipliers-ui", "wan2gp-plugin-manager"]
+ "enabled_plugins": ["wan2gp-gallery", "wan2gp-lora-multipliers-ui", "wan2gp-plugin-manager", "wan2gp-about", "wan2gp-downloads", "wan2gp-guides", "wan2gp-configuration", "wan2gp-video-mask-creator"]
}
with open(server_config_filename, "w", encoding="utf-8") as writer:
@@ -1837,7 +1837,7 @@ else:
text = reader.read()
server_config = json.loads(text)
if "enabled_plugins" not in server_config:
- server_config["enabled_plugins"] = ["wan2gp-gallery", "wan2gp-lora-multipliers-ui", "wan2gp-plugin-manager"]
+ server_config["enabled_plugins"] = ["wan2gp-gallery", "wan2gp-lora-multipliers-ui", "wan2gp-plugin-manager", "wan2gp-about", "wan2gp-downloads", "wan2gp-guides", "wan2gp-configuration", "wan2gp-video-mask-creator"]
# Deprecated models
for path in ["wan2.1_Vace_1.3B_preview_bf16.safetensors", "sky_reels2_diffusion_forcing_1.3B_bf16.safetensors","sky_reels2_diffusion_forcing_720p_14B_bf16.safetensors",
@@ -2986,131 +2986,6 @@ def release_RAM():
release_model()
gr.Info("Models stored in RAM have been released")
-def apply_changes( state,
- transformer_types_choices,
- transformer_dtype_policy_choice,
- text_encoder_quantization_choice,
- VAE_precision_choice,
- mixed_precision_choice,
- save_path_choice,
- image_save_path_choice,
- attention_choice,
- compile_choice,
- profile_choice,
- vae_config_choice,
- metadata_choice,
- quantization_choice,
- boost_choice = 1,
- clear_file_list = 0,
- preload_model_policy_choice = 1,
- UI_theme_choice = "default",
- enhancer_enabled_choice = 0,
- enhancer_mode_choice = 0,
- mmaudio_enabled_choice = 0,
- fit_canvas_choice = 0,
- preload_in_VRAM_choice = 0,
- depth_anything_v2_variant_choice = "vitl",
- notification_sound_enabled_choice = 0,
- notification_sound_volume_choice = 50,
- max_frames_multiplier_choice = 1,
- display_stats_choice = 0,
- video_output_codec_choice = None,
- image_output_codec_choice = None,
- audio_output_codec_choice = None,
- last_resolution_choice = None,
-):
- if args.lock_config:
- return "<DIV ALIGN=CENTER>Config Locked</DIV>",*[gr.update()]*4
- if gen_in_progress:
- return "<DIV ALIGN=CENTER>Unable to change config when a generation is in progress</DIV>",*[gr.update()]*4
- global offloadobj, wan_model, server_config, loras, default_loras_choices, default_loras_multis_str, default_lora_preset_prompt, default_lora_preset, loras_presets
- server_config = {
- "attention_mode" : attention_choice,
- "transformer_types": transformer_types_choices,
- "text_encoder_quantization" : text_encoder_quantization_choice,
- "save_path" : save_path_choice,
- "image_save_path" : image_save_path_choice,
- "compile" : compile_choice,
- "profile" : profile_choice,
- "vae_config" : vae_config_choice,
- "vae_precision" : VAE_precision_choice,
- "mixed_precision" : mixed_precision_choice,
- "metadata_type": metadata_choice,
- "transformer_quantization" : quantization_choice,
- "transformer_dtype_policy" : transformer_dtype_policy_choice,
- "boost" : boost_choice,
- "clear_file_list" : clear_file_list,
- "preload_model_policy" : preload_model_policy_choice,
- "UI_theme" : UI_theme_choice,
- "fit_canvas": fit_canvas_choice,
- "enhancer_enabled" : enhancer_enabled_choice,
- "enhancer_mode" : enhancer_mode_choice,
- "mmaudio_enabled" : mmaudio_enabled_choice,
- "preload_in_VRAM" : preload_in_VRAM_choice,
- "depth_anything_v2_variant": depth_anything_v2_variant_choice,
- "notification_sound_enabled" : notification_sound_enabled_choice,
- "notification_sound_volume" : notification_sound_volume_choice,
- "max_frames_multiplier" : max_frames_multiplier_choice,
- "display_stats" : display_stats_choice,
- "video_output_codec" : video_output_codec_choice,
- "image_output_codec" : image_output_codec_choice,
- "audio_output_codec" : audio_output_codec_choice,
- "last_model_type" : state["model_type"],
- "last_model_per_family": state["last_model_per_family"],
- "last_advanced_choice": state["advanced"],
- "last_resolution_choice": last_resolution_choice,
- "last_resolution_per_group": state["last_resolution_per_group"],
- }
-
- if Path(server_config_filename).is_file():
- with open(server_config_filename, "r", encoding="utf-8") as reader:
- text = reader.read()
- old_server_config = json.loads(text)
- if lock_ui_attention:
- server_config["attention_mode"] = old_server_config["attention_mode"]
- if lock_ui_compile:
- server_config["compile"] = old_server_config["compile"]
-
- with open(server_config_filename, "w", encoding="utf-8") as writer:
- writer.write(json.dumps(server_config, indent=4))
-
- changes = []
- for k, v in server_config.items():
- v_old = old_server_config.get(k, None)
- if v != v_old:
- changes.append(k)
-
- global attention_mode, default_profile, compile, vae_config, boost, lora_dir, reload_needed, preload_model_policy, transformer_quantization, transformer_dtype_policy, transformer_types, text_encoder_quantization, save_path
- attention_mode = server_config["attention_mode"]
- default_profile = server_config["profile"]
- compile = server_config["compile"]
- text_encoder_quantization = server_config["text_encoder_quantization"]
- vae_config = server_config["vae_config"]
- boost = server_config["boost"]
- save_path = server_config["save_path"]
- image_save_path = server_config["image_save_path"]
- preload_model_policy = server_config["preload_model_policy"]
- transformer_quantization = server_config["transformer_quantization"]
- transformer_dtype_policy = server_config["transformer_dtype_policy"]
- text_encoder_quantization = server_config["text_encoder_quantization"]
- transformer_types = server_config["transformer_types"]
- model_filename = get_model_filename(transformer_type, transformer_quantization, transformer_dtype_policy)
- state["model_filename"] = model_filename
- if "enhancer_enabled" in changes or "enhancer_mode" in changes:
- reset_prompt_enhancer()
- if all(change in ["attention_mode", "vae_config", "boost", "save_path", "metadata_type", "clear_file_list", "fit_canvas", "depth_anything_v2_variant",
- "notification_sound_enabled", "notification_sound_volume", "mmaudio_enabled", "max_frames_multiplier", "display_stats",
- "video_output_codec", "image_output_codec", "audio_output_codec"] for change in changes ):
- model_family = gr.Dropdown()
- model_choice = gr.Dropdown()
- else:
- reload_needed = True
- model_family, model_choice = generate_dropdown_model_list(transformer_type)
-
- header = generate_header(state["model_type"], compile=compile, attention_mode= attention_mode)
- mmaudio_enabled = server_config["mmaudio_enabled"] > 0
- return "<DIV ALIGN=CENTER>The new configuration has been succesfully applied</DIV>", header, model_family, model_choice, get_unique_id()
-
def get_gen_info(state):
cache = state.get("gen", None)
if cache == None:
@@ -6888,33 +6763,6 @@ def save_inputs(
elif target == "state":
set_model_settings(state, model_type, cleaned_inputs)
-def download_loras():
- from huggingface_hub import snapshot_download
- yield gr.Row(visible=True), "<B><FONT SIZE=3>Please wait while the Loras are being downloaded</B></FONT>" #, *[gr.Column(visible=False)] * 2
- lora_dir = get_lora_dir("i2v")
- log_path = os.path.join(lora_dir, "log.txt")
- if not os.path.isfile(log_path):
- tmp_path = os.path.join(lora_dir, "tmp_lora_dowload")
- import glob
- snapshot_download(repo_id="DeepBeepMeep/Wan2.1", allow_patterns="loras_i2v/*", local_dir= tmp_path)
- for f in glob.glob(os.path.join(tmp_path, "loras_i2v", "*.*")):
- target_file = os.path.join(lora_dir, Path(f).parts[-1] )
- if os.path.isfile(target_file):
- os.remove(f)
- else:
- shutil.move(f, lora_dir)
- try:
- os.remove(tmp_path)
- except:
- pass
- yield gr.Row(visible=True), "<B><FONT SIZE=3>Loras have been completely downloaded</B></FONT>" #, *[gr.Column(visible=True)] * 2
-
- from datetime import datetime
- dt = datetime.today().strftime('%Y-%m-%d')
- with open( log_path, "w", encoding="utf-8") as writer:
- writer.write(f"Loras downloaded on the {dt} at {time.time()} on the {time.time()}")
- return
-
def handle_celll_selection(state, evt: gr.SelectData):
gen = get_gen_info(state)
@@ -8898,421 +8746,6 @@ def generate_video_tab(update_form = False, state_dict = None, ui_defaults = Non
return ( state, loras_choices, lset_name, resolution, refresh_form_trigger, save_form_trigger, locals(),
# video_guide, image_guide, video_mask, image_mask, image_refs,
)
-
-
-def generate_download_tab(lset_name,loras_choices, state):
- with gr.Row():
- with gr.Row(scale =2):
- gr.Markdown("<I>WanGP's Lora Festival ! Press the following button to download i2v <B>Remade_AI</B> Loras collection (and bonuses Loras).")
- with gr.Row(scale =1):
- download_loras_btn = gr.Button("---> Let the Lora's Festival Start !", scale =1)
- with gr.Row(scale =1):
- gr.Markdown("")
- with gr.Row() as download_status_row:
- download_status = gr.Markdown()
-
- download_loras_btn.click(fn=download_loras, inputs=[], outputs=[download_status_row, download_status]).then(fn=refresh_lora_list, inputs=[state, lset_name,loras_choices], outputs=[lset_name, loras_choices])
-
-
-def generate_configuration_tab(state, blocks, header, model_family, model_choice, resolution, refresh_form_trigger):
- gr.Markdown("Please click Apply Changes at the bottom so that the changes are effective. Some choices below may be locked if the app has been launched by specifying a config preset.")
- with gr.Column():
- with gr.Tabs():
- # with gr.Row(visible=advanced_ui) as advanced_row:
- with gr.Tab("General"):
- dropdown_families, dropdown_choices = get_sorted_dropdown(displayed_model_types, None)
-
- transformer_types_choices = gr.Dropdown(
- choices= dropdown_choices,
- value= transformer_types,
- label= "Selectable Generative Models (keep empty to get All of them)",
- scale= 2,
- multiselect= True
- )
-
- fit_canvas_choice = gr.Dropdown(
- choices=[
- ("Dimensions correspond to the Pixels Budget (as the Prompt Image/Video will be Resized to match this pixels Budget, output video height or width may exceed the requested dimensions )", 0),
- ("Dimensions correspond to the Maximum Width and Height (as the Prompt Image/Video will be Resized to fit into these dimensions, the output video may be smaller)", 1),
- ("Dimensions correspond to the Output Width and Height (as the Prompt Image/Video will be Cropped to fit exactly these dimensions)", 2),
- ],
- value= server_config.get("fit_canvas", 0),
- label="Generated Video Dimensions when Prompt contains an Image or a Video",
- interactive= not lock_ui_attention
- )
-
-
- def check(mode):
- if not mode in attention_modes_installed:
- return " (NOT INSTALLED)"
- elif not mode in attention_modes_supported:
- return " (NOT SUPPORTED)"
- else:
- return ""
- attention_choice = gr.Dropdown(
- choices=[
- ("Auto : pick sage2 > sage > sdpa depending on what is installed", "auto"),
- ("Scale Dot Product Attention: default, always available", "sdpa"),
- ("Flash" + check("flash")+ ": good quality - requires additional install (usually complex to set up on Windows without WSL)", "flash"),
- ("Xformers" + check("xformers")+ ": good quality - requires additional install (usually complex, may consume less VRAM to set up on Windows without WSL)", "xformers"),
- ("Sage" + check("sage")+ ": 30% faster but slightly worse quality - requires additional install (usually complex to set up on Windows without WSL)", "sage"),
- ("Sage2/2++" + check("sage2")+ ": 40% faster but slightly worse quality - requires additional install (usually complex to set up on Windows without WSL)", "sage2")]\
- + ([("Radial" + check("radial")+ ": x? faster but ? quality - requires Sparge & Sage 2 Attn (usually complex to set up on Windows without WSL)", "radial")] if args.betatest else [])\
- + [("Sage3" + check("sage3")+ ": x2 faster but worse quality - requires additional install (usually complex to set up on Windows without WSL)", "sage3")],
- value= attention_mode,
- label="Attention Type",
- interactive= not lock_ui_attention
- )
-
-
- metadata_choice = gr.Dropdown(
- choices=[
- ("Export JSON files", "json"),
- ("Embed metadata (Exif tag)", "metadata"),
- ("Neither", "none")
- ],
- value=server_config.get("metadata_type", "metadata"),
- label="Metadata Handling"
- )
- preload_model_policy_choice = gr.CheckboxGroup([("Preload Model while Launching the App","P"), ("Preload Model while Switching Model", "S"), ("Unload Model when Queue is Done", "U")],
- value=server_config.get("preload_model_policy",[]),
- label="RAM Loading / Unloading Model Policy (in any case VRAM will be freed once the queue has been processed)"
- )
-
- clear_file_list_choice = gr.Dropdown(
- choices=[
- ("None", 0),
- ("Keep the last video", 1),
- ("Keep the last 5 videos", 5),
- ("Keep the last 10 videos", 10),
- ("Keep the last 20 videos", 20),
- ("Keep the last 30 videos", 30),
- ],
- value=server_config.get("clear_file_list", 5),
- label="Keep Previously Generated Videos when starting a new Generation Batch"
- )
-
- display_stats_choice = gr.Dropdown(
- choices=[
- ("Disabled", 0),
- ("Enabled", 1),
- ],
- value=server_config.get("display_stats", 0),
- label="Display in real time available RAM / VRAM and other stats (needs a restart)"
- )
-
- max_frames_multiplier_choice = gr.Dropdown(
- choices=[
- ("Default", 1),
- ("x2", 2),
- ("x3", 3),
- ("x4", 4),
- ("x5", 5),
- ("x6", 7),
- ("x7", 7),
- ],
- value=server_config.get("max_frames_multiplier", 1),
- label="Increase the Max Number of Frames (needs more RAM and VRAM, usually the longer the worse the quality, needs an App restart)"
- )
-
- UI_theme_choice = gr.Dropdown(
- choices=[
- ("Blue Sky", "default"),
- ("Classic Gradio", "gradio"),
- ],
- value=server_config.get("UI_theme", "default"),
- label="User Interface Theme. You will need to restart the App the see new Theme."
- )
-
-
- with gr.Tab("Performance"):
-
- quantization_choice = gr.Dropdown(
- choices=[
- ("Scaled Int8 Quantization (recommended)", "int8"),
- ("16 bits (no quantization)", "bf16"),
- ],
- value= transformer_quantization,
- label="Transformer Model Quantization Type (if available)",
- )
-
- transformer_dtype_policy_choice = gr.Dropdown(
- choices=[
- ("Best Supported Data Type by Hardware", ""),
- ("FP16", "fp16"),
- ("BF16", "bf16"),
- ],
- value= server_config.get("transformer_dtype_policy", ""),
- label="Transformer Data Type (if available)"
- )
-
- mixed_precision_choice = gr.Dropdown(
- choices=[
- ("16 bits only, requires less VRAM", "0"),
- ("Mixed 16 / 32 bits, slightly more VRAM needed but better Quality mainly for 1.3B models", "1"),
- ],
- value= server_config.get("mixed_precision", "0"),
- label="Transformer Engine Calculation"
- )
-
-
- text_encoder_quantization_choice = gr.Dropdown(
- choices=[
- ("16 bits - unquantized text encoder, better quality uses more RAM", "bf16"),
- ("8 bits - quantized text encoder, slightly worse quality but uses less RAM", "int8"),
- ],
- value= text_encoder_quantization,
- label="Text Encoder model"
- )
-
- VAE_precision_choice = gr.Dropdown(
- choices=[
- ("16 bits, requires less VRAM and faster", "16"),
- ("32 bits, requires twice more VRAM and slower but recommended with Window Sliding", "32"),
- ],
- value= server_config.get("vae_precision", "16"),
- label="VAE Encoding / Decoding precision"
- )
-
- gr.Text("Beware: when restarting the server or changing a resolution or video duration, the first step of generation for a duration / resolution may last a few minutes due to recompilation", interactive= False, show_label= False )
- compile_choice = gr.Dropdown(
- choices=[
- ("On (requires to have Triton installed)", "transformer"),
- ("Off", "" ),
- ],
- value= compile,
- label="Compile Transformer : up to 10-20% faster, useful only if multiple gens at same frames no / resolution",
- interactive= not lock_ui_compile
- )
-
- depth_anything_v2_variant_choice = gr.Dropdown(
- choices=[
- ("Large (more precise but 2x slower)", "vitl"),
- ("Big (less precise, less VRAM needed but faster)", "vitb"),
- ],
- value= server_config.get("depth_anything_v2_variant", "vitl"),
- label="Depth Anything v2 Vace Preprocessor Model type",
- )
-
- vae_config_choice = gr.Dropdown(
- choices=[
- ("Auto", 0),
- ("Disabled (faster but may require up to 22 GB of VRAM)", 1),
- ("256 x 256 : If at least 8 GB of VRAM", 2),
- ("128 x 128 : If at least 6 GB of VRAM", 3),
- ],
- value= vae_config,
- label="VAE Tiling - reduce the high VRAM requirements for VAE decoding and VAE encoding (if enabled it will be slower)"
- )
-
- boost_choice = gr.Dropdown(
- choices=[
- # ("Auto (ON if Video longer than 5s)", 0),
- ("ON", 1),
- ("OFF", 2),
- ],
- value=boost,
- label="Boost: Give a 10% speedup without losing quality at the cost of a litle VRAM (up to 1GB at max frames and resolution)"
- )
-
- profile_choice = gr.Dropdown(
- choices = memory_profile_choices,
- value= default_profile,
- label="Profile (for power users only, not needed to change it)"
- )
- preload_in_VRAM_choice = gr.Slider(0, 40000, value=server_config.get("preload_in_VRAM", 0), step=100, label="Number of MB of Models that are Preloaded in VRAM (0 will use Profile default)")
-
- release_RAM_btn = gr.Button("Force Release RAM")
- release_RAM_btn.click(fn=release_RAM)
-
- with gr.Tab("Extensions"):
- enhancer_enabled_choice = gr.Dropdown(
- choices=[
- ("Off", 0),
- ("Florence 2 1.6B + LLava 3.2 3.5B", 1),
- ("Florence 2 1.6B + LLama Joy Caption (uncensored but needs more VRAM) 9,3B", 2),
- ],
- value=server_config.get("enhancer_enabled", 0),
- label="Prompt Enhancer (if enabled, from 8 GB to 14 GB of extra models will be downloaded)"
- )
-
- enhancer_mode_choice = gr.Dropdown(
- choices=[
- ("Automatically triggered when Generating a Video", 0),
- ("On Demand Only", 1),
- ],
- value=server_config.get("enhancer_mode", 0),
- label="Prompt Enhancer Usage"
- )
-
- mmaudio_enabled_choice = gr.Dropdown(
- choices=[
- ("Off", 0),
- ("Turned On but unloaded from RAM after usage", 1),
- ("Turned On and kept in RAM for fast loading", 2),
- ],
- value=server_config.get("mmaudio_enabled", 0),
- label="MMAudio (if enabled, 10 GB of extra models will be downloaded)"
- )
-
- with gr.Tab("Outputs"):
-
- video_output_codec_choice = gr.Dropdown(
- choices=[
- ("x265 Balanced Quality (CRF 28)", 'libx265_28'),
- ("x264 Balanced Quality (Level 8)", 'libx264_8'),
- ("x265 High Quality (CRF 8)", 'libx265_8'),
- ("x264 High Quality (Level 10)", 'libx264_10'),
- ("x264 Lossless", 'libx264_lossless'),
- ],
- value=server_config.get("video_output_codec", "libx264_8"),
- label="Video Codec to use"
- )
-
- image_output_codec_choice = gr.Dropdown(
- choices=[
- ("JPEG Quality 85", 'jpeg_85'),
- ("WEBP Quality 85", 'webp_85'),
- ("JPEG Quality 95", 'jpeg_95'),
- ("WEBP Quality 95", 'webp_95'),
- ("WEBP Lossless", 'webp_lossless'),
- ("PNG Lossless", 'png'),
- ],
- value=server_config.get("image_output_codec", "jpeg_95"),
- label="Image Codec to use"
- )
-
- audio_output_codec_choice = gr.Dropdown(
- choices=[
- ("AAC 128 kbit", 'aac_128'),
- ],
- value=server_config.get("audio_output_codec", "aac_128"),
- visible = False,
- label="Audio Codec to use"
- )
-
- video_save_path_choice = gr.Textbox(
- label="Output Folder for Generated Videos (need to restart app to be taken into account)",
- value=server_config.get("save_path", save_path)
- )
-
- image_save_path_choice = gr.Textbox(
- label="Output Folder for Generated Images (need to restart app to be taken into account)",
- value=server_config.get("image_save_path", image_save_path)
- )
-
-
- with gr.Tab("Notifications"):
- gr.Markdown("### Notification Settings")
- notification_sound_enabled_choice = gr.Dropdown(
- choices=[
- ("On", 1),
- ("Off", 0),
- ],
- value=server_config.get("notification_sound_enabled", 0),
- label="Notification Sound Enabled"
- )
-
- notification_sound_volume_choice = gr.Slider(
- minimum=0,
- maximum=100,
- value=server_config.get("notification_sound_volume", 50),
- step=5,
- label="Notification Sound Volume (0 = silent, 100 = very loud)"
- )
-
-
-
- msg = gr.Markdown()
- apply_btn = gr.Button("Apply Changes")
- apply_btn.click(
- fn=apply_changes,
- inputs=[
- state,
- transformer_types_choices,
- transformer_dtype_policy_choice,
- text_encoder_quantization_choice,
- VAE_precision_choice,
- mixed_precision_choice,
- video_save_path_choice,
- image_save_path_choice,
- attention_choice,
- compile_choice,
- profile_choice,
- vae_config_choice,
- metadata_choice,
- quantization_choice,
- boost_choice,
- clear_file_list_choice,
- preload_model_policy_choice,
- UI_theme_choice,
- enhancer_enabled_choice,
- enhancer_mode_choice,
- mmaudio_enabled_choice,
- fit_canvas_choice,
- preload_in_VRAM_choice,
- depth_anything_v2_variant_choice,
- notification_sound_enabled_choice,
- notification_sound_volume_choice,
- max_frames_multiplier_choice,
- display_stats_choice,
- video_output_codec_choice,
- image_output_codec_choice,
- audio_output_codec_choice,
- resolution,
- ],
- outputs= [msg , header, model_family, model_choice, refresh_form_trigger]
- )
-
-def generate_about_tab():
- gr.Markdown("<H2>WanGP - AI Generative Models for the GPU Poor by <B>DeepBeepMeep</B> (<A HREF='https://github.com/deepbeepmeep/Wan2GP'>GitHub</A>)</H2>")
- gr.Markdown("Many thanks to:")
- gr.Markdown("- <B>Alibaba Wan Team</B> for the best open source video generators (https://github.com/Wan-Video/Wan2.1)")
- gr.Markdown("- <B>Alibaba Vace, Multitalk and Fun Teams</B> for their incredible control net models (https://github.com/ali-vilab/VACE), (https://github.com/MeiGen-AI/MultiTalk) and (https://huggingface.co/alibaba-pai/Wan2.2-Fun-A14B-InP) ")
- gr.Markdown("- <B>Tencent</B> for the impressive Hunyuan Video models (https://github.com/Tencent-Hunyuan/HunyuanVideo)")
- gr.Markdown("- <B>Blackforest Labs</B> for the innovative Flux image generators (https://github.com/black-forest-labs/flux)")
- gr.Markdown("- <B>Alibaba Qwen Team</B> for their state of the art Qwen Image generators (https://github.com/QwenLM/Qwen-Image)")
- gr.Markdown("- <B>Lightricks</B> for their super fast LTX Video models (https://github.com/Lightricks/LTX-Video)")
- gr.Markdown("- <B>Hugging Face</B> for providing hosting for the models and developing must have open source libraries such as Tranformers, Diffusers, Accelerate and Gradio (https://huggingface.co/)")
- gr.Markdown("<BR>Huge acknowledgments to these great open source projects used in WanGP:")
- gr.Markdown("- <B>Rife</B>: temporal upsampler (https://github.com/hzwer/ECCV2022-RIFE)")
- gr.Markdown("- <B>DwPose</B>: Open Pose extractor (https://github.com/IDEA-Research/DWPose)")
- gr.Markdown("- <B>DepthAnything</B> & <B>Midas</B>: Depth extractors (https://github.com/DepthAnything/Depth-Anything-V2) and (https://github.com/isl-org/MiDaS")
- gr.Markdown("- <B>Matanyone</B> and <B>SAM2</B>: Mask Generation (https://github.com/pq-yang/MatAnyone) and (https://github.com/facebookresearch/sam2)")
- gr.Markdown("- <B>Pyannote</B>: speaker diarization (https://github.com/pyannote/pyannote-audio)")
-
- gr.Markdown("<BR>Special thanks to the following people for their support:")
- gr.Markdown("- <B>Cocktail Peanuts</B> : QA dpand simple installation via Pinokio.computer")
- gr.Markdown("- <B>Tophness</B> : created (former) multi tabs and queuing frameworks")
- gr.Markdown("- <B>AmericanPresidentJimmyCarter</B> : added original support for Skip Layer Guidance")
- gr.Markdown("- <B>Remade_AI</B> : for their awesome Loras collection")
- gr.Markdown("- <B>Reevoy24</B> : for his repackaging / completing the documentation")
- gr.Markdown("- <B>Redtash1</B> : for designing the protype of the RAM / VRAM stats viewer")
-
-def generate_info_tab():
-
-
- with open("docs/VACE.md", "r", encoding="utf-8") as reader:
- vace= reader.read()
-
- with open("docs/MODELS.md", "r", encoding="utf-8") as reader:
- models = reader.read()
-
- with open("docs/LORAS.md", "r", encoding="utf-8") as reader:
- loras = reader.read()
-
- with open("docs/FINETUNES.md", "r", encoding="utf-8") as reader:
- finetunes = reader.read()
-
- with gr.Tabs() :
- with gr.Tab("Models", id="models"):
- gr.Markdown(models)
- with gr.Tab("Loras", id="loras"):
- gr.Markdown(loras)
- with gr.Tab("Vace", id="vace"):
- gr.Markdown(vace)
- with gr.Tab("Finetunes", id="finetunes"):
- gr.Markdown(finetunes)
def compact_name(family_name, model_name):
if model_name.startswith(family_name):
@@ -9917,17 +9350,6 @@ def create_ui():
( state, loras_choices, lset_name, resolution, refresh_form_trigger, save_form_trigger, tab_components
# video_guide, image_guide, video_mask, image_mask, image_refs,
) = generate_video_tab(model_family=model_family, model_choice=model_choice, header=header, main = main, main_tabs =main_tabs)
- with gr.Tab("Guides", id="info") as info_tab:
- generate_info_tab()
- with gr.Tab("Video Mask Creator", id="video_mask_creator") as video_mask_creator:
- matanyone_app.display(main_tabs, tab_state, state, refresh_form_trigger, server_config, get_current_model_settings) #, video_guide, image_guide, video_mask, image_mask, image_refs)
- if not args.lock_config:
- with gr.Tab("Downloads", id="downloads") as downloads_tab:
- generate_download_tab(lset_name, loras_choices, state)
- with gr.Tab("Configuration", id="configuration") as configuration_tab:
- generate_configuration_tab(state, main, header, model_family, model_choice, resolution, refresh_form_trigger)
- with gr.Tab("About"):
- generate_about_tab()
app.finalize_ui_setup(globals(), tab_components)
if stats_app is not None:
stats_app.setup_events(main, state)