feat(parser): add support for invokeai_metadata format
parent
117aa7fb27
commit
74382f25eb
|
|
@ -27,3 +27,7 @@ iib.db-wal
|
||||||
|
|
||||||
CLAUDE.md
|
CLAUDE.md
|
||||||
.claude/*
|
.claude/*
|
||||||
|
videos/启动&添加文件夹构建索引.mp4
|
||||||
|
videos/图像搜索和链接跳转.mp4
|
||||||
|
videos/ai智能文件整理.mp4
|
||||||
|
videos/skills安装&启动.mp4
|
||||||
|
|
|
||||||
|
|
@ -12,13 +12,17 @@ class InvokeAIParser:
|
||||||
def parse(clz, img: Image, file_path):
|
def parse(clz, img: Image, file_path):
|
||||||
if not clz.test(img, file_path):
|
if not clz.test(img, file_path):
|
||||||
raise Exception("The input image does not match the current parser.")
|
raise Exception("The input image does not match the current parser.")
|
||||||
raw_infos = json.loads(img.info["invokeai_graph"])
|
if 'invokeai_metadata' in img.info:
|
||||||
core_metadata = {}
|
core_metadata = json.loads(img.info['invokeai_metadata'])
|
||||||
for key in raw_infos['nodes']:
|
core_metadata.pop("canvas_v2_metadata", None)
|
||||||
if key.startswith("core_metadata"):
|
elif 'invokeai_graph' in img.info:
|
||||||
core_metadata = raw_infos['nodes'][key]
|
raw_infos = json.loads(img.info["invokeai_graph"])
|
||||||
break
|
core_metadata = {}
|
||||||
|
for key in raw_infos['nodes']:
|
||||||
|
if key.startswith("core_metadata"):
|
||||||
|
core_metadata = raw_infos['nodes'][key]
|
||||||
|
break
|
||||||
|
|
||||||
positive_prompt = core_metadata.get("positive_prompt", "None")
|
positive_prompt = core_metadata.get("positive_prompt", "None")
|
||||||
negative_prompt = core_metadata.get("negative_prompt", "None")
|
negative_prompt = core_metadata.get("negative_prompt", "None")
|
||||||
steps = core_metadata.get("steps", 'Unknown')
|
steps = core_metadata.get("steps", 'Unknown')
|
||||||
|
|
@ -60,6 +64,6 @@ class InvokeAIParser:
|
||||||
@classmethod
|
@classmethod
|
||||||
def test(clz, img: Image, file_path: str):
|
def test(clz, img: Image, file_path: str):
|
||||||
try:
|
try:
|
||||||
return 'invokeai_graph' in img.info
|
return 'invokeai_graph' in img.info or 'invokeai_metadata' in img.info
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return False
|
return False
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue