Skip to content
Python

some feature for some future

DeepBeepMeep222659ccd4a2
diff --git a/defaults/animate.json b/defaults/animate.json
index bf45f4a..bdcb6fe 100644
--- a/defaults/animate.json
+++ b/defaults/animate.json
@@ -1,6 +1,6 @@
{
"model": {
- "name": "Wan2.2 Animate",
+ "name": "Wan2.2 Animate 14B",
"architecture": "animate",
"description": "Wan-Animate takes a video and a character image as input, and generates a video in either 'Animation' or 'Replacement' mode. Sliding Window of 81 frames at least are recommeded to obtain the best Style continuity.",
"URLs": [
diff --git a/defaults/fantasy.json b/defaults/fantasy.json
index 3917cab..fc09cee 100644
--- a/defaults/fantasy.json
+++ b/defaults/fantasy.json
@@ -1,7 +1,7 @@
{
"model":
{
- "name": "Fantasy Talking 720p",
+ "name": "Fantasy Talking 720p 14B",
"architecture" : "fantasy",
"modules": [ ["https://huggingface.co/DeepBeepMeep/Wan2.1/resolve/main/wan2.1_fantasy_speaking_14B_bf16.safetensors"]],
"description": "The Fantasy Talking model corresponds to the original Wan image 2 video model combined with the Fantasy Speaking module to process an audio Input.",
diff --git a/defaults/flux_dev_umo.json b/defaults/flux_dev_umo.json
index ea73680..a5e8e7d 100644
--- a/defaults/flux_dev_umo.json
+++ b/defaults/flux_dev_umo.json
@@ -1,8 +1,8 @@
{
"model": {
- "name": "Flux 1 Dev UMO 12B",
+ "name": "Flux 1 UMO Dev 12B",
"architecture": "flux_dev_umo",
- "description": "FLUX.1 Dev UMO is a model that can Edit Images with a specialization in combining multiple image references (resized internally at 512x512 max) to produce an Image output. Best Image preservation at 768x768 Resolution Output.",
+ "description": "FLUX.1 UMO Dev is a model that can Edit Images with a specialization in combining multiple image references (resized internally at 512x512 max) to produce an Image output. Best Image preservation at 768x768 Resolution Output.",
"URLs": "flux",
"loras": ["https://huggingface.co/DeepBeepMeep/Flux/resolve/main/flux1-dev-UMO_dit_lora_bf16.safetensors"],
"resolutions": [ ["1024x1024 (1:1)", "1024x1024"],
diff --git a/defaults/flux_dev_uso.json b/defaults/flux_dev_uso.json
index fee8f25..4b42921 100644
--- a/defaults/flux_dev_uso.json
+++ b/defaults/flux_dev_uso.json
@@ -1,8 +1,8 @@
{
"model": {
- "name": "Flux 1 Dev USO 12B",
+ "name": "Flux 1 USO Dev 12B",
"architecture": "flux_dev_uso",
- "description": "FLUX.1 Dev USO is a model that can Edit Images with a specialization in Style Transfers (up to two).",
+ "description": "FLUX.1 USO Dev is a model that can Edit Images with a specialization in Style Transfers (up to two).",
"modules": [ ["https://huggingface.co/DeepBeepMeep/Flux/resolve/main/flux1-dev-USO_projector_bf16.safetensors"]],
"URLs": "flux",
"loras": ["https://huggingface.co/DeepBeepMeep/Flux/resolve/main/flux1-dev-USO_dit_lora_bf16.safetensors"]
diff --git a/defaults/flux_krea.json b/defaults/flux_krea.json
index 4fa0b3f..669e1a5 100644
--- a/defaults/flux_krea.json
+++ b/defaults/flux_krea.json
@@ -1,6 +1,6 @@
{
"model": {
- "name": "Flux 1 Krea Dev 12B",
+ "name": "Flux 1 Dev Krea 12B",
"architecture": "flux",
"description": "Cutting-edge output quality, with a focus on aesthetic photography..",
"URLs": [
diff --git a/defaults/flux_srpo.json b/defaults/flux_srpo.json
index 188c162..8b1c447 100644
--- a/defaults/flux_srpo.json
+++ b/defaults/flux_srpo.json
@@ -1,6 +1,6 @@
{
"model": {
- "name": "Flux 1 SRPO Dev 12B",
+ "name": "Flux 1 Dev SRPO 12B",
"architecture": "flux",
"description": "By fine-tuning the FLUX.1.dev model with optimized denoising and online reward adjustment, SRPO improves its human-evaluated realism and aesthetic quality by over 3x.",
"URLs": [
diff --git a/defaults/flux_srpo_uso.json b/defaults/flux_srpo_uso.json
index e43371d..eed67bd 100644
--- a/defaults/flux_srpo_uso.json
+++ b/defaults/flux_srpo_uso.json
@@ -1,8 +1,8 @@
{
"model": {
- "name": "Flux 1 SRPO USO 12B",
+ "name": "Flux 1 USO SRPO 12B",
"architecture": "flux_dev_uso",
- "description": "FLUX.1 SRPO USO is a model that can Edit Images with a specialization in Style Transfers (up to two). It leverages the improved Image quality brought by the SRPO process",
+ "description": "FLUX.1 USO SRPO is a model that can Edit Images with a specialization in Style Transfers (up to two). It leverages the improved Image quality brought by the SRPO process",
"modules": [ "flux_dev_uso"],
"URLs": "flux_srpo",
"loras": "flux_dev_uso"
diff --git a/defaults/hunyuan_t2v_accvideo.json b/defaults/hunyuan_t2v_accvideo.json
index 23309d0..2da984a 100644
--- a/defaults/hunyuan_t2v_accvideo.json
+++ b/defaults/hunyuan_t2v_accvideo.json
@@ -1,6 +1,6 @@
{
"model": {
- "name": "Hunyuan Video AccVideo 720p 13B",
+ "name": "Hunyuan Video Text2video 720p AccVideo 13B",
"architecture": "hunyuan",
"description": " AccVideo is a novel efficient distillation method to accelerate video diffusion models with synthetic datset. Our method is 8.5x faster than HunyuanVideo.",
"URLs": [
diff --git a/defaults/hunyuan_t2v_fast.json b/defaults/hunyuan_t2v_fast.json
index 30adb17..4019e24 100644
--- a/defaults/hunyuan_t2v_fast.json
+++ b/defaults/hunyuan_t2v_fast.json
@@ -1,6 +1,6 @@
{
"model": {
- "name": "Hunyuan Video FastHunyuan 720p 13B",
+ "name": "Hunyuan Video Text2video 720p FastHunyuan 13B",
"architecture": "hunyuan",
"description": "Fast Hunyuan is an accelerated HunyuanVideo model. It can sample high quality videos with 6 diffusion steps.",
"settings_dir": [ "" ],
diff --git a/defaults/infinitetalk.json b/defaults/infinitetalk.json
index 7fddea9..fc28d96 100644
--- a/defaults/infinitetalk.json
+++ b/defaults/infinitetalk.json
@@ -1,6 +1,6 @@
{
"model": {
- "name": "Infinitetalk Single Speaker 480p",
+ "name": "Infinitetalk Single Speaker 480p 14B",
"architecture": "infinitetalk",
"modules": [
[
diff --git a/defaults/infinitetalk_multi.json b/defaults/infinitetalk_multi.json
index 97251e8..229ecc7 100644
--- a/defaults/infinitetalk_multi.json
+++ b/defaults/infinitetalk_multi.json
@@ -1,6 +1,6 @@
{
"model": {
- "name": "Infinitetalk Multi Speakers 480p",
+ "name": "Infinitetalk Multi Speakers 480p 14B",
"architecture": "infinitetalk",
"modules": [
[
diff --git a/defaults/lucy_edit_fastwan.json b/defaults/lucy_edit_fastwan.json
index 2a52166..de2830c 100644
--- a/defaults/lucy_edit_fastwan.json
+++ b/defaults/lucy_edit_fastwan.json
@@ -1,6 +1,6 @@
{
"model": {
- "name": "Wan2.2 FastWan Lucy Edit 5B",
+ "name": "Wan2.2 Lucy Edit FastWan 5B",
"architecture": "lucy_edit",
"description": "Lucy Edit is a video editing model that performs instruction-guided edits on videos using free-text prompts. It supports a variety of edits, such as clothing & accessory changes, character changes, object insertions, and scene replacements while preserving the motion and composition perfectly. This is the FastWan version for faster generation.",
"URLs": "lucy_edit",
diff --git a/defaults/multitalk.json b/defaults/multitalk.json
index 1133657..41699b5 100644
--- a/defaults/multitalk.json
+++ b/defaults/multitalk.json
@@ -1,7 +1,7 @@
{
"model":
{
- "name": "Multitalk 480p",
+ "name": "Multitalk 480p 14B",
"architecture" : "multitalk",
"modules": [
["https://huggingface.co/DeepBeepMeep/Wan2.1/resolve/main/wan2.1_multitalk_14B_mbf16.safetensors",
diff --git a/defaults/multitalk_720p.json b/defaults/multitalk_720p.json
index 4bdaabc..f18bebc 100644
--- a/defaults/multitalk_720p.json
+++ b/defaults/multitalk_720p.json
@@ -1,7 +1,7 @@
{
"model":
{
- "name": "Multitalk 720p",
+ "name": "Multitalk 720p 14B",
"architecture" : "multitalk",
"modules": ["multitalk"],
"description": "The Multitalk model corresponds to the original Wan image 2 video 720p model combined with the Multitalk module. It lets you have up to two people have a conversation.",
diff --git a/defaults/t2v_2_2.json b/defaults/t2v_2_2.json
index 122eeb9..806a1bf 100644
--- a/defaults/t2v_2_2.json
+++ b/defaults/t2v_2_2.json
@@ -2,7 +2,7 @@
"model":
{
"name": "Wan2.2 Text2video 14B",
- "architecture" : "t2v",
+ "architecture" : "t2v_2_2",
"description": "Wan 2.2 Text 2 Video model",
"URLs": [
"https://huggingface.co/DeepBeepMeep/Wan2.2/resolve/main/wan2.2_text2video_14B_high_mbf16.safetensors",
diff --git a/defaults/t2v_lighting_palingenesis_2_2.json b/defaults/t2v_lighting_palingenesis_2_2.json
index e52119b..f14f03a 100644
--- a/defaults/t2v_lighting_palingenesis_2_2.json
+++ b/defaults/t2v_lighting_palingenesis_2_2.json
@@ -2,7 +2,7 @@
"model":
{
"name": "Wan2.2 Text2video Lightning Palingenesis 14B",
- "architecture" : "t2v",
+ "architecture" : "t2v_2_2",
"description": "Wan 2.2 Text 2 Video Lightning Dyno model. Palingenesis a finetune praised for its high quality is used for the Low noise model whereas the High Noise model uses Lightning Finetune that offers natively Loras accelerators. ",
"URLs": [
"https://huggingface.co/lightx2v/Wan2.2-Lightning/resolve/main/Wan2.2-T2V-A14B-4steps-250928-dyno/Wan2.2-T2V-A14B-4steps-250928-dyno-high-lightx2v.safetensors"
diff --git a/defaults/ti2v_2_2_fastwan.json b/defaults/ti2v_2_2_fastwan.json
index c142dcb..eeb2cff 100644
--- a/defaults/ti2v_2_2_fastwan.json
+++ b/defaults/ti2v_2_2_fastwan.json
@@ -1,6 +1,6 @@
{
"model": {
- "name": "Wan2.2 FastWan TextImage2video 5B",
+ "name": "Wan2.2 TextImage2video FastWan 5B",
"architecture": "ti2v_2_2",
"description": "FastWan2.2-TI2V-5B-Full-Diffusers is built upon Wan-AI/Wan2.2-TI2V-5B-Diffusers. It supports efficient 3-step inference and produces high-quality videos at 121×704×1280 resolution",
"URLs": "ti2v_2_2",
diff --git a/defaults/vace_1.3B.json b/defaults/vace_1.3B.json
index 406b9a7..8b18f45 100644
--- a/defaults/vace_1.3B.json
+++ b/defaults/vace_1.3B.json
@@ -1,7 +1,7 @@
{
"model":
{
- "name": "Vace ControlNet 1.3B",
+ "name": "Vace 1.3B",
"architecture" : "vace_1.3B",
"modules": [
["https://huggingface.co/DeepBeepMeep/Wan2.1/resolve/main/wan2.1_Vace_1_3B_module.safetensors"]
diff --git a/defaults/vace_14B.json b/defaults/vace_14B.json
index b639664..0304db7 100644
--- a/defaults/vace_14B.json
+++ b/defaults/vace_14B.json
@@ -1,6 +1,6 @@
{
"model": {
- "name": "Vace ControlNet 14B",
+ "name": "Vace 14B",
"architecture": "vace_14B",
"modules": [
["https://huggingface.co/DeepBeepMeep/Wan2.1/resolve/main/wan2.1_Vace_14B_module_mbf16.safetensors",
diff --git a/defaults/vace_14B_2_2.json b/defaults/vace_14B_2_2.json
index 6aa8cf8..e93f96a 100644
--- a/defaults/vace_14B_2_2.json
+++ b/defaults/vace_14B_2_2.json
@@ -1,14 +1,13 @@
{
"model": {
- "name": "Wan2.2 Vace Experimental 14B",
+ "name": "Wan2.2 Vace 14B",
"architecture": "vace_14B_2_2",
"modules": [
"vace_14B"
],
"description": "There is so far only PARTIAL support of Vace 2.1 which is currently used.",
"URLs": "t2v_2_2",
- "URLs2": "t2v_2_2",
- "visible": false
+ "URLs2": "t2v_2_2"
},
"guidance_phases": 2,
"guidance_scale": 1,
diff --git a/defaults/vace_fun_14B_cocktail_2_2.json b/defaults/vace_fun_14B_cocktail_2_2.json
index 0a73438..b50ddda 100644
--- a/defaults/vace_fun_14B_cocktail_2_2.json
+++ b/defaults/vace_fun_14B_cocktail_2_2.json
@@ -1,7 +1,7 @@
{
"model": {
"name": "Wan2.2 Vace Fun Cocktail 14B",
- "architecture": "vace_14B",
+ "architecture": "vace_14B_2_2",
"description": "This model has been created on the fly using the Wan text 2.2 video model and the Loras of FusioniX. The weight of the Detail Enhancer Lora has been reduced to improve identity preservation. This is the Fun Vace 2.2, that is not the official Vace 2.2",
"URLs": "vace_fun_14B_2_2",
"URLs2": "vace_fun_14B_2_2",
diff --git a/models/wan/wan_handler.py b/models/wan/wan_handler.py
index dfc416e..da0bdc4 100644
--- a/models/wan/wan_handler.py
+++ b/models/wan/wan_handler.py
@@ -126,15 +126,18 @@ class family_handler():
extra_model_def["lynx_class"] = test_lynx(base_model_type)
vace_class = base_model_type in ["vace_14B", "vace_14B_2_2", "vace_1.3B", "vace_multitalk_14B", "vace_standin_14B", "vace_lynx_14B"]
extra_model_def["vace_class"] = vace_class
+ if base_model_type in ["vace_multitalk_14B", "vace_standin_14B", "vace_lynx_14B"]:
+ extra_model_def["parent_model_type"] = "vace_14B"
+
group = "wan"
if base_model_type in ["t2v_2_2", "i2v_2_2", "vace_14B_2_2"]:
profiles_dir = "wan_2_2"
- group = "wan_2_2"
+ group = "wan2_2"
elif i2v:
profiles_dir = "wan_i2v"
elif test_wan_5B(base_model_type):
profiles_dir = "wan_2_2_5B"
- group = "wan_2_2"
+ group = "wan2_2"
elif test_class_1_3B(base_model_type):
profiles_dir = "wan_1.3B"
else:
diff --git a/wgp.py b/wgp.py
index ff0a51d..1ce0824 100644
--- a/wgp.py
+++ b/wgp.py
@@ -54,6 +54,7 @@ from preprocessing.matanyone import app as matanyone_app
from tqdm import tqdm
import requests
from shared.gradio.gallery import AdvancedMediaGallery
+from collections import defaultdict
# import torch._dynamo as dynamo
# dynamo.config.recompile_limit = 2000 # default is 256
@@ -1839,6 +1840,7 @@ else:
checkpoints_paths = server_config.get("checkpoints_paths", None)
if checkpoints_paths is None: checkpoints_paths = server_config["checkpoints_paths"] = fl.default_checkpoints_paths
fl.set_checkpoints_paths(checkpoints_paths)
+three_levels_hierarchy = server_config.get("model_hierarchy_type", 1) == 1
# 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",
@@ -1897,6 +1899,12 @@ def get_base_model_type(model_type):
else:
return model_def["architecture"]
+def get_parent_model_type(model_type):
+ base_model_type = get_base_model_type(model_type)
+ if base_model_type is None: return None
+ model_def = get_model_def(base_model_type)
+ return model_def.get("parent_model_type", base_model_type)
+"vace_14B"
def get_model_handler(model_type):
base_model_type = get_base_model_type(model_type)
if base_model_type is None:
@@ -2993,6 +3001,7 @@ def release_RAM():
def apply_changes( state,
transformer_types_choices,
+ model_hierarchy_type_choice,
transformer_dtype_policy_choice,
text_encoder_quantization_choice,
VAE_precision_choice,
@@ -3029,13 +3038,14 @@ def apply_changes( state,
checkpoints_paths = [path.strip() for path in checkpoints_paths if len(path.strip()) > 0 ]
fl.set_checkpoints_paths(checkpoints_paths)
if args.lock_config:
- return "<DIV ALIGN=CENTER>Config Locked</DIV>",*[gr.update()]*4
+ return "<DIV ALIGN=CENTER>Config Locked</DIV>",*[gr.update()]*5
if gen_in_progress:
- return "<DIV ALIGN=CENTER>Unable to change config when a generation is in progress</DIV>",*[gr.update()]*4
+ return "<DIV ALIGN=CENTER>Unable to change config when a generation is in progress</DIV>",*[gr.update()]*5
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,
+ "model_hierarchy_type": model_hierarchy_type_choice,
"text_encoder_quantization" : text_encoder_quantization_choice,
"save_path" : save_path_choice,
"image_save_path" : image_save_path_choice,
@@ -3066,6 +3076,7 @@ def apply_changes( state,
"audio_output_codec" : audio_output_codec_choice,
"last_model_type" : state["model_type"],
"last_model_per_family": state["last_model_per_family"],
+ "last_model_per_type": state["last_model_per_type"],
"last_advanced_choice": state["advanced"],
"last_resolution_choice": last_resolution_choice,
"last_resolution_per_group": state["last_resolution_per_group"],
@@ -3090,7 +3101,8 @@ def apply_changes( state,
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
+ 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 , three_levels_hierarchy
+ three_levels_hierarchy= server_config["model_hierarchy_type"] == 1
attention_mode = server_config["attention_mode"]
default_profile = server_config["profile"]
compile = server_config["compile"]
@@ -3104,22 +3116,24 @@ def apply_changes( state,
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)
+ model_type = state["model_type"]
+ model_filename = get_model_filename(model_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", "checkpoints_paths"] for change in changes ):
+ "video_output_codec", "image_output_codec", "audio_output_codec", "checkpoints_paths", "model_hierarchy_type_choice"] for change in changes ):
model_family = gr.Dropdown()
+ model_base_type = gr.Dropdown()
model_choice = gr.Dropdown()
else:
reload_needed = True
- model_family, model_choice = generate_dropdown_model_list(transformer_type)
+ model_family, model_base_type, model_choice = generate_dropdown_model_list(model_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()
+ return "<DIV ALIGN=CENTER>The new configuration has been succesfully applied</DIV>", header, model_family, model_base_type, model_choice, get_unique_id()
def get_gen_info(state):
cache = state.get("gen", None)
@@ -5877,7 +5891,7 @@ def compute_lset_choices(model_type, loras_presets):
indent = chr(160) * 4
lset_choices = []
if len(global_list) > 0:
- lset_choices += [( (sep*16) +"Profiles" + (sep*17), ">Profiles")]
+ lset_choices += [( (sep*12) +"Accelerators Profiles" + (sep*13), ">profiles")]
lset_choices += [ ( indent + os.path.splitext(os.path.basename(preset))[0], preset) for preset in global_list ]
if len(settings_list) > 0:
settings_list.sort()
@@ -6089,14 +6103,14 @@ def apply_lset(state, wizard_prompt_activated, lset_name, loras_choices, loras_m
state["apply_success"] = 1
wizard_prompt_activated = "on"
- return wizard_prompt_activated, loras_choices, loras_mult_choices, prompt, get_unique_id(), gr.update(), gr.update(), gr.update()
+ return wizard_prompt_activated, loras_choices, loras_mult_choices, prompt, get_unique_id(), gr.update(), gr.update(), gr.update(), gr.update()
else:
lset_path = os.path.join("profiles" if len(Path(lset_name).parts)>1 else get_lora_dir(current_model_type), lset_name)
configs, _ = get_settings_from_file(state,lset_path , True, True, True, min_settings_version=2.38, merge_loras = "merge after" if len(Path(lset_name).parts)<=1 else "merge before" )
if configs == None:
gr.Info("File not supported")
- return [gr.update()] * 8
+ return [gr.update()] * 9
model_type = configs["model_type"]
configs["lset_name"] = lset_name
gr.Info(f"Settings File '{lset_name}' has been applied")
@@ -6104,7 +6118,7 @@ def apply_lset(state, wizard_prompt_activated, lset_name, loras_choices, loras_m
if help is not None: gr.Info(help)
if model_type == current_model_type:
set_model_settings(state, current_model_type, configs)
- return *[gr.update()] * 4, gr.update(), gr.update(), gr.update(), get_unique_id()
+ return *[gr.update()] * 4, gr.update(), gr.update(), gr.update(), gr.update(), get_unique_id()
else:
set_model_settings(state, model_type, configs)
return *[gr.update()] * 4, gr.update(), *generate_dropdown_model_list(model_type), gr.update()
@@ -6755,12 +6769,12 @@ def load_settings_from_file(state, file_path):
gen = get_gen_info(state)
if file_path==None:
- return gr.update(), gr.update(), None
+ return gr.update(), gr.update(), gr.update(), gr.update(), None
configs, any_video_or_image_file = get_settings_from_file(state, file_path, True, True, True)
if configs == None:
gr.Info("File not supported")
- return gr.update(), gr.update(), None
+ return gr.update(), gr.update(), gr.update(), gr.update(), None
current_model_type = state["model_type"]
model_type = configs["model_type"]
@@ -6774,7 +6788,7 @@ def load_settings_from_file(state, file_path):
if model_type == current_model_type:
set_model_settings(state, current_model_type, configs)
- return gr.update(), gr.update(), str(time.time()), None
+ return gr.update(), gr.update(), gr.update(), gr.update(), str(time.time()), None
else:
set_model_settings(state, model_type, configs)
return *generate_dropdown_model_list(model_type), gr.update(), None
@@ -6876,7 +6890,6 @@ def save_inputs(
):
- model_filename = state["model_filename"]
model_type = state["model_type"]
if image_mask_guide is not None and image_mode >= 1 and video_prompt_type is not None and "A" in video_prompt_type and not "U" in video_prompt_type:
# if image_mask_guide is not None and image_mode == 2:
@@ -6981,6 +6994,11 @@ def change_model(state, model_choice):
last_model_per_family = state["last_model_per_family"]
last_model_per_family[get_model_family(model_choice, for_ui= True)] = model_choice
server_config["last_model_per_family"] = last_model_per_family
+
+ last_model_per_type = state["last_model_per_type"]
+ last_model_per_type[get_base_model_type(model_choice)] = model_choice
+ server_config["last_model_per_type"] = last_model_per_type
+
server_config["last_model_type"] = model_choice
with open(server_config_filename, "w", encoding="utf-8") as writer:
@@ -7500,7 +7518,7 @@ def download_lora(state, lora_url, progress=gr.Progress(track_tqdm=True),):
-def generate_video_tab(update_form = False, state_dict = None, ui_defaults = None, model_family = None, model_choice = None, header = None, main = None, main_tabs= None):
+def generate_video_tab(update_form = False, state_dict = None, ui_defaults = None, model_family = None, model_base_type_choice = None, model_choice = None, header = None, main = None, main_tabs= None):
global inputs_names #, advanced
if update_form:
@@ -7517,6 +7535,7 @@ def generate_video_tab(update_form = False, state_dict = None, ui_defaults = Non
state_dict["model_type"] = model_type
state_dict["advanced"] = advanced_ui
state_dict["last_model_per_family"] = server_config.get("last_model_per_family", {})
+ state_dict["last_model_per_type"] = server_config.get("last_model_per_type", {})
state_dict["last_resolution_per_group"] = server_config.get("last_resolution_per_group", {})
gen = dict()
gen["queue"] = []
@@ -8622,7 +8641,7 @@ def generate_video_tab(update_form = False, state_dict = None, ui_defaults = Non
).then(fn=save_inputs,
inputs =[target_state] + gen_inputs,
outputs= None
- ).then( fn=use_video_settings, inputs =[state, output, last_choice] , outputs= [model_family, model_choice, refresh_form_trigger])
+ ).then( fn=use_video_settings, inputs =[state, output, last_choice] , outputs= [model_family, model_base_type_choice, model_choice, refresh_form_trigger])
prompt_enhancer_btn.click(fn=validate_wizard_prompt,
@@ -8667,7 +8686,7 @@ def generate_video_tab(update_form = False, state_dict = None, ui_defaults = Non
confirm_delete_lset_btn.click(delete_lset, inputs=[state, lset_name], outputs=[lset_name, apply_lset_btn, refresh_lora_btn, delete_lset_btn, save_lset_btn,confirm_delete_lset_btn, cancel_lset_btn ])
cancel_lset_btn.click(cancel_lset, inputs=[], outputs=[apply_lset_btn, refresh_lora_btn, delete_lset_btn, save_lset_btn, confirm_delete_lset_btn,confirm_save_lset_btn, cancel_lset_btn,save_lset_prompt_drop ])
apply_lset_btn.click(fn=save_inputs, inputs =[target_state] + gen_inputs, outputs= None).then(fn=apply_lset,
- inputs=[state, wizard_prompt_activated_var, lset_name,loras_choices, loras_multipliers, prompt], outputs=[wizard_prompt_activated_var, loras_choices, loras_multipliers, prompt, fill_wizard_prompt_trigger, model_family, model_choice, refresh_form_trigger])
+ inputs=[state, wizard_prompt_activated_var, lset_name,loras_choices, loras_multipliers, prompt], outputs=[wizard_prompt_activated_var, loras_choices, loras_multipliers, prompt, fill_wizard_prompt_trigger, model_family, model_base_type_choice, model_choice, refresh_form_trigger])
refresh_lora_btn.click(refresh_lora_list, inputs=[state, lset_name,loras_choices], outputs=[lset_name, loras_choices])
refresh_lora_btn2.click(refresh_lora_list, inputs=[state, lset_name,loras_choices], outputs=[lset_name, loras_choices])
@@ -8706,7 +8725,7 @@ def generate_video_tab(update_form = False, state_dict = None, ui_defaults = Non
).then(fn=save_inputs,
inputs =[target_state] + gen_inputs,
outputs= None
- ).then(fn=load_settings_from_file, inputs =[state, settings_file] , outputs= [model_family, model_choice, refresh_form_trigger, settings_file])
+ ).then(fn=load_settings_from_file, inputs =[state, settings_file] , outputs= [model_family, model_base_type_choice, model_choice, refresh_form_trigger, settings_file])
reset_settings_btn.click(fn=validate_wizard_prompt,
@@ -8735,7 +8754,8 @@ def generate_video_tab(update_form = False, state_dict = None, ui_defaults = Non
show_progress="hidden",
)
- model_family.input(fn=change_model_family, inputs=[state, model_family], outputs= [model_choice])
+ model_family.input(fn=change_model_family, inputs=[state, model_family], outputs= [model_base_type_choice, model_choice], show_progress="hidden")
+ model_base_type_choice.input(fn=change_model_base_types, inputs=[state, model_family, model_base_type_choice], outputs= [model_base_type_choice, model_choice], show_progress="hidden")
model_choice.change(fn=validate_wizard_prompt,
inputs= [state, wizard_prompt_activated_var, wizard_variables_var, prompt, wizard_prompt, *prompt_vars] ,
@@ -8923,13 +8943,13 @@ def generate_download_tab(lset_name,loras_choices, state):
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):
+def generate_configuration_tab(state, blocks, header, model_family, model_base_type_choice, 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)
+ _, _, dropdown_choices = get_sorted_dropdown(displayed_model_types, None, None, False)
transformer_types_choices = gr.Dropdown(
choices= dropdown_choices,
@@ -8939,6 +8959,17 @@ def generate_configuration_tab(state, blocks, header, model_family, model_choice
multiselect= True
)
+ model_hierarchy_type_choice = gr.Dropdown(
+ choices=[
+ ("Two Levels: Model Family > Models & Finetunes", 0),
+ ("Three Levels: Model Family > Models > Finetunes", 1),
+ ],
+ value= server_config.get("model_hierarchy_type", 1),
+ label= "Models Hierarchy In User Interface",
+ scale= 2,
+ )
+
+
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),
@@ -9241,6 +9272,7 @@ def generate_configuration_tab(state, blocks, header, model_family, model_choice
inputs=[
state,
transformer_types_choices,
+ model_hierarchy_type_choice,
transformer_dtype_policy_choice,
text_encoder_quantization_choice,
VAE_precision_choice,
@@ -9273,7 +9305,7 @@ def generate_configuration_tab(state, blocks, header, model_family, model_choice
resolution,
checkpoints_paths,
],
- outputs= [msg , header, model_family, model_choice, refresh_form_trigger]
+ outputs= [msg , header, model_family, model_base_type_choice, model_choice, refresh_form_trigger]
)
def generate_about_tab():
@@ -9331,7 +9363,100 @@ def compact_name(family_name, model_name):
return model_name[len(family_name):].strip()
return model_name
-def get_sorted_dropdown(dropdown_types, current_model_family):
+
+def create_models_hierarchy(rows):
+ """
+ rows: list of (model_name, model_id, parent_model_id)
+ returns:
+ parents_list: list[(parent_header, parent_id)]
+ children_dict: dict[parent_id] -> list[(child_display_name, child_id)]
+ """
+ toks=lambda s:[t for t in s.split() if t]
+ norm=lambda s:' '.join(s.split()).casefold()
+
+ groups,parents,order=defaultdict(list),{},[]
+ for name,mid,pmid in rows:
+ groups[pmid].append((name,mid))
+ if mid==pmid and pmid not in parents:
+ parents[pmid]=name; order.append(pmid)
+
+ parents_list,children_dict=[],{}
+
+ # --- Real parents ---
+ for pid in order:
+ p_name=parents[pid]; p_tok=toks(p_name); p_low=[w.casefold() for w in p_tok]
+ n=len(p_low); p_last=p_low[-1]; p_set=set(p_low)
+
+ kids=[]
+ for name,mid in groups.get(pid,[]):
+ ot=toks(name); lt=[w.casefold() for w in ot]; st=set(lt)
+ kids.append((name,mid,ot,lt,st))
+
+ outliers={mid for _,mid,_,_,st in kids if mid!=pid and p_set.isdisjoint(st)}
+
+ # Only parent + children that start with parent's first word contribute to prefix
+ prefix_non=[]
+ for name,mid,ot,lt,st in kids:
+ if mid==pid or (mid not in outliers and lt and lt[0]==p_low[0]):
+ prefix_non.append((ot,lt))
+
+ def lcp_len(a,b):
+ i=0; m=min(len(a),len(b))
+ while i<m and a[i]==b[i]: i+=1
+ return i
+ L=n if len(prefix_non)<=1 else min(lcp_len(lt,p_low) for _,lt in prefix_non)
+ if L==0 and len(prefix_non)>1: L=n
+
+ shares_last=any(mid!=pid and mid not in outliers and lt and lt[-1]==p_last
+ for _,mid,_,lt,_ in kids)
+ header_tokens_disp=p_tok[:L]+([p_tok[-1]] if shares_last and L<n else [])
+ header=' '.join(header_tokens_disp)
+ header_has_last=(L==n) or (shares_last and L<n)
+
+ prefix_low=p_low[:L]
+ def startswith_prefix(lt):
+ if L==0 or len(lt)<L: return False
+ for i in range(L):
+ if lt[i]!=prefix_low[i]: return False
+ return True
+
+ def disp(name,mid,ot,lt):
+ if mid in outliers: return name
+ rem=ot[L:] if startswith_prefix(lt) else ot[:]
+ if header_has_last and lt and lt[-1]==p_last and rem and rem[-1].casefold()==p_last:
+ rem=rem[:-1]
+ s=' '.join(rem).strip()
+ return s if s else 'Default'
+
+ entries=[(disp(p_name,pid,p_tok,p_low),pid)]
+ for name,mid,ot,lt,_ in kids:
+ if mid==pid: continue
+ entries.append((disp(name,mid,ot,lt),mid))
+
+ # Number "Default" for children whose full name == parent's full name
+ p_full=norm(p_name); full_by_mid={mid:name for name,mid,*_ in kids}
+ num=2; numbered=[entries[0]]
+ for dname,mid in entries[1:]:
+ if dname=='Default' and norm(full_by_mid[mid])==p_full:
+ numbered.append((f'Default #{num}',mid)); num+=1
+ else:
+ numbered.append((dname,mid))
+
+ parents_list.append((header,pid))
+ children_dict[pid]=numbered
+
+ # --- Orphan groups (no real parent present) ---
+ for pid in groups.keys():
+ if pid in parents: continue
+ first_name=groups[pid][0][0]
+ parents_list.append((first_name,pid)) # fake parent: full name of first orphan
+ children_dict[pid]=[(name,mid) for name,mid in groups[pid]] # copy full names only
+
+ parents_list = sorted(parents_list, key=lambda c: c[0])
+ return parents_list,children_dict
+
+
+def get_sorted_dropdown(dropdown_types, current_model_family, current_model_type, three_levels = True):
models_families = [get_model_family(type, for_ui= True) for type in dropdown_types]
families = {}
for family in models_families:
@@ -9345,32 +9470,53 @@ def get_sorted_dropdown(dropdown_types, current_model_family):
else:
dropdown_choices = [ (families_infos[family][0], compact_name(families_infos[family][1], get_model_name(model_type)), model_type) for model_type, family in zip( dropdown_types, models_families) if family == current_model_family]
dropdown_choices = sorted(dropdown_choices, key=lambda c: (c[0], c[1]))
- dropdown_choices = [model[1:] for model in dropdown_choices]
- return sorted_familes, dropdown_choices
+ if three_levels:
+ dropdown_choices = [ (*model[1:], get_parent_model_type(model[2])) for model in dropdown_choices]
+ sorted_choices, finetunes_dict = create_models_hierarchy(dropdown_choices)
+ return sorted_familes, sorted_choices, finetunes_dict[get_parent_model_type(current_model_type)]
+
+ else:
+ dropdown_types_list = list({get_parent_model_type(model[2]) for model in dropdown_choices})
+ dropdown_choices = [model[1:] for model in dropdown_choices]
+ return sorted_familes, dropdown_types_list, dropdown_choices
+
+
def generate_dropdown_model_list(current_model_type):
dropdown_types= transformer_types if len(transformer_types) > 0 else displayed_model_types
if current_model_type not in dropdown_types:
dropdown_types.append(current_model_type)
current_model_family = get_model_family(current_model_type, for_ui= True)
- sorted_familes, dropdown_choices = get_sorted_dropdown(dropdown_types, current_model_family)
+ sorted_familes, sorted_models, sorted_finetunes = get_sorted_dropdown(dropdown_types, current_model_family, current_model_type, three_levels=three_levels_hierarchy)
dropdown_families = gr.Dropdown(
choices= sorted_familes,
value= current_model_family,
show_label= False,
- scale= 1,
+ scale= 2 if three_levels_hierarchy else 1,
elem_id="family_list",
min_width=50
)
- return dropdown_families, gr.Dropdown(
- choices= dropdown_choices,
+ dropdown_models = gr.Dropdown(
+ choices= sorted_models,
+ value= get_base_model_type(current_model_type),
+ show_label= False,
+ scale= 3 if len(sorted_finetunes) > 1 else 7,
+ elem_id="model_base_types_list",
+ visible= three_levels_hierarchy
+ )
+
+ dropdown_finetunes = gr.Dropdown(
+ choices= sorted_finetunes,
value= current_model_type,
show_label= False,
scale= 4,
+ visible= len(sorted_finetunes) > 1,
elem_id="model_list",
)
+
+ return dropdown_families, dropdown_models, dropdown_finetunes
def change_model_family(state, current_model_family):
dropdown_types= transformer_types if len(transformer_types) > 0 else displayed_model_types
@@ -9381,7 +9527,33 @@ def change_model_family(state, current_model_family):
last_model_per_family = state.get("last_model_per_family", {})
model_type = last_model_per_family.get(current_model_family, "")
if len(model_type) == "" or model_type not in [choice[1] for choice in dropdown_choices] : model_type = dropdown_choices[0][1]
- return gr.Dropdown(choices= dropdown_choices, value = model_type )
+
+ parent_model_type = get_parent_model_type(model_type)
+ if three_levels_hierarchy:
+ dropdown_choices = [ (*tup, get_parent_model_type(tup[1])) for tup in dropdown_choices]
+ dropdown_base_types_choices, finetunes_dict = create_models_hierarchy(dropdown_choices)
+ dropdown_choices = finetunes_dict[parent_model_type ]
+ model_finetunes_visible = len(dropdown_choices) > 1
+ else:
+ model_finetunes_visible = True
+ dropdown_base_types_choices = list({get_parent_model_type(model[1]) for model in dropdown_choices})
+
+ return gr.Dropdown(choices= dropdown_base_types_choices, value = parent_model_type, scale=3 if model_finetunes_visible else 7), gr.Dropdown(choices= dropdown_choices, value = model_type, visible = model_finetunes_visible )
+
+def change_model_base_types(state, current_model_family, model_base_type_choice):
+ if not three_levels_hierarchy: return gr.update()
+ dropdown_types= transformer_types if len(transformer_types) > 0 else displayed_model_types
+ current_family_name = families_infos[current_model_family][1]
+ dropdown_choices = [ (compact_name(current_family_name, get_model_name(model_type)), model_type, model_base_type_choice) for model_type in dropdown_types if get_parent_model_type(model_type) == model_base_type_choice and get_model_family(model_type, for_ui= True) == current_model_family]
+ dropdown_choices = sorted(dropdown_choices, key=lambda c: c[0])
+ _, finetunes_dict = create_models_hierarchy(dropdown_choices)
+ dropdown_choices = finetunes_dict[model_base_type_choice ]
+ model_finetunes_visible = len(dropdown_choices) > 1
+ last_model_per_type = state.get("last_model_per_type", {})
+ model_type = last_model_per_type.get(model_base_type_choice, "")
+ if len(model_type) == "" or model_type not in [choice[1] for choice in dropdown_choices] : model_type = dropdown_choices[0][1]
+
+ return gr.update(scale=3 if model_finetunes_visible else 7), gr.Dropdown(choices= dropdown_choices, value = model_type, visible=model_finetunes_visible )
def set_new_tab(tab_state, new_tab_no):
global vmc_event_handler
@@ -9547,11 +9719,13 @@ def create_ui():
--layout-gap: 0px !important;
}
.postprocess span {margin-top:4px;margin-bottom:4px}
- #model_list, #family_list{
+ #model_list, #family_list, #model_base_types_list {
background-color:black;
padding:1px}
- #model_list input, #family_list input {
+ #model_list,#model_base_types_list { padding-left:0px}
+
+ #model_list input, #family_list input, #model_base_types_list input {
font-size:25px}
#family_list div div {
@@ -9562,6 +9736,10 @@ def create_ui():
border-radius: 0px 4px 4px 0px;
}
+ #model_base_types_list div div {
+ border-radius: 0px 0px 0px 0px;
+ }
+
.title-with-lines {
display: flex;
align-items: center;
@@ -9917,8 +10095,8 @@ def create_ui():
model_family = gr.Dropdown(visible=False, value= "")
model_choice = gr.Dropdown(visible=False, value= transformer_type, choices= [transformer_type])
else:
- gr.Markdown("<div class='title-with-lines'><div class=line width=100%></div></div>")
- model_family, model_choice = generate_dropdown_model_list(transformer_type)
+ gr.Markdown("<div class='title-with-lines'><div class=line width=100%></div></div>")
+ model_family, model_base_type_choice, model_choice = generate_dropdown_model_list(transformer_type)
gr.Markdown("<div class='title-with-lines'><div class=line width=100%></div></div>")
with gr.Row():
header = gr.Markdown(generate_header(transformer_type, compile, attention_mode), visible= True)
@@ -9927,17 +10105,16 @@ def create_ui():
with gr.Row():
( state, loras_choices, lset_name, resolution, refresh_form_trigger, save_form_trigger
- # 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)
+ ) = generate_video_tab(model_family=model_family, model_base_type_choice= model_base_type_choice, 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)
+ matanyone_app.display(main_tabs, tab_state, state, refresh_form_trigger, server_config, get_current_model_settings)
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)
+ generate_configuration_tab(state, main, header, model_family, model_base_type_choice, model_choice, resolution, refresh_form_trigger)
with gr.Tab("About"):
generate_about_tab()
if stats_app is not None: