Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comma backtrack padding #2192

Merged

Conversation

hentailord85ez
Copy link
Collaborator

@hentailord85ez hentailord85ez commented Oct 10, 2022

Help improve coherency when having words that overlap token set bondaries.

When a token is at a boundary of 75 and it is not a comma, the last n tokens (n which can be spec. in config) are checked to see if any are a comma. If one is, tokens are padded starting from that comma to the next mult. of 75, and the tokens that were there before get moved into the next token set.

ex: {[74]=comma,[75]=orange},{[76]=hair} -> {[74]=comma,[75]=padding},{[76]=orange, [77]=hair}

Before:
without
After:
with

masterpiece, 1girl, cute, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , orange hair
Negative prompt: lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry, artist name
Steps: 20, Sampler: Euler, CFG scale: 11, Seed: 2347389309, Size: 512x640, Model hash: 925997e9, Eta: 0.67

Edit: if being merged, please squash merge. I fucked up on some buttons and have the default commit messages

@AUTOMATIC1111 AUTOMATIC1111 merged commit 5e2627a into AUTOMATIC1111:master Oct 11, 2022
Ending2015a added a commit to Ending2015a/stable-diffusion-webui that referenced this pull request Oct 13, 2022
* hypernetwork training mk1

* Update textual_inversion.py

* add embed embedding to ui

* Add pretty image captioning functions

* add embedding load and save from b64 json

* add alternate checkpoint hash source

* add encoder and decoder classes

* change json tensor key name

* correct case on embeddingFromB64

* source checkpoint hash from current checkpoint

* change source of step count

* add caption image with overlay

* change caption method

* remove braces from steps

* Add "Scale to" option to Extras

* add vae path args

* refactored the deepbooru module to improve speed on running multiple interogations in a row.  Added the option to generate deepbooru tags for textual inversion preproccessing.

* Textual Inversion: Added custom training image size and number of repeats per input image in a single epoch

* removed duplicate run_preprocess.click by creating run_preprocess_inputs list and appending deepbooru variable to input list if in scope

* Fixed progress bar output for epoch

* removed change in last commit, simplified to adding the visible argument to process_caption_deepbooru and it set to False if deepdanbooru argument is not set

* Add a pull request template

* --no-half-vae

* Custom Width and Height

* --no-half-vae pt2

* Textual Inversion: Added custom training image size and number of repeats per input image in a single epoch

* Fixed progress bar output for epoch

* Custom Width and Height

* maximize the view

* add pixel data footer

* convert back to rgb as some hosts add alpha

* Remove max_batch_count from ui.py

* Unlimited Token Works

Unlimited tokens actually work now. Works with textual inversion too. Replaces the previous not-so-much-working implementation.

* Pad beginning of textual inversion embedding

* Add back in output hidden states parameter

* Add ctrl+enter as a shortcut to quickly start a generation.

* Always show previous mask and fix extras_send dest

* change prebuilt wheel

* allow pascal onwards

* remove functorch

* Update requirements.txt

* Update requirements_versions.txt

* Add files via upload

* add swinir v2 support

* change vae loading method

* add eta noise seed delta option

* no to different messages plus fix using != to compare to None

* Simplify crop logic

* remove batch size restriction from X/Y plot

* Textual Inversion: Preprocess and Training will only pick-up image files

* add an option to not add watermark to created images

* Make cancel generate forever let the current gen complete (AUTOMATIC1111#2206)

* Refactored learning rate code

* Added .webp .bmp

* import time missing, added to deepbooru fixxing error on get_deepbooru_tags

* corrected tag return in get_deepbooru_tags

* update data dis[play style

* add dependency

* colour depth conversion fix

* added deepbooru settings (threshold and sort by alpha or likelyhood)

* add features, credit for Composable Diffusion

to readme

AUTOMATIC1111#2171

* added alpha sort and threshold variables to create process method in preprocessing

* Refresh list of models/ckpts upon hitting restart gradio in the settings pane

* use simple lcg in xor

* Make the ctrl+enter shortcut use the generate button on the current tab

* Added slider for deepbooru score threshold in settings

* Comma backtrack padding (AUTOMATIC1111#2192)

Comma backtrack padding

* replace duplicate code with a function

* Switched to exception handling

* Removed my local edits to checkpoint image generation

* Error if prompt missing SR token to prevent mis-gens (AUTOMATIC1111#2209)

* Reset init img in loopback at start of each batch (AUTOMATIC1111#2214)

Before a new batch would use the last image from the previous batch. Now
each batch will use the original image for the init image at the start of the
batch.

* revert sr warning

* add incorrect start word guard to xy_grid (AUTOMATIC1111#2259)

* fixes related to merge

* Correct list style, apply gen forever to both tabs, roll3 on both tabs

* context menus closure

* Handle different parameters for DPM fast & adaptive

* Remove debug code for checking that first sigma value is same after code cleanup

* Fix typo in comments

* Save some space

* Layout fix

* add a space holder

* space holder

* Update style.css

* Added 'suggestion' flair to suggestion template

* Added installation of pyngrok if needed

* Cleaned ngrok integration

* Added new line at the end of ngrok.py

* rename hypernetwork dir to hypernetworks to prevent clash with an old filename that people who use zip instead of git clone will have

* more renames

* Update README.md

* move list refresh to webui.py and add stdout indicating it's doing so

* become even stricter with pickles
no pickle shall pass
thank you again, RyotaK

* add codeowners file so stop the great guys who are collaborating on the project from merging in PRs.

* Add cross-attention optimization from InvokeAI

* Add cross-attention optimization from InvokeAI (~30% speed improvement on MPS)
* Add command line option for it
* Make it default when CUDA is unavailable

* Add check for psutil

* Add InvokeAI and lstein to credits, add back CUDA support

* Use apply_hypernetwork function

* change default for XY plot's Y to Nothing.

* add option to select hypernetwork modules when creating

* removed unneeded print

* produce error when training with medvram/lowvram enabled

* add an option to unload models during hypernetwork training to save VRAM

* prevent extra modules from being saved/loaded with hypernet

* bump gradio to 3.4.1

* triggers 'input' event when using arrow keys to edit attention

* move embedding logic to separate file

* remove embedding related image functions from images

* shift embedding logic out of textual_inversion

* remove old caption method

* apply lr schedule to hypernets

* correct conflict resolution typo

* update imports

* spacing

* Add files via upload

* add file based test

* reports that training with medvram is possible.

* resolved conflicts, moved settings under interrogate section, settings only show if deepbooru flag is enabled

* Prevent nans from failed float parsing from overwriting weights

* Update shared.py

Correct typo to "Unload VAE and CLIP from VRAM when training" in settings tab.

* Interrogate: add option to include ranks in output

Since the UI also allows users to specify ranks, it can be useful to show people what ranks are being returned by interrogate

This can also give much better results when feeding the interrogate results back into either img2img or txt2img, especially when trying to generate a specific character or scene for which you have a similar concept image

Testing Steps:

Launch Webui with command line arg: --deepdanbooru
Navigate to img2img tab, use interrogate DeepBooru, verify tags appears as before. Use "Interrogate CLIP", verify prompt appears as before
Navigate to Settings tab, enable new option, click "apply settings"
Navigate to img2img, Interrogate DeepBooru again, verify that weights appear and are properly formatted. Note that "Interrogate CLIP" prompt is still unchanged
In my testing, this change has no effect to "Interrogate CLIP", as it seems to generate a sentence-structured caption, and not a set of tags.

(reproduce changes from AUTOMATIC1111@6ed4faa)

* create dir for hypernetworks

* Truncate error text to fix service lockup / stall

What:
* Update wrap_gradio_call to add a limit to the maximum amount of text output

Why:
* wrap_gradio_call currently prints out a list of the arguments provided to the failing function.
   * if that function is save_image, this causes the entire image to be printed to stderr
    * If the image is large, this can cause the service to lock up while attempting to print all the text
 * It is easy to generate large images using the x/y plot script
 * it is easy to encounter image save exceptions, including if the output directory does not exist / cannot be written to, or if the file is too big
  * The huge amount of log spam is confusing and not particularly helpful

* just add the deepdanbooru settings unconditionally

* prevent SD model from loading when running in deepdanbooru process

* update environment-wsl2.yaml

* emergency fix

* Ensure the directory exists before saving to it

The directory for the images saved with the Save button may still not exist, so it needs to be created prior to opening the log.csv file.

* [img2imgalt] Fix seed & Allow batch.

* Typo fix in watermark hint.

* xy_grid: Find hypernetwork by closest name

* xy_grid: Confirm that hypernetwork options are valid before starting

* xy_grid: Refactor confirm functions

* change textual inversion tab to train
remake train interface to use tabs

* Account when lines are mismatched

* Remove duplicate artist from file

* fix iterator bug for AUTOMATIC1111#2295

* formatting

* formatting

* train: change filename processing to be more simple and configurable
train: make it possible to make text files with prompts
train: rework scheduler so that there's less repeating code in textual inversion and hypernets
train: move epochs setting to options

* deepbooru: added option to use spaces or underscores
deepbooru: added option to quote (\) in tags
deepbooru/BLIP: write caption to file instead of image filename
deepbooru/BLIP: now possible to use both for captions
deepbooru: process is stopped even if an exception occurs

* [1/?] [wip] Reintroduce opts.interrogate_return_ranks

looks functionally correct, needs testing

Needs particular testing care around whether the colon usage (:) will break anything in whatever new use cases were introduced by AUTOMATIC1111#2143

* [2/?] [wip] ignore OPT_INCLUDE_RANKS for training filenames

* [3/?] [wip] fix incorrect variable reference

still needs testing

* remove interrogate option I accidentally deleted

* add missing id property

* Merge branch 'master' of https://github.com/HunterVacui/stable-diffusion-webui

* Restore last generation params

* update AUTOMATIC1111#2336 to prevent reading params.txt when --hide-ui-dir-config option is enabled (for servers, since this will let some users access others' params)

Co-authored-by: AUTOMATIC <16777216c@gmail.com>
Co-authored-by: DepFA <35278260+dfaker@users.noreply.github.com>
Co-authored-by: Justin Maier <Zipp425@gmail.com>
Co-authored-by: ssysm <me@theeditorstudio.com>
Co-authored-by: JC_Array <justin318@att.net>
Co-authored-by: alg-wiki <alg.4chan@gmail.com>
Co-authored-by: Bepis <36346617+bbepis@users.noreply.github.com>
Co-authored-by: Ben <110583491+TheLastBen@users.noreply.github.com>
Co-authored-by: RW21 <rinze.watanabe.translation@gmail.com>
Co-authored-by: hentailord85ez <112723046+hentailord85ez@users.noreply.github.com>
Co-authored-by: Melan <alexleander91@gmail.com>
Co-authored-by: Vladimir Repin <32306715+mezotaken@users.noreply.github.com>
Co-authored-by: C43H66N12O12S2 <36072735+C43H66N12O12S2@users.noreply.github.com>
Co-authored-by: alg-wiki <47810160+alg-wiki@users.noreply.github.com>
Co-authored-by: Fampai <>
Co-authored-by: JC-Array <44535867+JC-Array@users.noreply.github.com>
Co-authored-by: ClashSAN <98228077+ClashSAN@users.noreply.github.com>
Co-authored-by: papuSpartan <mcgpapu@gmail.com>
Co-authored-by: Jairo Correa <jn.j41r0@gmail.com>
Co-authored-by: Kenneth <kenneth.mccarthy24@yahoo.com>
Co-authored-by: aperullo <18688190+aperullo@users.noreply.github.com>
Co-authored-by: Rory Grieve <rhrg500@gmail.com>
Co-authored-by: Martin Cairns <Martin.Cairns+github@gmail.com>
Co-authored-by: parsec501 <105080989+parsec501@users.noreply.github.com>
Co-authored-by: JamnedZ <zaguzinegor@gmail.com>
Co-authored-by: brkirch <brkirch@users.noreply.github.com>
Co-authored-by: nai-degen <92774204+nai-degen@users.noreply.github.com>
Co-authored-by: supersteve3d <39339941+supersteve3d@users.noreply.github.com>
Co-authored-by: Greg Fuller <gfuller23@gmail.com>
Co-authored-by: James Noeckel <jamesn8@cs.washington.edu>
Co-authored-by: aoirusann <yimodo.siki@gmail.com>
Co-authored-by: LunixWasTaken <Lunixwastaken@protonmail.com>
Co-authored-by: Milly <milly.ca@gmail.com>
Co-authored-by: Kalle <kalekkiorg@gmail.com>
Co-authored-by: Trung Ngo <codem01@gmail.com>
Symbiomatrix pushed a commit to Symbiomatrix/stable-diffusion-webui that referenced this pull request Sep 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants