Sign In

Fix broken dynamic prompts

4

May 6, 2025

(Updated: 7 months ago)

tool guide
Fix broken dynamic prompts

Promitis: Chronic pain in the prompts 🙃

Prologue

Been having some fun with good ol' Automatic1111 and dynamic prompts, but I found they're easily broken. Usually after downloading some Lora's.

Dynamic prompts use text between __double_underscores__ as its syntax for finding the dynamic prompts. It seems not all Lora creators are aware of this fact and so sometimes use double underscores in their naming schemes. Understandable (extra spaces (that aren't really spaces) are nice) but unfortunate.

Anyway, if such a Lora is part of the prompt, it will confuse the dynamic prompts extension and break it.

This will hopefully fix that, but no guarantee.

Fixing dynamic prompts (hopefully)

Basically it's just two steps / parts. Kind of.

  • Rename Lora files (Easier if you use a file rename utility that can search-replace text of multiple filenames at once. Not strictly necessary, but makes life a little bit easier)

  • Use sd-webui-adjust_lora_filename to adjust lora (metadata) "output name" to reflect it's current filename.

    sd-webui-adjust_lora_filename is an Extension for the AUTOMATIC1111 web UI. The Extension adjusts the output name in the metadata of the LoRA model file to the current stored file name.

That's it!

What follows is just the above in ultra-high-def details (Automatic1111, maybe Forge, never tried).

Rename Lora files (part 1)

  1. In Automatic1111's Lora browser, simply search for "__" (two underscores, without the quotes).

    • Thus only Lora with two (or more) underscores shows up

  2. Copy an offending Lora's path from it's "front card" / image (one of the buttons at the top of the "card", or what it's called), or open the card and copy its path from there.

  3. Open a regular file explorer, paste the path into it and navigate to that folder.

    • You should now see the Lora file (safetensor or pickletensor), as well as any related .info and preview image files (if any). Presumably these files have the same name (different file types ofc) with double underscores in them.

  4. Rename with search-replace, replacing "__" with "_". Or any other character(s) you like (not space afaik).

    • Alternatively, I guess you could just rename the one Lora file, delete the other related files and just let Automatic1111 re-download those afterwards.

    • Make sure there aren't any more underscores next to each other, in the unlikely(?) case someone uses three or more underscores!

Adjust Lora's "output name" (Part 2)

  1. Make a (mental) note of the Lora's file name or just copy it from the file explorer, from the step above

    • You should generally only need the first word or two, the Adjust Lora Filename extension doesn't like too long text pasted into it, and / or any spaces in it

  2. Go to the "Adjust LoRa Filename" tab

  3. Top-left there is a "Lora File List" drop-down list. Click the refresh button to the right of it.

  4. Start typing the name of the Lora in the drop-down list, or just paste it.

    • If pasting, you probably need to edit it to only be the first word or two or so to find it

  5. Find and select the (newly renamed) Lora in this drop-down list.

    • You should then see its old double-underscored filename in the box "Filename without extension from metadata", next to the big "Adjust" button. (Aka "output name")

  6. Click on the big "Adjust" button. This adjusts it to the current filename.

  7. Click on the big "Update" button, so you may verify that the new output name corresponds to the new filename.

  8. Go back to the txt2img tab and then the Lora browser.

    • If there are more Loras to fix, repeat from Part 1, step 2 on the next offending Lora

    • If you're finished, just refresh the Lora browser (and clear the search field).

That should be it.

Note

  • The Adjust Lora Filename extension makes a backup of the original Lora file with a ".bak" extension. You may or may not want to delete this.

  • When generating images, there will be warning messages in the Terminal: "Error while deserializing header: InvalidHeaderDeserialization". It will still work however. I'm not sure why this is.

  • I'm not sure if double underscores in the path to a Lora "counts". I just don't have those.

Postlogue

(that's a word, right?)

First, sorry it's somewhat wordy with very few pictures.

This is rewritten from a comment I made some 3 weeks back btw. I figured I could write it up.

EDITS: Just minor changes, formatting, grammar etc. Nothing major unless noted here.
EDIT: Shortened, hopefully improved text a bit. Oh and I guess it's "Epilogue" btw, but the "Postlogue" stays :)

-wrOngplanet

4