add boogu

Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
Vladimir Mandic
2026-07-04 15:26:36 +02:00
parent 5b486dc3cf
commit db26b77909
23 changed files with 5152 additions and 16 deletions
+2
View File
@@ -127,6 +127,8 @@ def get_model_type(pipe):
model_type = 'ovis'
elif 'Wan' in name:
model_type = 'wanai'
elif 'BooguImage' in name or 'Boogu' in name:
model_type = 'boogu'
elif 'ChronoEdit' in name:
model_type = 'chrono'
elif 'HunyuanImage3' in name:
+9 -3
View File
@@ -40,6 +40,7 @@ def hf_init():
def hf_check_cache():
t0 = time.time()
from modules.modelstats import stat
prev_default = os.environ.get("SD_HFCACHEDIR", None) or os.path.join(os.path.expanduser('~'), '.cache', 'huggingface', 'hub')
if opts.hfcache_dir != prev_default:
@@ -52,9 +53,14 @@ def hf_check_cache():
if size // 1024 // 1024 > 99:
log.warning(f'Huggingface cache changed: type=xet unused="{prev_default}" size={size//1024//1024} MB')
hf_size, _mtime = stat(opts.hfcache_dir)
xet_size, _mtime = stat(opts.xetcache_dir)
log.debug(f'Huggingface: cache="{opts.hfcache_dir}" size={hf_size//1024//1024} MB xet="{opts.xetcache_dir}" size={xet_size//1024//1024} MB')
def check_thread():
hf_size, _mtime = stat(opts.hfcache_dir)
xet_size, _mtime = stat(opts.xetcache_dir)
t1 = time.time()
log.debug(f'Huggingface: cache="{opts.hfcache_dir}" size={hf_size//1024//1024} MB xet="{opts.xetcache_dir}" size={xet_size//1024//1024} MB time={t1-t0:.2f}')
from threading import Thread
Thread(target=check_thread, daemon=True).start()
def hf_search(keyword):
+37 -2
View File
@@ -13,7 +13,7 @@ def walk(folder: str):
return files
def stat(fn: str):
def _stat(fn: str):
if fn is None or len(fn) == 0 or not os.path.exists(fn):
return 0, datetime.fromtimestamp(0)
fs_stat = os.stat(fn, follow_symlinks=False)
@@ -23,12 +23,47 @@ def stat(fn: str):
elif os.path.isfile(fn):
size = round(fs_stat.st_size)
elif os.path.isdir(fn):
size = round(sum(stat(fn)[0] for fn in walk(fn)))
size = round(sum(_stat(fn)[0] for fn in walk(fn)))
else:
size = 0
return size, mtime
def stat(path: str):
try: # 1. Base Case: Check if path exists safely
root_stat = os.stat(path, follow_symlinks=False) # We fetch the stat of the root path once
except (FileNotFoundError, PermissionError):
return 0, datetime.fromtimestamp(0)
if os.path.stat.S_ISLNK(root_stat.st_mode): # 2. Handle Symlinks (Checking st_mode is faster than os.path.islink)
return 0, datetime.fromtimestamp(root_stat.st_mtime).replace(microsecond=0)
if os.path.stat.S_ISREG(root_stat.st_mode): # 3. Handle Single Files
return root_stat.st_size, datetime.fromtimestamp(root_stat.st_mtime).replace(microsecond=0)
# 4. Handle Directories
total_size = 0
latest_mtime = root_stat.st_mtime
try:
with os.scandir(path) as entries:
for entry in entries:
try:
entry_stat = entry.stat(follow_symlinks=False) # Fetch cached stat object from the entry
if entry_stat.st_mtime > latest_mtime: # Track the latest modification time across everything
latest_mtime = entry_stat.st_mtime
if entry.is_symlink():
continue
elif entry.is_file():
total_size += entry_stat.st_size
elif entry.is_dir():
sub_size, sub_mtime = stat(entry.path) # Recursively scan subfolders
total_size += sub_size
if sub_mtime.timestamp() > latest_mtime:
latest_mtime = sub_mtime.timestamp()
except (FileNotFoundError, PermissionError): # Skip files that disappear or lack permissions during runtime
continue
except (FileNotFoundError, PermissionError):
pass
return total_size, datetime.fromtimestamp(latest_mtime).replace(microsecond=0)
class Module:
name: str = ''
cls: str = None
+2
View File
@@ -80,6 +80,8 @@ def guess_by_name(fn, current_guess):
new_guess = 'Meissonic'
elif 'omnigen2' in fn.lower():
new_guess = 'OmniGen2'
elif 'boogu' in fn.lower():
new_guess = 'Boogu'
elif 'omnigen' in fn.lower():
new_guess = 'OmniGen'
elif 'sd3' in fn.lower():
+1 -1
View File
@@ -88,6 +88,6 @@ def hijack_encode_prompt(*args, **kwargs):
def init_hijack(pipe):
if pipe is not None and not hasattr(pipe, 'orig_encode_prompt') and hasattr(pipe, 'encode_prompt'):
if (pipe is not None) and not hasattr(pipe, 'orig_encode_prompt') and hasattr(pipe, 'encode_prompt'):
pipe.orig_encode_prompt = pipe.encode_prompt
pipe.encode_prompt = hijack_encode_prompt
+2 -2
View File
@@ -71,9 +71,9 @@ def hijack_vae_encode(*args, **kwargs):
def init_hijack(pipe):
if pipe is not None and hasattr(pipe, 'vae') and hasattr(pipe.vae, 'decode') and not hasattr(pipe.vae, 'orig_decode'):
if (pipe is not None) and hasattr(pipe, 'vae') and hasattr(pipe.vae, 'decode') and not hasattr(pipe.vae, 'orig_decode'):
pipe.vae.orig_decode = pipe.vae.decode
pipe.vae.decode = hijack_vae_decode
if pipe is not None and hasattr(pipe, 'vae') and hasattr(pipe.vae, 'encode') and not hasattr(pipe.vae, 'orig_encode'):
if (pipe is not None) and hasattr(pipe, 'vae') and hasattr(pipe.vae, 'encode') and not hasattr(pipe.vae, 'orig_encode'):
pipe.vae.orig_encode = pipe.vae.encode
pipe.vae.encode = hijack_vae_encode
+13 -1
View File
@@ -11,7 +11,7 @@ import diffusers.loaders.single_file_utils
import torch
import huggingface_hub as hf
from modules.logger import log
from modules import timer, paths, shared, modelloader, devices, script_callbacks, sd_vae, sd_unet, errors, sd_models_compile, sd_detect, model_quant, sd_hijack_te, sd_hijack_accelerate, sd_hijack_safetensors, sd_hijack_transformers, sd_hijack_hfhub, attention
from modules import timer, paths, shared, modelloader, devices, script_callbacks, sd_vae, sd_unet, errors, sd_models_compile, sd_detect, model_quant, sd_hijack_te, sd_hijack_vae, sd_hijack_accelerate, sd_hijack_safetensors, sd_hijack_transformers, sd_hijack_hfhub, attention
from modules.memstats import memory_stats
from modules.shared_helpers import walk_files
from modules.modeldata import model_data
@@ -54,6 +54,8 @@ pipe_switch_task_exclude = [
'Kandinsky5I2IPipeline',
'GoogleNanoBananaPipeline',
'Step1XEditPipeline',
'BooguImagePipeline',
'BooguImageTurboPipeline',
]
i2i_pipes = [
'LEditsPPPipelineStableDiffusion', 'LEditsPPPipelineStableDiffusionXL',
@@ -480,6 +482,10 @@ def load_diffuser_force(detected_model_type: str, checkpoint_info: CheckpointInf
from pipelines.model_qwen import load_qwen
sd_model = load_qwen(checkpoint_info, diffusers_load_config)
allow_post_quant = False
elif model_type in ['Boogu']:
from pipelines.model_boogu import load_boogu
sd_model = load_boogu(checkpoint_info, diffusers_load_config)
allow_post_quant = False
elif model_type in ['HunyuanDiT']:
from pipelines.model_hunyuandit import load_hunyuandit
sd_model = load_hunyuandit(checkpoint_info, diffusers_load_config)
@@ -1225,6 +1231,8 @@ def backup_pipe_components(pipe):
'mask_processor': getattr(pipe, "mask_processor", None),
'restore_pipeline': getattr(pipe, "restore_pipeline", None),
'task_args': getattr(pipe, "task_args", None),
'hijack_prompt': hasattr(pipe, "orig_encode_prompt"),
'hijack_vae': hasattr(pipe, "vae") and hasattr(pipe.vae, "orig_decode")
}
@@ -1250,6 +1258,10 @@ def restore_pipe_components(pipe, components):
pipe.restore_pipeline = components['restore_pipeline']
if components['task_args'] is not None:
pipe.task_args = components['task_args']
if components['hijack_prompt']:
sd_hijack_te.init_hijack(pipe)
if components['hijack_vae']:
sd_hijack_vae.init_hijack(pipe)
if pipe.__class__.__name__ in ['FluxPipeline', 'StableDiffusion3Pipeline']:
pipe.register_modules(image_encoder = components['image_encoder'])
+1
View File
@@ -83,6 +83,7 @@ pipelines = {
'VIBE': None,
'XOmni': None,
'ZetaChroma': None,
'Boogu': None,
}