diff --git a/modules/caption/moondream3.py b/modules/caption/moondream3.py index 399836100..07866adba 100644 --- a/modules/caption/moondream3.py +++ b/modules/caption/moondream3.py @@ -171,8 +171,11 @@ def query(image: Image.Image, question: str, repo: str, stream: bool = False, if isinstance(response, dict): debug(f'LLM: handler=moondream3 response_type=dict keys={list(response.keys())}') if 'reasoning' in response: - reasoning_text = response['reasoning'].get('text', '')[:100] + '...' if len(response['reasoning'].get('text', '')) > 100 else response['reasoning'].get('text', '') - debug(f'LLM: handler=moondream3 reasoning="{reasoning_text}"') + reasoning_data = response.get('reasoning', {}) + if isinstance(reasoning_data, dict): + text = reasoning_data.get('text', '') + reasoning_text = text[:100] + '...' if len(text) > 100 else text + debug(f'LLM: handler=moondream3 reasoning="{reasoning_text}"') if 'answer' in response: debug(f'LLM: handler=moondream3 answer="{response["answer"]}"') diff --git a/modules/control/tile.py b/modules/control/tile.py index bc8ed8e60..b09ede7f8 100644 --- a/modules/control/tile.py +++ b/modules/control/tile.py @@ -21,9 +21,11 @@ def set_tile(image: Image.Image, x: int, y: int, tiled: Image.Image): def run_tiling(p: processing.StableDiffusionProcessing, input_image: Image.Image) -> processing.Processed: t0 = time.time() # prepare images - sx, sy = p.control_tile.split('x') - sx = int(sx) - sy = int(sy) + tile_parts = p.control_tile.split('x') + if len(tile_parts) != 2: + raise ValueError('Control Tile: invalid format, expected "SxS"') + sx = int(tile_parts[0]) + sy = int(tile_parts[1]) vae_scale_factor = sd_vae.get_vae_scale_factor() if sx <= 0 or sy <= 0: raise ValueError('Control Tile: invalid tile size') diff --git a/modules/extras.py b/modules/extras.py index de00e8cd4..8a414aa0e 100644 --- a/modules/extras.py +++ b/modules/extras.py @@ -242,7 +242,7 @@ def run_model_modules(model_type:str, model_name:str, custom_name:str, modules_sdxl.recipe.debug = debug loras = [l.strip() if ':' in l else f'{l.strip()}:1.0' for l in comp_lora.split(',') if len(l.strip()) > 0] - for lora, strength in [l.split(':') for l in loras]: + for lora, strength in [l.split(':', 1) for l in loras]: modules_sdxl.recipe.lora[lora] = float(strength) scheduler = sd_samplers.create_sampler(comp_scheduler, None) modules_sdxl.recipe.scheduler = scheduler.__class__.__name__ if scheduler is not None else None diff --git a/modules/image/metadata.py b/modules/image/metadata.py index 27a04473f..8242b2fe0 100644 --- a/modules/image/metadata.py +++ b/modules/image/metadata.py @@ -73,7 +73,7 @@ def parse_comfy_metadata(data: dict): def parse_invoke_metadata(data: dict): - def parse_metadtaa(): + def parse_metadata(): res = '' try: txt = data.get('invokeai_metadata', {}) @@ -86,7 +86,7 @@ def parse_invoke_metadata(data: dict): pass return res - metadata = parse_metadtaa() + metadata = parse_metadata() if len(metadata) > 0: parsed = f'App: InvokeAI{metadata}' log.info(f'Image metadata: {parsed}') diff --git a/modules/postprocess/yolo.py b/modules/postprocess/yolo.py index eabca9394..2d913ca84 100644 --- a/modules/postprocess/yolo.py +++ b/modules/postprocess/yolo.py @@ -531,7 +531,7 @@ class YoloRestorer(Detailer): def change_mode(self, dropdown, text): self.ui_mode = not self.ui_mode if self.ui_mode: - value = [val.split(':')[0].strip() for val in text.split(',')] + value = [val.split(':', 1)[0].strip() for val in text.split(',') if val.strip()] return gr.update(visible=True, value=value), gr.update(visible=False), gr.update(visible=True) else: value = ', '.join(dropdown) diff --git a/modules/ui_extra_networks_styles.py b/modules/ui_extra_networks_styles.py index 232bc83ce..1154b7b7f 100644 --- a/modules/ui_extra_networks_styles.py +++ b/modules/ui_extra_networks_styles.py @@ -14,7 +14,9 @@ class ExtraNetworksPageStyles(ui_extra_networks.ExtraNetworksPage): shared.prompt_styles.reload() def parse_desc(self, desc): - lines = desc.strip().split("\n") + if not isinstance(desc, str): + desc = '' + lines = desc.strip().split("\n") if desc else [] params = { 'name': '', 'description': '', 'prompt': '', 'negative': '', 'extra': '', 'wildcards': ''} found = '' for line in lines: diff --git a/modules/ui_models.py b/modules/ui_models.py index 789740f4d..6b161a0bd 100644 --- a/modules/ui_models.py +++ b/modules/ui_models.py @@ -32,8 +32,10 @@ def update_model_hashes(): yield from sd_models.update_model_hashes(model_type='checkpoint') -def create_models_table(rows: list = []): +def create_models_table(rows: list | None = None): from modules import sd_detect + if rows is None: + rows = [] rows = sorted(rows, key=lambda row: str(getattr(row, 'model_name', '')).lower()) html = """