receyuki / stable-diffusion-prompt-reader

A simple standalone viewer for reading prompts from Stable Diffusion generated image outside the webui.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] - Does not read Invoke 3 SDXL data

Void2258 opened this issue · comments

Description

Nothing comes up for images generated in Invoke 3 using SDXL. All fields show blank. "No data selected or unsupported format".

Image file

Example image:
28c4cac9-1c05-4f30-8341-cf47f94fe954
Yes I know the image is kinda bad; it was a test for my new card to see gen times.

Invoke metadata shown internally for comparison:
{
"app_version": "3.1.1",
"generation_mode": "sdxl_txt2img",
"positive_prompt": "supergirl flying through the sky, billowing cape, city background",
"negative_prompt": "Multiple, several, bad hands, extra arms",
"width": 1024,
"height": 1024,
"seed": 2507332253,
"rand_device": "cpu",
"cfg_scale": 7.5,
"steps": 25,
"scheduler": "ddpm",
"clip_skip": 0,
"model": {
"model_name": "dreamshaperXL10_alpha2Xl10",
"base_model": "sdxl",
"model_type": "main"
},
"controlnets": [],
"loras": [],
"positive_style_prompt": "Comic, drawn, animated, high quality, masterpiece, artgerm",
"negative_style_prompt": "Realistic, poor quality, warped, deformed"
}

Version

1.3.3Post1

OS

Windows

Tool

InvokeAI

To the @receyuki :

import re

def split_string(text):
    patterns = [r"(?<=,)\s*\([^)]+\)\s*(?=,)", r"\w+\s*\([^)]+\)\s*\w+"]
    matches = []
    for pattern in patterns:
        matches += re.findall(pattern, text)
    if matches:
        for match in matches:
            text = text.replace(match, "").strip()
    result = text.split(",")
    result = [item.strip() for item in result if item]
    result = matches + result
    return result

image_dict = {
    "invokeai_metadata": {
        "app_version": "3.1.1",
        "generation_mode": "sdxl_txt2img",
        "positive_prompt": "supergirl flying through the sky, billowing cape, city background",
        "negative_prompt": "Multiple, several, bad hands, extra arms",
        "width": 1024,
        "height": 1024,
        "seed": 2507332253,
        "rand_device": "cpu",
        "cfg_scale": 7.5,
        "steps": 25,
        "scheduler": "ddpm",
        "clip_skip": 0,
        "model": {
            "model_name": "dreamshaperXL10_alpha2Xl10",
            "base_model": "sdxl",
            "model_type": "main",
        },
        "controlnets": [],
        "loras": [],
        "positive_style_prompt": "Comic, drawn, animated, high quality, masterpiece, artgerm",
        "negative_style_prompt": "Realistic, poor quality, warped, deformed",
    }
}

def extract_image_prompt(image_data):
    data = image_data.get("invokeai_metadata")
    image_prompt = {
        "positive": split_string(data.get("positive_prompt")),
        "negative": split_string(data.get("negative_prompt")),
        "parameter": {
            "model": data.get("model", {}).get("model_name"),
            "sampler": data.get("scheduler"),
            "seed": data.get("seed"),
            "cfg": data.get("cfg_scale"),
            "steps": data.get("steps"),
            "size": f'{data.get("width")}x{data.get("height")}',
        },
    }
    return image_prompt


extract_image_prompt(image_dict)

output:

{
  "positive": ["supergirl flying through the sky", "billowing cape", "city background"],
  "negative": ["Multiple", "several", "bad hands", "extra arms"],
  "parameter": {
    "model": "dreamshaperXL10_alpha2Xl10",
    "sampler": "ddpm",
    "seed": 2507332253,
    "cfg": 7.5,
    "steps": 25,
    "size": "1024x1024"
  }
}

@Void2258
I've just realized that Invoke3 has a completely different metadata structure, and it can't even properly import images generated by Invoke2 lol. I will be adding support for Invoke3 in the next release.

Supposedly the import issues for invoke 2 into invoke 3 have been addressed in 3.2

Opens invoke 3 images, but almost everything is in a big blob in the bottom box (settingS).

However, now doesn't even respond to invoke 2 images being dragged in and just opens nothing if you try the browse function for them. Invoke 2 images open fine in older version.

About Invoke 2, please upload any images that cannot be read here. I have refactored the code for InvokeAI, so there may be new issues that were not present before.

For Invoke 3, as mentioned in the release notes, previous versions only extracted essential metadata. However, I believe some users may need additional data beyond the essentials, such as control nets or LoRAs. Therefore, I have decided to directly display the original settings. Simple mode will be a better choice if you only need essential metadata. Additionally, you can click on the text box in simple mode to copy a single parameter value.

It's all of my invoke 2 images. I have several hundred and while I haven't tried every single one, every one I have tried does not work. Here is just one item.

000327 199d5bbc 3701805154

I guess the thing with invoke 3 is there is more "essential" stuff, like style prompts, than there was before. So the big block at the end carries 99% of things and the other boxes look empty.

I must say, InvokeAI has made a mess of ensuring metadata compatibility, and once again, this image contains a format I've never seen before. I will fix this issue in beta2.

As for the new display format, you're right, style_prompt and refiner are making the settings very long. I thought the simple mode would be sufficient for most users, which is why I made this change. Additionally, in version 1.4.x, I will add an option to modify the default display mode so that users can have the simple mode as their default.

You might want to go to the invoke discord and discuss things with them. They are very responsive to feedback and willing to help out with issues.

I originally planned to wait for comfyUI node to be ready, but it seems like it might take a while, so I released a beta2.
https://github.com/receyuki/stable-diffusion-prompt-reader/releases/tag/v1.3.4-beta.2