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] - Incompatible with latest Stable Swarm UI

Shadetail opened this issue · comments

Description

It worked with images generated by Stable Swarm until I updated Stable Swarm, then it stopped working.
Also it would be great if it was possible to have option to read raw metadata, for robustness. auto1111 png info does this, and as a result, even an ancient version of png info can read metadata from latest Stable Swarm.

This is its metadata as read by auto1111 PNG Info:

parameters

{
"sui_image_params": {
"prompt": "(3D:1.45) creature, (spiky:1.45) (seashell:0.85) snail, (effervescent:1.5), diffuse clean, (cute animal:1.25), googlyeyes, (colorful swirls:1.15), spikes, vibrant colorful, (embedding :easynegative:1.45), wheel s",
"negativeprompt": "worst quality, low quality:1.4), technology, metal, cybernetic, vehicle, mechanical, fur coat, human, human face, chibi, clothes, attire, suit, gear, equipment, humanoid, shrek",
"images": 6,
"seed": 581626448,
"steps": 25,
"cfgscale": 4.0,
"width": 1024,
"height": 1024,
"initimagecreativity": 0.7,
"model": "SDXL/realcartoonXL_v5.safetensors",
"swarm_version": "0.5.9.0",
"date": "2023-12-01",
"generation_time": "0.00 (prep) and 6.49 (gen) seconds"
}
}

dpi

(96.012, 96.012)

Reproduction steps

No response

Image file

18-12-47-0-581626448

Version

1.3.4

OS

Windows

Tool

StableSwarmUI

It seems like the new version of StableSwarmUI has changed the structure of metadata and is completely incompatible with the old version. I will support the new version asap.

Previous versions of the metadata contained data in both StableSwarmUI format and A1111 format, thus it could be read by both StableSwarmUI and A1111. However, in this version, the StableSwarmUI data has been moved to the location originally reserved for storing A1111 data, therefore it can still be read by A1111, but in an incompatible format.

BTW, I just realised that the JPGs generated by StableSwarmUI only show some mojibake when read by pnginfo. Although I have added a new JPG parser, I think once the author of StableSwarmUI realises this issue, they will once again change the method of storing metadata.

Please try version 1.3.4.post1

I tried version 1.3.4.post1 and it works now! Thank you! ❤

BTW, I just realised that the JPGs generated by StableSwarmUI only show some mojibake when read by pnginfo. Although I have added a new JPG parser, I think once the author of StableSwarmUI realises this issue, they will once again change the method of storing metadata.
Could you clarify what this means?

@mcmonkey4eva
For instance, this is a JPG generated by StableSwarmUI 0.6.
flying whale, sky, clouds, photorealisti-sd_xl_base_10_09vaesafetensors-162473898
If you read it using A1111's PNG Info:
image

I’ve been using the same module and method as A1111 for reading and writing JPG UserComment, I would like to share some insights that might interest you.

The A1111 utilises piexif for managing UserComment (a module that hasn’t been updated in four years).
https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/master/modules/images.py#L559
And piexif encodes metadata using UTF-16BE and can only read metadata encoded in UTF-16BE.
https://github.com/hMatoba/Piexif/blob/master/piexif/helper.py#L15
But the ImageSharp you are using encodes metadata with System.Text.Encoding.Unicode, which is UTF-16LE.
https://github.com/SixLabors/ImageSharp/blob/main/src/ImageSharp/Metadata/Profiles/Exif/ExifEncodedStringHelpers.cs#L57
If you decide to make the metadata compatible with A1111, you might need to consider using Encoding.BigEndianUnicode to encode it yourself.

Oh, lol.
If you decide to make the metadata compatible with A1111 that's never been an intended feature target, and even if it was I'd rather submit a PR to auto to fix it than the other way around.
There's also https://github.com/NoCrypt/sd-fast-pnginfo this extension for auto webui which uses exifr and so won't have that problem anyway

I personally agree with your opinion, and this should be considered a legacy issue. I think A1111 should replace piexif with a different library.