mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 01:04:32 +02:00
Merge pull request #4918 from QualiaRain/fix/ui-misc-guards
Fix parse_metadtaa typo, None-desc crash, and malformed-input crashes in UI/misc
This commit is contained in:
@@ -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"]}"')
|
||||
|
||||
|
||||
@@ -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')
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
@@ -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}')
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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 = """
|
||||
<table class="simple-table sortable-table" data-sortable="true" data-default-sort-key="name" data-default-sort-order="asc" data-sort-key="name" data-sort-order="asc">
|
||||
|
||||
@@ -68,7 +68,10 @@ def ar_change(ar, width, height):
|
||||
if ar == 'AR':
|
||||
return gr.update(), gr.update()
|
||||
try:
|
||||
(w, h) = [float(x) for x in ar.split(':')]
|
||||
parts = [float(x) for x in ar.split(':')]
|
||||
if len(parts) != 2:
|
||||
raise ValueError(f"Expected 2 values, got {len(parts)}")
|
||||
w, h = parts
|
||||
except Exception as e:
|
||||
log.warning(f"Invalid aspect ratio: {ar} {e}")
|
||||
return gr.update(), gr.update()
|
||||
|
||||
+2
-1
@@ -53,7 +53,8 @@ def save_video_atomic(images, filename, video_type: str = 'none', duration: floa
|
||||
frames = interpolate_frames(images, count=interpolate, scale=scale, pad=pad, change=change)
|
||||
fourcc = "mp4v"
|
||||
h, w, _c = frames[0].shape
|
||||
video_writer = cv2.VideoWriter(filename, fourcc=cv2.VideoWriter_fourcc(*fourcc), fps=len(frames)/duration, frameSize=(w, h))
|
||||
fps = max(1.0, len(frames) / duration) if duration > 0 else 30.0
|
||||
video_writer = cv2.VideoWriter(filename, fourcc=cv2.VideoWriter_fourcc(*fourcc), fps=fps, frameSize=(w, h))
|
||||
for i in range(len(frames)):
|
||||
img = cv2.cvtColor(frames[i], cv2.COLOR_RGB2BGR)
|
||||
video_writer.write(img)
|
||||
|
||||
Reference in New Issue
Block a user