Remove excess spaces and convert nested brackets
 
 
 
Go to file
uwidev b843d73bd1 feat: convert redundant checkboxes to radio buttons
spaces to underscore, underscore to spaces, or ignore
2024-09-30 11:08:54 -07:00
demo Updated demo gif 2023-06-03 11:41:10 -07:00
javascript Javescript to move button into tools div row. 2023-05-08 19:25:48 -07:00
scripts feat: convert redundant checkboxes to radio buttons 2024-09-30 11:08:54 -07:00
tests feat: convert redundant checkboxes to radio buttons 2024-09-30 11:08:54 -07:00
.gitignore Version 1 commit 2023-04-24 20:21:27 -07:00
LICENSE Create LICENSE 2024-09-26 11:32:41 -07:00
README.md Update README.md 2023-06-03 19:00:18 +00:00
Twemoji.Mozilla.ttf Fixed font-emoji incompatibly on other browsers 2023-05-09 10:16:05 -07:00
install.py Overhauled technique for cleaning up the prompt and formatting it. 2023-04-26 23:30:58 -07:00
pyproject.toml Wildcard compatability for '_' to ' ' 2023-09-13 12:19:18 -07:00
style.css Fixed font-emoji incompatibly on other browsers 2023-05-09 10:16:05 -07:00

README.md

Demonstration

sd_extension-prompt_formatter

This is an extension for AUTOMATIC1111/stable-diffusion-webui that adds a magic button next to your prompt to make it look neat and "optimized." It does several things.

  1. Normalizes the characters to their standard equivalent (NFKC)
  2. Normalizes brackets to their minimum matching pair
  3. Removes excessive whitespace
  4. Properly spaces commas, bracketing, commas, and |
  5. Converts nested brackets ((a)) to a single bracket weight (a:1.21)

Works for txt2img and img2img for both positive and negative prompts.

Currenty as of commit 54d57c2 v0.3, may not respect escaped parenthesis and square brackets, and may crash the extension.

Example

Raw Prompt

photorealistic   photo of a handsome male (wizard  :1.2 <lora:LuisapHotlineStyle:0.5> <lora:ElegantHanfuRuqunStyle:0.2>    short beard, white wizard  shirt, (with golden    trim:0.8), (((bald))

Formatted

photorealistic photo of a handsome male (wizard:1.2), <lora:LuisapHotlineStyle:0.5> <lora:ElegantHanfuRuqunStyle:0.2> short beard, white wizard shirt, (with golden trim:0.8), (bald:1.21)

Raw Prompt

a, [[b, [c, [A:B], [A|B], [A :1.2 AND B :1.2]], e]]

Formatted

a, (b, (c, [A:B], [A|B], [A :1.2 AND B :1.2]:0.91), e:0.83)

Inspiration from taken from canisminor1990/sd-webui-kitchen-theme's prompt formatter.

Installation

  1. In your Stable Diffusion Web UI, navigate to Extensions > Install from URL
  2. Copy and paste this repository to the URL install

https://github.com/uwidev/sd_extension-prompt_formatter

  1. Install
  2. Go to the Installed tab and click Apply and restart UI

Other planned(?) features

  • take into account prompt editing (do not convert [from:to:when] 2023-04-27
  • fix: do not convert {} to () (wildcard fix) 2023-04-27
  • handle additional bracekt weighting within nested brackets e.g. ((A), (B)) => ((A, B)) => (A, B:1.21) 2023-04-27
  • Somehow magically resolve mixed bracketing (e.g. ([<1girl>]) who types their prompts like this?!1) 2023-04-27 maybe fixed?
  • Respect new lines (useful when splitting prompt on BREAK)
  • Further simplify [(a:0.91)] => (a:0.83), instead of ((a:0.91):0.91)
  • A Revert button just in case it formats it incorrectly (and my logic be funky) 🔼
  • Have moving networks to the back a option rather than always enforced.
  • Extension settings menu.
  • Option to convert token spaces to underscore
  • have an option multiple weighted tagged blocks into individual blocks? e.g. (A, B:1.2) => (A:1.2), (B:1.2)
  • Update the top right token counter so that it's not red on prompt format (need to learn javascript for that one it seems)
  • Option to normalize brackets to their maximum matching pair (e.g. (((a -> (((a)))
  • proper testing of prompts for faster development 2023-04-27