diff --git a/extensions-builtin/sdnext-modernui b/extensions-builtin/sdnext-modernui index 146bd3643..e282300b3 160000 --- a/extensions-builtin/sdnext-modernui +++ b/extensions-builtin/sdnext-modernui @@ -1 +1 @@ -Subproject commit 146bd36431d3c38e3938054366934be91cce0ba6 +Subproject commit e282300b3d109580f0b32da1dcdf18c7c8504186 diff --git a/modules/processing_args.py b/modules/processing_args.py index 6f3305e62..fc7ba7e43 100644 --- a/modules/processing_args.py +++ b/modules/processing_args.py @@ -156,7 +156,10 @@ def task_specific_kwargs(p, model): 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 hasattr(p, 'orig_init_images') and (p.orig_init_images is not None) and len(p.orig_init_images) > 0: + task_args['images'] = p.orig_init_images + else: + task_args['images'] = p.init_images if ('GlmImagePipeline' in model_cls) and (p.init_images is not None) and (len(p.init_images) > 0): task_args['image'] = p.init_images if 'BlipDiffusionPipeline' in model_cls: diff --git a/pipelines/model_google.py b/pipelines/model_google.py index 91045fc53..62007cc6b 100644 --- a/pipelines/model_google.py +++ b/pipelines/model_google.py @@ -28,8 +28,6 @@ aspect_ratios_buckets = { def google_requirements(): from installer import install # , reload install('google-genai==1.52.0') - # install('pydantic==2.11.7', ignore=True, quiet=True) - # reload('pydantic', '2.11.7') def get_size_buckets(width: int, height: int) -> tuple[str, str]: @@ -55,15 +53,18 @@ class GoogleNanoBananaPipeline(): contents=prompt, ) - def img2img(self, prompt, image): + def img2img(self, prompt, images): from google import genai # pylint: disable=no-name-in-module - image_bytes = io.BytesIO() - image.save(image_bytes, format='JPEG') + image_bytes_list = [] + for image in images: + image_bytes = io.BytesIO() + image.save(image_bytes, format='JPEG') + image_bytes_list.append(genai.types.Part.from_bytes(data=image_bytes.getvalue(), mime_type='image/jpeg')) return self.client.models.generate_content( model=self.model, config=self.config, contents=[ - genai.types.Part.from_bytes(data=image_bytes.getvalue(), mime_type='image/jpeg'), + *image_bytes_list, prompt, ], ) @@ -108,7 +109,7 @@ class GoogleNanoBananaPipeline(): log.debug(f'Cloud: model="{self.model}" args={args_log}') return args - def __call__(self, prompt: list[str], width: int, height: int, image: Image.Image = None): + def __call__(self, prompt: list[str], width: int, height: int, images: list[Image.Image] = []): from google import genai # pylint: disable=no-name-in-module if self.client is None: args = self.get_args() @@ -125,13 +126,13 @@ class GoogleNanoBananaPipeline(): response_modalities=["IMAGE"], image_config=image_config ) - log.debug(f'Cloud: model="{self.model}" prompt="{prompt}" size={image_size} ar={aspect_ratio} image={image}') + log.debug(f'Cloud: model="{self.model}" prompt="{prompt}" size={image_size} ar={aspect_ratio} images={len(images) if images is not None else 0}') # log.debug(f'Cloud: config={self.config}') try: t0 = time.time() - if image is not None: - response = self.img2img(prompt, image) + if images is not None and len(images) > 0: + response = self.img2img(prompt, images) else: response = self.txt2img(prompt) t1 = time.time()