Promptvision icon indicating copy to clipboard operation
Promptvision copied to clipboard

sd-parsers api changes

Open d3x-at opened this issue 2 years ago • 0 comments

Hello there!

Just a quick heads-up, the sd-parsers api will "soon(tm)" be changing a bit. (see dev0.4 branch). No real time estimate from my side though, maybe this year. ;-)

Quick mockup of what the code i found you using it might look like in the future:

from sd_parsers import ParserManager

parser_manager = ParserManager()

def test(image):
    exif = parser_manager.parse(image)
    if exif is None:
        raise Exception("No metadata found")

    positive_prompt = ", ".join(prompt.value for prompt in exif.prompts)
    if positive_prompt == "":
        positive_prompt = "No positive prompt found"

    negative_prompt = ", ".join(prompt.value for prompt in exif.negative_prompts)
    if negative_prompt == "":
        negative_prompt = "No negative prompt found"

    if exif.generator == "ComfyUI":
        print(exif.generator)
        print(exif.parameters["prompt"])
        print(exif.parameters["workflow"])
        metadata = exif.parameters
    else:
        metadata = exif.metadata

    print(positive_prompt, negative_prompt, metadata)

Have fun!

d3x-at avatar Oct 11 '23 22:10 d3x-at