add nano-banana

Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
Vladimir Mandic
2025-11-13 13:14:55 -05:00
parent d8eadcb7c1
commit 4ffc1b6097
12 changed files with 156 additions and 11 deletions
+3
View File
@@ -88,6 +88,9 @@ def get_model_type(pipe):
model_type = 'hunyuanimage3'
elif 'HunyuanImage' in name:
model_type = 'hunyuanimage'
# cloud models
elif 'NanoBanana' in name:
model_type = 'nanobanana'
else:
model_type = name
return model_type
+2
View File
@@ -145,6 +145,8 @@ def task_specific_kwargs(p, model):
task_args['image'] = Image.new('RGB', (p.width, p.height), (0, 0, 0)) # monkey-patch so wan-i2i pipeline does not error-out on t2i
if ('WanVACEPipeline' in model_cls) and (p.init_images is not None) and (len(p.init_images) > 0):
task_args['reference_images'] = p.init_images
if ('GoogleNanoBananaPipeline' in model_cls) and (p.init_images is not None) and (len(p.init_images) > 0):
task_args['image'] = p.init_images[0]
if 'BlipDiffusionPipeline' in model_cls:
if len(p.init_images) == 0:
shared.log.error('BLiP diffusion requires init image')
+2
View File
@@ -129,6 +129,8 @@ def guess_by_name(fn, current_guess):
new_guess = 'Stable Diffusion XL'
elif 'stable-video-diffusion' in fn.lower():
new_guess = 'StableVideoDiffusion'
elif 'gemini-2.5-flash-image' in fn.lower():
new_guess = 'NanoBanana'
if debug_load:
shared.log.trace(f'Autodetect: method=name file="{fn}" previous="{current_guess}" current="{new_guess}"')
return new_guess or current_guess
+6
View File
@@ -49,6 +49,7 @@ pipe_switch_task_exclude = [
'HunyuanImagePipeline',
'AuraFlowPipeline',
'ChronoEditPipeline',
'GoogleNanoBananaPipeline',
]
i2i_pipes = [
'LEditsPPPipelineStableDiffusion', 'LEditsPPPipelineStableDiffusionXL',
@@ -421,6 +422,10 @@ def load_diffuser_force(model_type, checkpoint_info, diffusers_load_config, op='
from pipelines.model_xomni import load_xomni
sd_model = load_xomni(checkpoint_info, diffusers_load_config) # pylint: disable=assignment-from-none
allow_post_quant = False
elif model_type in ['NanoBanana']:
from pipelines.model_google import load_nanobanana
sd_model = load_nanobanana(checkpoint_info, diffusers_load_config)
allow_post_quant = False
except Exception as e:
shared.log.error(f'Load {op}: path="{checkpoint_info.path}" {e}')
if debug_load:
@@ -863,6 +868,7 @@ def load_diffuser(checkpoint_info=None, op='model', revision=None): # pylint: di
modelstats.analyze()
shared.log.info(f"Load {op}: family={shared.sd_model_type} time={timer.load.dct()} native={get_native(sd_model)} memory={memory_stats()}")
shared.opts.save(silent=True)
class DiffusersTaskType(Enum):
+4 -1
View File
@@ -294,6 +294,7 @@ class ExtraNetworksPage:
subdirs['Distilled'] = 1
subdirs['Quantized'] = 1
subdirs['Community'] = 1
subdirs['Cloud'] = 1
subdirs[diffusers_base] = 1
if self.name == 'style' and shared.opts.extra_networks_styles:
subdirs['Local'] = 1
@@ -313,11 +314,13 @@ class ExtraNetworksPage:
subdirs.move_to_end('Quantized', last=True)
if 'Community' in subdirs:
subdirs.move_to_end('Community', last=True)
if 'Cloud' in subdirs:
subdirs.move_to_end('Cloud', last=True)
subdirs_html = ''
for subdir in subdirs:
if len(subdir) == 0:
continue
if subdir in ['All', 'Local', 'Diffusers', 'Reference', 'Distilled', 'Quantized', 'Community']:
if subdir in ['All', 'Local', 'Diffusers', 'Reference', 'Distilled', 'Quantized', 'Community', 'Cloud']:
style = 'network-reference'
else:
style = 'network-folder'
+11 -8
View File
@@ -68,13 +68,6 @@ class ExtraNetworksPageCheckpoints(ui_extra_networks.ExtraNetworksPage):
else:
path = f'{v.get("path", "")}'
ready = reference_downloaded(url)
if not ready and shared.opts.offline_mode:
count['hidden'] += 1
continue
if ready:
count['ready'] += 1
tag = v.get('tags', '')
if tag in count:
count[tag] += 1
@@ -83,6 +76,16 @@ class ExtraNetworksPageCheckpoints(ui_extra_networks.ExtraNetworksPage):
else:
count['base'] += 1
ready = reference_downloaded(url)
version = "ready" if ready else "download"
if tag == 'cloud':
version = 'cloud'
if not ready and shared.opts.offline_mode:
count['hidden'] += 1
continue
if ready:
count['ready'] += 1
yield {
"type": 'Model',
"name": name,
@@ -97,7 +100,7 @@ class ExtraNetworksPageCheckpoints(ui_extra_networks.ExtraNetworksPage):
"info": {},
"metadata": {},
"description": v.get('desc', ''),
"version": "ready" if ready else "download",
"version": version,
"tags": tag,
}
shared.log.debug(f'Networks: type="reference" items={count}')