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

SD Api Pics extension, v.1.1 #596

Merged
merged 19 commits into from
Apr 8, 2023

Conversation

Brawlence
Copy link
Contributor

Lots of new things, gonna do a quick draft right now:

New features: API detection (press enter in the API box), more robust host address handing, VRAM management (model shuffling), separate image dimensions sliders for H&W, three different trigger modes (manual, interactive, always-on). The button to force/suppress the image on the next reply.
The model input is modified only in the interactive mode; other two are unaffected. The output pic description is presented differently for Picture-book / Adventure mode.

Connection check:
Connection feature demo

It's gonna strip the http(s):// part and the trailing / if present and also return the status when pressing Enter in that field

#533

@oobabooga
Copy link
Owner

It's looking great! I'm really excited for this.

extensions/sd_api_pictures/script.py Outdated Show resolved Hide resolved
extensions/sd_api_pictures/script.py Outdated Show resolved Hide resolved
extensions/sd_api_pictures/script.py Show resolved Hide resolved
extensions/sd_api_pictures/script.py Outdated Show resolved Hide resolved
@@ -105,7 +122,7 @@ def output_modifier(string):
"""
This function is applied to the model outputs.
"""
global pic_id, picture_response, streaming_state
global pic_id, picture_response, params

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice, if there is a way, to skip generating image when loading character which already has some history (now it generates picture, but it is not visible anywhere)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoa that's a nice catch! Can you list the exact steps to reproduce it?

Gonna think if I can actually override that behaviour

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Steps: Open some character, select Adventure mode, generate some text with images, switch character, switch back to one with images in history. This will issue new SD request and take some time to load as image is being generated. I use gallery extension for switching characters, but I think same happens when using Character tab.

r = response.json()
del response
del r

payload = {
"prompt": params['prompt_prefix'] + description,
"seed": -1,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to have seed, sampler_name, steps and cfg_scale configurable as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why you'd want to manually specify a seed when an AI is randomly generating the prompt?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some times same seed provides similar images on slightly different promts, it helps to get more consistent characters/visuals (or I am just seeing things)

@laughinggaschambers
Copy link

laughinggaschambers commented Mar 28, 2023

send_pictures always triggers generation in immersive mode. I believe the input prompt from send_pictures has the words send and picture in them. It might be good to filter out any prompts that uses send_pictures.
image

@Brawlence
Copy link
Contributor Author

Brawlence commented Mar 28, 2023

Okay, just a little checklist to keep my thoughts organized:


  • Planned (later):
    • BUG fix: character swapping triggering image generation (the image is immediately discarded)
    • request available samplers from SD
    • request and set availible MODELS from SD
    • Interactive mode flow change
      • Factor out the decider function
      • Allow the bot to refuse sending pics? w/ option to force anyway
      • In-chat hidden context button for 'illustrate'
    • Zoom-in feature for pics?

@laughinggaschambers
Copy link

using regenerate display "is typing" instead of "Is sending a picture"

@Brawlence Brawlence force-pushed the SDApiPics-improvement branch from 93ca91a to cde74e7 Compare March 29, 2023 06:55
@Brawlence
Copy link
Contributor Author

@laughinggaschambers that's unfortunate but I can't detect re-generations; so if you didn't like the image it sent you'll have to 'remove-last' and then 'generate' instead

@Brawlence Brawlence force-pushed the SDApiPics-improvement branch from f125b0d to efc2dc8 Compare March 29, 2023 08:49
@Brawlence Brawlence requested review from mcmonkey4eva and vaidasmaciulis and removed request for mcmonkey4eva and vaidasmaciulis March 29, 2023 10:03
@ARandomUserFromGithub
Copy link

ARandomUserFromGithub commented Mar 30, 2023

Hi, I have an issue with this plugin whereas the generated picture only quickly flashes and instantly disappears. Also the HTML displays nothing between the textbox divs.
`

<div class="message">
                <div class="circle-bot">
                  <img src="file/cache/AI Helper.png_cache.png">
                </div>
                <div class="text">
                  
                  
                </div>
              </div>

`

@vaidasmaciulis
Copy link

Okay, just a little checklist to keep my thoughts organized:

@Brawlence would it make sense to merge current PR and address remaining issues with separate PRs?

@oobabooga
Copy link
Owner

I agree with @vaidasmaciulis. There is no need for @Brawlence to overwhelm himself and try to fix everything at once. If there are not any new bugs in this PR that need to be addressed, I'd vote for merging it.

Cleaning address, checking connection, removed enable checkbox, added VRAM management
Changes to the interface, separate width/height sliders, mode of operations, button to suppress gen
Load parameters from settings.json, factored out VRAM management, initial state of checkbox influences VRAM use, also on selecting mode generation state & suppress/force button are updated
Patch the viewport size override (non-configurable as of now) and make it used local saved files if this option is set
& Uniquify filenames with int ( epoch seconds )
@Brawlence Brawlence force-pushed the SDApiPics-improvement branch from 399830b to 4872029 Compare April 2, 2023 02:37
Copy link
Contributor

@mcmonkey4eva mcmonkey4eva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Review submitted because I was tagged for it) there's only one potentially-breaking issue I see, the https part, and a lot of formatting, but that is stuff that can easily be worked on in followups

EDIT: gave it a testrun, worked flawlessly from the text-gen-webui side.
(The Auto WebUI side had errors, but, er, that's an auto webui issue unrelated. Extensions and API calls don't get along)

I'd say either good to pull now, or revert the change that breaks https support and then pull.
Other things to improve aren't blockers.

+make seed, sampler_name, steps and cfg_scale configurable via setting.json
@Brawlence
Copy link
Contributor Author

@vaidasmaciulis although nothing seems broken right now, for the last 3 or 4 days I couldn't really test the full extent of my changes because the flow kept breaking cause I want all the new features. I should have fixed the repo state, but oh well.

@oobabooga thanks but don't worry, I am not really overwhelmed

@mcmonkey4eva thanks, your feedback is invaluable!

via the UI. Defaults are still loaded from settings.json on startup
Trigger is factored out, also subject detection should now be broader
@Brawlence
Copy link
Contributor Author

Okay, finished with everything I wanted but readme. It's coming later™

@Brawlence Brawlence marked this pull request as ready for review April 2, 2023 07:10
@oobabooga
Copy link
Owner

In Manual mode, if I click on Force (Suppress) the picture response, the button changes to Suppress the picture response and the next reply is an image.

After that, the button text remains at Suppress the picture response, but the next generation returns text instead of another image.

@Brawlence
Copy link
Contributor Author

@oobabooga so the state changes correctly but the button is not reset after the generation. Hmmmm

Is there a way to access this button component outside of extension ui()'s scope?

@oobabooga
Copy link
Owner

You can turn it into a global variable (inside script.py), like with global my_button at the top of the ui() function.

@Brawlence
Copy link
Contributor Author

Strangely, although declaring it globally does allow me to change its label, the rendered button won't automatically adjust. So, as it is seemingly useless as a feedback for the user, I'm splitting it in two buttons. There won't be any reliable indication for the state of the next reply (picture/regular), but one can always force it with those.

@oobabooga oobabooga merged commit ffd102e into oobabooga:main Apr 8, 2023
@oobabooga
Copy link
Owner

I did some reorganizing/reformatting. Everything is working well on my end. I'm impressed at how engineered and detailed this extension has become. In particular, the new Picturebook is really fun to use.

Thanks for the update, @Brawlence :) (and feel free to submit new PRs in the future if you come up with further enhancements)

@Brawlence Brawlence deleted the SDApiPics-improvement branch April 9, 2023 23:33
Ph0rk0z pushed a commit to Ph0rk0z/text-generation-webui-testing that referenced this pull request Apr 17, 2023
@Brawlence Brawlence restored the SDApiPics-improvement branch April 17, 2023 14:13
@Brawlence Brawlence deleted the SDApiPics-improvement branch April 17, 2023 14:33
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.

6 participants