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] - 'dict' object has no attribute 'strip'

crafter312 opened this issue · comments

Description

I recently installed the ComfyUI node version of SD Prompt Reader. It worked perfectly at first, but over the last couple of days, I have started to encounter a weird error that prevents me from using the node at all. If I hook up the node as I want to use it (described below) and then hit "Queue Prompt," I get a nasty red error that says:

Error occurred when executing SDPromptReader: 'dict' object has no attribute 'strip'

As I'm new to using this set of custom nodes, it's always possible that I just did something stupid and/or set something up wrong. I'm not entirely sure what version of this node pack I'm using, as I was not able to find the version number in ComfyUI. However, I made sure that I was using whatever the most up-to-date version available to ComfyUI was at the time of writing this bug report.

Reproduction steps

My general workflow in this case is one set up for the hires fix of an image from a previous workflow, with its metadata still intact and everything.

  1. Add the SD Prompt Reader node to your workflow.
  2. Drag and drop an image (generated from a previous workflow and otherwise unmodified) into the SD Prompt Reader node.
  3. Attach the "image" output to your upscaler, which in my case consisted of an Upscale Image (using Model) node, followed by a 0.5 upscale and a tiled VAE encoder.
  4. Add two CLIPTextEncode nodes to your workflow, and convert the text widgets in both to inputs. These should then of course be connected to your kSampler node.
  5. Connect the "positive" and "negative" SD Prompt Reader outputs each to one of the text inputs from your CLIPTextEncode nodes.
  6. Convert the "seed" widget in your kSampler node to an input, and connect the "seed" output of your SD Prompt Reader node to this new input.
  7. Make sure the rest of your workflow is good to go, and then hit the Queue Prompt button.
  8. Bask in the glory of the angry red error that should pop up on your screen.

Image file

SDPromptReader

Version

1.3.3

OS

Windows

Tool

ComfyUI

Please post your original image here or send it to my email.

Here's the image I've been testing with:

MedievalCastle_00002_

The workflow in the image above doesn't seem to include a Prompt Reader Node. What I see is that you're reading data from text files and splitting it.

Firstly, since you're directly reading data from text files, your image metadata doesn't contain any prompt or setting data. Therefore, the SD Prompt Reader won't be able to read any data in any case.

I guess you may have uploaded the wrong image or want to read data you previously obtained through text files. Unfortunately, I have to inform you that this won't work.

In summary, for the SD Prompt Reader to work properly, the Prompt Reader Node itself should be a part of your workflow, or you should use a Prompt Saver Node to save your image instead. Personally, I would recommend using the Prompt Saver Node to ensure the maximum compatibility.

The image I included is the one I was trying to load with a Prompt Reader node in a different workflow. I split the image generation and upscaling processes into different workflows, with the idea being that I would load a generated image into my upscaling workflow and extract the generation data (mostly the seed) from it using a Prompt Reader node.

I didn't realize that my whole text file setup meant that there was no prompt saved in the metadata, so you're right about that part. Is that what's causing the Prompt Reader node to freak out?

Regardless, I'll take your advice and use a Prompt Saver node in my generation workflow. In that case, I have one brief question— How does the Prompt Saver node treat seeds for batch images? A latent image with batch_size>1 has a single "seed," but then each image in the batch has its own seed. Does the Prompt Saver node give each image in the batch the same seed, or is it able to extract the correct seed from each individual image in the batch?

Thank you so much for the help! I should be able to work around the issue with your suggestions. Apologies then for the false alarm bug report.

In ComfyUI, image metadata doesn't store prompts and settings (unless you use the Prompt Saver Node). Instead, it stores the entire workflow. The Prompt Reader works by tracing back from the Image Saver or KSampler until it traverses the entire workflow. In most cases, it can trace back to prompts and parameters. The Prompt Reader crashed because it mistakenly thought it was reading parameters, but in your particular case, it was reading 'a node pointing to another node, ultimately pointing to a file path' .

About batch_size, although it's possible to retrieve parameters like seed and batch_size, it won't tell you about which image in the sequence it refers to lol. So, I can't tell you the exact seed, I can only tell you the value you entered in the KSampler.