fix cli+api: data-uri decode guards, mutable default, caption/ffprobe/palette IndexError guards

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
QualiaRain
2026-06-12 05:08:02 -04:00
parent 1cf715fac2
commit 584f2b84c4
5 changed files with 19 additions and 8 deletions
+5 -3
View File
@@ -21,7 +21,7 @@ all_images_by_type = {}
class Result():
def __init__(self, typ: str, fn: str, tag: str | None = None, requested: list = []):
def __init__(self, typ: str, fn: str, tag: str | None = None, requested: list = None):
self.type = typ
self.input = fn
self.output = ''
@@ -32,7 +32,7 @@ class Result():
self.tag = tag
self.tags = []
self.ops = []
self.steps = requested
self.steps = requested if requested is not None else []
def detect_blur(image: Image.Image):
@@ -163,7 +163,9 @@ def caption_image(res: Result, tag: str | None = None):
for t in res.tag.split(',')[::-1]:
tags.insert(0, t.strip())
pos = 0 if len(tags) == 0 else 1
tags.insert(pos, caption.split(' ')[1])
words = caption.split(' ')
if len(words) > 1:
tags.insert(pos, words[1])
tags = [t for t in tags if len(t) > 2]
if len(tags) > options.process.tag_limit:
tags = tags[:options.process.tag_limit]