mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 09:14:35 +02:00
@@ -11,6 +11,8 @@
|
||||
- fix: model type detection
|
||||
- fix: version detection when cloned with `.git` suffix
|
||||
- fix: init `sdnq` on video model load
|
||||
- fix: add vae scale override for chrono
|
||||
- fix: add tracing to model detection
|
||||
- ui: fix full-screen image viewer buttons with non-standard ui theme
|
||||
- ui: control tab show override section
|
||||
|
||||
|
||||
+68
-57
@@ -9,121 +9,127 @@ debug_load = os.environ.get('SD_LOAD_DEBUG', None)
|
||||
|
||||
|
||||
def guess_by_size(fn, current_guess):
|
||||
new_guess = None
|
||||
if os.path.isfile(fn) and fn.endswith('.safetensors'):
|
||||
size = round(os.path.getsize(fn) / 1024 / 1024)
|
||||
if (size > 0 and size < 128):
|
||||
shared.log.warning(f'Model size smaller than expected: file="{fn}" size={size} MB')
|
||||
elif (size >= 316 and size <= 324) or (size >= 156 and size <= 164): # 320 or 160
|
||||
shared.log.warning(f'Model detected as VAE model, but attempting to load as model: file="{fn}" size={size} MB')
|
||||
return 'VAE'
|
||||
new_guess = 'VAE'
|
||||
elif (size >= 2002 and size <= 2038): # 2032
|
||||
return 'Stable Diffusion 1.5'
|
||||
new_guess = 'Stable Diffusion 1.5'
|
||||
elif (size >= 3138 and size <= 3142): #3140
|
||||
return 'Stable Diffusion XL'
|
||||
new_guess = 'Stable Diffusion XL'
|
||||
elif (size >= 3361 and size <= 3369): # 3368
|
||||
return 'Stable Diffusion Upscale'
|
||||
new_guess = 'Stable Diffusion Upscale'
|
||||
elif (size >= 4891 and size <= 4899): # 4897
|
||||
return 'Stable Diffusion XL Inpaint'
|
||||
new_guess = 'Stable Diffusion XL Inpaint'
|
||||
elif (size >= 4970 and size <= 4976): # 4973
|
||||
return 'Stable Diffusion 2' # SD v2 but could be eps or v-prediction
|
||||
new_guess = 'Stable Diffusion 2' # SD v2 but could be eps or v-prediction
|
||||
elif (size >= 5791 and size <= 5799): # 5795
|
||||
return 'Stable Diffusion XL Refiner'
|
||||
new_guess = 'Stable Diffusion XL Refiner'
|
||||
elif (size > 5692 and size < 5698) or (size > 4134 and size < 4138) or (size > 10362 and size < 10366) or (size > 15028 and size < 15228):
|
||||
return 'Stable Diffusion 3'
|
||||
new_guess = 'Stable Diffusion 3'
|
||||
elif (size >= 6420 and size <= 7220): # 6420, IustriousRedux is 6541, monkrenRealisticINT_v10 is 7217
|
||||
return 'Stable Diffusion XL'
|
||||
new_guess = 'Stable Diffusion XL'
|
||||
elif (size >= 9791 and size <= 9799): # 9794
|
||||
return 'Stable Diffusion XL Instruct'
|
||||
new_guess = 'Stable Diffusion XL Instruct'
|
||||
elif (size >= 18414 and size <= 18420): # sd35-large aio
|
||||
return 'Stable Diffusion 3'
|
||||
new_guess = 'Stable Diffusion 3'
|
||||
elif (size >= 20000 and size <= 40000):
|
||||
return 'FLUX'
|
||||
return current_guess
|
||||
new_guess = 'FLUX'
|
||||
if debug_load:
|
||||
shared.log.trace(f'Autodetect: method=size file="{fn}" size={size} previous="{current_guess}" current="{new_guess}"')
|
||||
return new_guess or current_guess
|
||||
|
||||
|
||||
def guess_by_name(fn, current_guess):
|
||||
new_guess = None
|
||||
if 'instaflow' in fn.lower():
|
||||
return 'InstaFlow'
|
||||
new_guess = 'InstaFlow'
|
||||
elif 'segmoe' in fn.lower():
|
||||
return 'SegMoE'
|
||||
new_guess = 'SegMoE'
|
||||
elif 'hunyuandit' in fn.lower():
|
||||
return 'HunyuanDiT'
|
||||
new_guess = 'HunyuanDiT'
|
||||
elif 'hdm-xut' in fn.lower():
|
||||
return 'hdm'
|
||||
new_guess = 'hdm'
|
||||
elif 'pixart-xl' in fn.lower():
|
||||
return 'PixArt Alpha'
|
||||
new_guess = 'PixArt Alpha'
|
||||
elif 'stable-diffusion-3' in fn.lower():
|
||||
return 'Stable Diffusion 3'
|
||||
new_guess = 'Stable Diffusion 3'
|
||||
elif 'stable-cascade' in fn.lower() or 'stablecascade' in fn.lower() or 'wuerstchen3' in fn.lower() or ('sotediffusion' in fn.lower() and "v2" in fn.lower()):
|
||||
if devices.dtype == torch.float16:
|
||||
shared.log.warning('Stable Cascade does not support Float16')
|
||||
return 'Stable Cascade'
|
||||
new_guess = 'Stable Cascade'
|
||||
elif 'pixart-sigma' in fn.lower():
|
||||
return 'PixArt Sigma'
|
||||
new_guess = 'PixArt Sigma'
|
||||
elif 'sana' in fn.lower():
|
||||
return 'Sana'
|
||||
new_guess = 'Sana'
|
||||
elif 'lumina-next' in fn.lower():
|
||||
return 'Lumina-Next'
|
||||
new_guess = 'Lumina-Next'
|
||||
elif 'lumina-image-2' in fn.lower():
|
||||
return 'Lumina 2'
|
||||
new_guess = 'Lumina 2'
|
||||
elif 'kolors' in fn.lower():
|
||||
return 'Kolors'
|
||||
new_guess = 'Kolors'
|
||||
elif 'auraflow' in fn.lower() or 'pony-v7' in fn.lower():
|
||||
return 'AuraFlow'
|
||||
new_guess = 'AuraFlow'
|
||||
elif 'cogview3' in fn.lower():
|
||||
return 'CogView 3'
|
||||
new_guess = 'CogView 3'
|
||||
elif 'cogview4' in fn.lower():
|
||||
return 'CogView 4'
|
||||
new_guess = 'CogView 4'
|
||||
elif 'meissonic' in fn.lower():
|
||||
return 'Meissonic'
|
||||
new_guess = 'Meissonic'
|
||||
elif 'monetico' in fn.lower():
|
||||
return 'Monetico'
|
||||
new_guess = 'Monetico'
|
||||
elif 'omnigen2' in fn.lower():
|
||||
return 'OmniGen2'
|
||||
new_guess = 'OmniGen2'
|
||||
elif 'omnigen' in fn.lower():
|
||||
return 'OmniGen'
|
||||
new_guess = 'OmniGen'
|
||||
elif 'sd3' in fn.lower():
|
||||
return 'Stable Diffusion 3'
|
||||
new_guess = 'Stable Diffusion 3'
|
||||
elif 'hidream' in fn.lower():
|
||||
return 'HiDream'
|
||||
new_guess = 'HiDream'
|
||||
elif 'chroma' in fn.lower() and 'xl' not in fn.lower():
|
||||
return 'Chroma'
|
||||
new_guess = 'Chroma'
|
||||
elif 'flux' in fn.lower() or 'flex.1' in fn.lower():
|
||||
size = round(os.path.getsize(fn) / 1024 / 1024) if os.path.isfile(fn) else 0
|
||||
if size > 11000 and size < 16000:
|
||||
shared.log.warning(f'Model detected as FLUX UNET model, but attempting to load a base model: file="{fn}" size={size} MB')
|
||||
return 'FLUX'
|
||||
new_guess = 'FLUX'
|
||||
elif 'flex.2' in fn.lower():
|
||||
return 'FLEX'
|
||||
new_guess = 'FLEX'
|
||||
elif 'cosmos-predict2' in fn.lower():
|
||||
return 'Cosmos'
|
||||
new_guess = 'Cosmos'
|
||||
elif 'f-lite' in fn.lower():
|
||||
return 'FLite'
|
||||
new_guess = 'FLite'
|
||||
elif 'wan' in fn.lower():
|
||||
return 'WanAI'
|
||||
new_guess = 'WanAI'
|
||||
if 'chronoedit' in fn.lower():
|
||||
return 'ChronoEdit'
|
||||
new_guess = 'ChronoEdit'
|
||||
elif 'bria' in fn.lower():
|
||||
return 'Bria'
|
||||
new_guess = 'Bria'
|
||||
elif 'qwen' in fn.lower():
|
||||
return 'Qwen'
|
||||
new_guess = 'Qwen'
|
||||
elif 'nextstep' in fn.lower():
|
||||
return 'NextStep'
|
||||
new_guess = 'NextStep'
|
||||
elif 'kandinsky-2-1' in fn.lower():
|
||||
return 'Kandinsky 2.1'
|
||||
new_guess = 'Kandinsky 2.1'
|
||||
elif 'kandinsky-2-2' in fn.lower():
|
||||
return 'Kandinsky 2.2'
|
||||
new_guess = 'Kandinsky 2.2'
|
||||
elif 'kandinsky-3' in fn.lower():
|
||||
return 'Kandinsky 3.0'
|
||||
new_guess = 'Kandinsky 3.0'
|
||||
elif 'hunyuanimage3' in fn.lower() or 'hunyuanimage-3' in fn.lower():
|
||||
return 'HunyuanImage3'
|
||||
new_guess = 'HunyuanImage3'
|
||||
elif 'hunyuanimage' in fn.lower():
|
||||
return 'HunyuanImage'
|
||||
new_guess = 'HunyuanImage'
|
||||
elif 'x-omni' in fn.lower():
|
||||
return 'X-Omni'
|
||||
new_guess = 'X-Omni'
|
||||
elif 'sdxl-turbo' in fn.lower() or 'stable-diffusion-xl' in fn.lower():
|
||||
return 'Stable Diffusion XL'
|
||||
return current_guess
|
||||
new_guess = 'Stable Diffusion XL'
|
||||
if debug_load:
|
||||
shared.log.trace(f'Autodetect: method=name file="{fn}" previous="{current_guess}" current="{new_guess}"')
|
||||
return new_guess or current_guess
|
||||
|
||||
|
||||
def guess_by_diffusers(fn, current_guess):
|
||||
@@ -160,22 +166,27 @@ def guess_by_diffusers(fn, current_guess):
|
||||
if v is not None and v.__name__ == pipeline.__name__:
|
||||
if is_quant:
|
||||
k = f'{k} SDNQ'
|
||||
if debug_load:
|
||||
shared.log.trace(f'Autodetect: method=diffusers file="{fn}" previous="{current_guess}" current="{k}"')
|
||||
return k, v
|
||||
return current_guess, None
|
||||
|
||||
|
||||
def guess_variant(fn, current_guess):
|
||||
new_guess = None
|
||||
if 'inpaint' in fn.lower():
|
||||
if current_guess == 'Stable Diffusion':
|
||||
return 'Stable Diffusion Inpaint'
|
||||
new_guess = 'Stable Diffusion Inpaint'
|
||||
elif current_guess == 'Stable Diffusion XL':
|
||||
return 'Stable Diffusion XL Inpaint'
|
||||
new_guess = 'Stable Diffusion XL Inpaint'
|
||||
elif 'instruct' in fn.lower():
|
||||
if current_guess == 'Stable Diffusion':
|
||||
return 'Stable Diffusion Instruct'
|
||||
new_guess = 'Stable Diffusion Instruct'
|
||||
elif current_guess == 'Stable Diffusion XL':
|
||||
return 'Stable Diffusion XL Instruct'
|
||||
return current_guess
|
||||
new_guess = 'Stable Diffusion XL Instruct'
|
||||
if debug_load:
|
||||
shared.log.trace(f'Autodetect: method=variant file="{fn}" previous="{current_guess}" current="{new_guess}"')
|
||||
return new_guess or current_guess
|
||||
|
||||
|
||||
def detect_pipeline(f: str, op: str = 'model'):
|
||||
|
||||
@@ -14,6 +14,7 @@ debug = os.environ.get('SD_LOAD_DEBUG', None) is not None
|
||||
unspecified = object()
|
||||
vae_scale_override = {
|
||||
'WanPipeline': 16,
|
||||
'ChronoEditPipeline': 16,
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -47,7 +47,6 @@ pipelines = {
|
||||
'WanAI': getattr(diffusers, 'WanPipeline', None),
|
||||
'Qwen': getattr(diffusers, 'QwenImagePipeline', None),
|
||||
'HunyuanImage': getattr(diffusers, 'HunyuanImagePipeline', None),
|
||||
'ChronoEdit': getattr(diffusers, 'WanImageToVideoPipeline', None),
|
||||
# dynamically imported and redefined later
|
||||
'Meissonic': getattr(diffusers, 'DiffusionPipeline', None),
|
||||
'Monetico': getattr(diffusers, 'DiffusionPipeline', None),
|
||||
@@ -59,6 +58,7 @@ pipelines = {
|
||||
'hdm': getattr(diffusers, 'DiffusionPipeline', None),
|
||||
'X-Omni': getattr(diffusers, 'DiffusionPipeline', None),
|
||||
'HunyuanImage3': getattr(diffusers, 'DiffusionPipeline', None),
|
||||
'ChronoEdit': getattr(diffusers, 'DiffusionPipeline', None),
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user