Skip to content

Commit e7ebb31

Browse files
authored
Merge pull request #4346 from vladmandic/dev
refresh branch
2 parents 618b196 + 0264400 commit e7ebb31

File tree

4 files changed

+72
-58
lines changed

4 files changed

+72
-58
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
- fix: model type detection
1212
- fix: version detection when cloned with `.git` suffix
1313
- fix: init `sdnq` on video model load
14+
- fix: add vae scale override for chrono
15+
- fix: add tracing to model detection
1416
- ui: fix full-screen image viewer buttons with non-standard ui theme
1517
- ui: control tab show override section
1618

modules/sd_detect.py

Lines changed: 68 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -9,121 +9,127 @@
99

1010

1111
def guess_by_size(fn, current_guess):
12+
new_guess = None
1213
if os.path.isfile(fn) and fn.endswith('.safetensors'):
1314
size = round(os.path.getsize(fn) / 1024 / 1024)
1415
if (size > 0 and size < 128):
1516
shared.log.warning(f'Model size smaller than expected: file="{fn}" size={size} MB')
1617
elif (size >= 316 and size <= 324) or (size >= 156 and size <= 164): # 320 or 160
1718
shared.log.warning(f'Model detected as VAE model, but attempting to load as model: file="{fn}" size={size} MB')
18-
return 'VAE'
19+
new_guess = 'VAE'
1920
elif (size >= 2002 and size <= 2038): # 2032
20-
return 'Stable Diffusion 1.5'
21+
new_guess = 'Stable Diffusion 1.5'
2122
elif (size >= 3138 and size <= 3142): #3140
22-
return 'Stable Diffusion XL'
23+
new_guess = 'Stable Diffusion XL'
2324
elif (size >= 3361 and size <= 3369): # 3368
24-
return 'Stable Diffusion Upscale'
25+
new_guess = 'Stable Diffusion Upscale'
2526
elif (size >= 4891 and size <= 4899): # 4897
26-
return 'Stable Diffusion XL Inpaint'
27+
new_guess = 'Stable Diffusion XL Inpaint'
2728
elif (size >= 4970 and size <= 4976): # 4973
28-
return 'Stable Diffusion 2' # SD v2 but could be eps or v-prediction
29+
new_guess = 'Stable Diffusion 2' # SD v2 but could be eps or v-prediction
2930
elif (size >= 5791 and size <= 5799): # 5795
30-
return 'Stable Diffusion XL Refiner'
31+
new_guess = 'Stable Diffusion XL Refiner'
3132
elif (size > 5692 and size < 5698) or (size > 4134 and size < 4138) or (size > 10362 and size < 10366) or (size > 15028 and size < 15228):
32-
return 'Stable Diffusion 3'
33+
new_guess = 'Stable Diffusion 3'
3334
elif (size >= 6420 and size <= 7220): # 6420, IustriousRedux is 6541, monkrenRealisticINT_v10 is 7217
34-
return 'Stable Diffusion XL'
35+
new_guess = 'Stable Diffusion XL'
3536
elif (size >= 9791 and size <= 9799): # 9794
36-
return 'Stable Diffusion XL Instruct'
37+
new_guess = 'Stable Diffusion XL Instruct'
3738
elif (size >= 18414 and size <= 18420): # sd35-large aio
38-
return 'Stable Diffusion 3'
39+
new_guess = 'Stable Diffusion 3'
3940
elif (size >= 20000 and size <= 40000):
40-
return 'FLUX'
41-
return current_guess
41+
new_guess = 'FLUX'
42+
if debug_load:
43+
shared.log.trace(f'Autodetect: method=size file="{fn}" size={size} previous="{current_guess}" current="{new_guess}"')
44+
return new_guess or current_guess
4245

4346

4447
def guess_by_name(fn, current_guess):
48+
new_guess = None
4549
if 'instaflow' in fn.lower():
46-
return 'InstaFlow'
50+
new_guess = 'InstaFlow'
4751
elif 'segmoe' in fn.lower():
48-
return 'SegMoE'
52+
new_guess = 'SegMoE'
4953
elif 'hunyuandit' in fn.lower():
50-
return 'HunyuanDiT'
54+
new_guess = 'HunyuanDiT'
5155
elif 'hdm-xut' in fn.lower():
52-
return 'hdm'
56+
new_guess = 'hdm'
5357
elif 'pixart-xl' in fn.lower():
54-
return 'PixArt Alpha'
58+
new_guess = 'PixArt Alpha'
5559
elif 'stable-diffusion-3' in fn.lower():
56-
return 'Stable Diffusion 3'
60+
new_guess = 'Stable Diffusion 3'
5761
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()):
5862
if devices.dtype == torch.float16:
5963
shared.log.warning('Stable Cascade does not support Float16')
60-
return 'Stable Cascade'
64+
new_guess = 'Stable Cascade'
6165
elif 'pixart-sigma' in fn.lower():
62-
return 'PixArt Sigma'
66+
new_guess = 'PixArt Sigma'
6367
elif 'sana' in fn.lower():
64-
return 'Sana'
68+
new_guess = 'Sana'
6569
elif 'lumina-next' in fn.lower():
66-
return 'Lumina-Next'
70+
new_guess = 'Lumina-Next'
6771
elif 'lumina-image-2' in fn.lower():
68-
return 'Lumina 2'
72+
new_guess = 'Lumina 2'
6973
elif 'kolors' in fn.lower():
70-
return 'Kolors'
74+
new_guess = 'Kolors'
7175
elif 'auraflow' in fn.lower() or 'pony-v7' in fn.lower():
72-
return 'AuraFlow'
76+
new_guess = 'AuraFlow'
7377
elif 'cogview3' in fn.lower():
74-
return 'CogView 3'
78+
new_guess = 'CogView 3'
7579
elif 'cogview4' in fn.lower():
76-
return 'CogView 4'
80+
new_guess = 'CogView 4'
7781
elif 'meissonic' in fn.lower():
78-
return 'Meissonic'
82+
new_guess = 'Meissonic'
7983
elif 'monetico' in fn.lower():
80-
return 'Monetico'
84+
new_guess = 'Monetico'
8185
elif 'omnigen2' in fn.lower():
82-
return 'OmniGen2'
86+
new_guess = 'OmniGen2'
8387
elif 'omnigen' in fn.lower():
84-
return 'OmniGen'
88+
new_guess = 'OmniGen'
8589
elif 'sd3' in fn.lower():
86-
return 'Stable Diffusion 3'
90+
new_guess = 'Stable Diffusion 3'
8791
elif 'hidream' in fn.lower():
88-
return 'HiDream'
92+
new_guess = 'HiDream'
8993
elif 'chroma' in fn.lower() and 'xl' not in fn.lower():
90-
return 'Chroma'
94+
new_guess = 'Chroma'
9195
elif 'flux' in fn.lower() or 'flex.1' in fn.lower():
9296
size = round(os.path.getsize(fn) / 1024 / 1024) if os.path.isfile(fn) else 0
9397
if size > 11000 and size < 16000:
9498
shared.log.warning(f'Model detected as FLUX UNET model, but attempting to load a base model: file="{fn}" size={size} MB')
95-
return 'FLUX'
99+
new_guess = 'FLUX'
96100
elif 'flex.2' in fn.lower():
97-
return 'FLEX'
101+
new_guess = 'FLEX'
98102
elif 'cosmos-predict2' in fn.lower():
99-
return 'Cosmos'
103+
new_guess = 'Cosmos'
100104
elif 'f-lite' in fn.lower():
101-
return 'FLite'
105+
new_guess = 'FLite'
102106
elif 'wan' in fn.lower():
103-
return 'WanAI'
107+
new_guess = 'WanAI'
104108
if 'chronoedit' in fn.lower():
105-
return 'ChronoEdit'
109+
new_guess = 'ChronoEdit'
106110
elif 'bria' in fn.lower():
107-
return 'Bria'
111+
new_guess = 'Bria'
108112
elif 'qwen' in fn.lower():
109-
return 'Qwen'
113+
new_guess = 'Qwen'
110114
elif 'nextstep' in fn.lower():
111-
return 'NextStep'
115+
new_guess = 'NextStep'
112116
elif 'kandinsky-2-1' in fn.lower():
113-
return 'Kandinsky 2.1'
117+
new_guess = 'Kandinsky 2.1'
114118
elif 'kandinsky-2-2' in fn.lower():
115-
return 'Kandinsky 2.2'
119+
new_guess = 'Kandinsky 2.2'
116120
elif 'kandinsky-3' in fn.lower():
117-
return 'Kandinsky 3.0'
121+
new_guess = 'Kandinsky 3.0'
118122
elif 'hunyuanimage3' in fn.lower() or 'hunyuanimage-3' in fn.lower():
119-
return 'HunyuanImage3'
123+
new_guess = 'HunyuanImage3'
120124
elif 'hunyuanimage' in fn.lower():
121-
return 'HunyuanImage'
125+
new_guess = 'HunyuanImage'
122126
elif 'x-omni' in fn.lower():
123-
return 'X-Omni'
127+
new_guess = 'X-Omni'
124128
elif 'sdxl-turbo' in fn.lower() or 'stable-diffusion-xl' in fn.lower():
125-
return 'Stable Diffusion XL'
126-
return current_guess
129+
new_guess = 'Stable Diffusion XL'
130+
if debug_load:
131+
shared.log.trace(f'Autodetect: method=name file="{fn}" previous="{current_guess}" current="{new_guess}"')
132+
return new_guess or current_guess
127133

128134

129135
def guess_by_diffusers(fn, current_guess):
@@ -160,22 +166,27 @@ def guess_by_diffusers(fn, current_guess):
160166
if v is not None and v.__name__ == pipeline.__name__:
161167
if is_quant:
162168
k = f'{k} SDNQ'
169+
if debug_load:
170+
shared.log.trace(f'Autodetect: method=diffusers file="{fn}" previous="{current_guess}" current="{k}"')
163171
return k, v
164172
return current_guess, None
165173

166174

167175
def guess_variant(fn, current_guess):
176+
new_guess = None
168177
if 'inpaint' in fn.lower():
169178
if current_guess == 'Stable Diffusion':
170-
return 'Stable Diffusion Inpaint'
179+
new_guess = 'Stable Diffusion Inpaint'
171180
elif current_guess == 'Stable Diffusion XL':
172-
return 'Stable Diffusion XL Inpaint'
181+
new_guess = 'Stable Diffusion XL Inpaint'
173182
elif 'instruct' in fn.lower():
174183
if current_guess == 'Stable Diffusion':
175-
return 'Stable Diffusion Instruct'
184+
new_guess = 'Stable Diffusion Instruct'
176185
elif current_guess == 'Stable Diffusion XL':
177-
return 'Stable Diffusion XL Instruct'
178-
return current_guess
186+
new_guess = 'Stable Diffusion XL Instruct'
187+
if debug_load:
188+
shared.log.trace(f'Autodetect: method=variant file="{fn}" previous="{current_guess}" current="{new_guess}"')
189+
return new_guess or current_guess
179190

180191

181192
def detect_pipeline(f: str, op: str = 'model'):

modules/sd_vae.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
unspecified = object()
1515
vae_scale_override = {
1616
'WanPipeline': 16,
17+
'ChronoEditPipeline': 16,
1718
}
1819

1920

modules/shared_items.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
'WanAI': getattr(diffusers, 'WanPipeline', None),
4848
'Qwen': getattr(diffusers, 'QwenImagePipeline', None),
4949
'HunyuanImage': getattr(diffusers, 'HunyuanImagePipeline', None),
50-
'ChronoEdit': getattr(diffusers, 'WanImageToVideoPipeline', None),
5150
# dynamically imported and redefined later
5251
'Meissonic': getattr(diffusers, 'DiffusionPipeline', None),
5352
'Monetico': getattr(diffusers, 'DiffusionPipeline', None),
@@ -59,6 +58,7 @@
5958
'hdm': getattr(diffusers, 'DiffusionPipeline', None),
6059
'X-Omni': getattr(diffusers, 'DiffusionPipeline', None),
6160
'HunyuanImage3': getattr(diffusers, 'DiffusionPipeline', None),
61+
'ChronoEdit': getattr(diffusers, 'DiffusionPipeline', None),
6262
}
6363

6464

0 commit comments

Comments
 (0)