Git Product home page Git Product logo

sd_extension-prompt_formatter's Introduction

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

sd_extension-prompt_formatter's People

Contributors

uwidev avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.