prototype progress api#3722
prototype progress api#3722AUTOMATIC1111 merged 8 commits intoAUTOMATIC1111:masterfrom evshiron:feat/progress-api
Conversation
|
@Keavon This should work now. Call {
// other parameters
override_settings: {
show_progress_every_n_steps: 5,
},
}And |
|
That's wonderful, thank you @evshiron! I will have to give this a try shortly. (I assume it also works for the img2img endpoint and your |
Yes, it should as they share the same code, but I didn't try yet. Btw, Graphite looks amazing. |
|
Thanks @evshiron! Also real quick, before I port over the old Gradio "API" to this, I want to confirm all the features are supported. Since I have been pinned to that old version, I haven't tried out the API at all yet while I waited on this feature to be added (so thank you again for adding it!). If you don't mind, could you let me know if it currently provides access to all of these settings?:
Those are the settings we expose (some of them renamed for better user-facing intuitiveness.) |
|
I also just had a thought: in your API endpoint, it might be useful to add an optional parameter in the GET request that can disable |
|
To be honest, I haven't tried all of the listed features, but the parameters in And after #3629, even options in So I would say these APIs should satisfy your need.
Yes, there was one, I will add it back. |
|
Perfect, thanks! I look forward to hooking it up as soon as I get a few hours free. Also, can this progress endpoint be used to check for server connectivity, without potentially interfering with the progress of another user that's currently generating an image? I have a feature that checks that it can reach the server when you type in an IP address/hostname, before it generates anything. I assume there isn't an actual "server status" endpoint yet which is why I am wondering if the status endpoint would be sufficient. Or if there might be any other sort of dummy endpoint, even if it returns a 400-level code at least I'd know the server exists. Ideally I'd like to also use that to query for server information, like available VRAM (so I can automatically pick a maximum resolution allowed for image generation). |
I am new to this project, but there is a
I send a HEAD request to I am doing an alternative UI too, but I don't know if a server status API will be needed, or maybe someone else to implement it. |
|
Looks good! I was thinking about the pros and cons of defaulting to showing the image automatically (with a skip option) or not showing it automatically (and requiring the opt-in send option). I came to the conclusion that it's probably better API design to maintain consistency and require it be opt-in:
That's basically three levels of That would mean renaming Do you have thoughts about that? |
|
My thought is that if we are calling APIs to generate images, we might already explicitly override some settings (for example if we want image preview, we set There might be changes when @AUTOMATIC1111 wants to merge this PR. |
|
I was thinking about this today, but I don't think spamming the backend with requests for an update is the correct thing. I understand that FastAPI comes with websocket support out of the box. What do you think about the client subscribing to a websocket and then the backend can push updates to the client in real time? The client also can control the rate of the updates by just ignoring the messages it doesn't want. |
This would probably be useful, but I'd suggest keeping both as options so different use cases can benefit from the simplicity of polling or the efficiency of websockets. But I'd suggest leaving that for a separate PR so it doesn't block this getting merged. |
|
Thank you @AUTOMATIC1111! |
|
Thank you @AUTOMATIC1111 for your rework in 1497842. But I wonder we can add that back to EDIT: #3970 |
Yeah, you are right. Implementing this via WebSocket should be more performant and state of the art, but my ideas are:
|
|
@evshiron I'm working on integrating it with Graphite now by updating the old Gradio "API" endpoints. I realized I'm missing an endpoint to terminate the job, so I'm sticking with the Gradio endpoint on that for now (but if you might be willing, that would be superb if you could do another PR to add that endpoint, or anyone else who might be reading this). I hooked it all up but I'm seeing a response of This is running the commit Initial request:Progress request:Thanks for the assistance! |
|
@Keavon I roll back to that commit and it works on my end. I use a |
|
I try your parameters and they work too. Try adding some logging around here? stable-diffusion-webui/modules/api/api.py Line 190 in 060ee5d See also here: stable-diffusion-webui/modules/sd_samplers.py Line 106 in 060ee5d |
current_image = None
print("shared.state.current_image:", shared.state.current_image, "req.skip_current_image:", req.skip_current_image)
if shared.state.current_image and not req.skip_current_image:
current_image = encode_pil_to_base64(shared.state.current_image)It spams this when generating: if opts.show_progress_every_n_steps > 0 and shared.state.sampling_step % opts.show_progress_every_n_steps == 0:
print("shared.parallel_processing_allowed:", shared.parallel_processing_allowed)
if not shared.parallel_processing_allowed:
shared.state.current_image = sample_to_image(decoded)Spams this: |
|
stable-diffusion-webui/modules/shared.py Line 107 in 060ee5d Oh well, my graphics card isn't that good so I have WebUI has support for stable-diffusion-webui/modules/ui.py Line 280 in 060ee5d I am going to see how that support can be integrated in the API part. |
|
Ah, that makes sense! Too bad that's currently a limitation. I have just enough VRAM (8 GB) for it to be viable to turn that flag off since it ~2-4x's the computation time, I found. But for larger images (approaching 1 megapixel) it breaks. Thank you for looking into that, I really appreciate it! Happy to help test with my hardware wherever I can be of assistance. |
|
Made a new PR #3970. |
|
I pulled your PR and it looks like everything is working now. Thank you for that! I guess now I just need the terminate endpoint and I'll have feature parity. I wonder if you plan to add a terminate feature to your UI so that'd be in line with your efforts? I could also file an issue and hope someone else takes it on— or I can poke into it myself once I'm not so busy after Halloween, although I don't know this codebase or Python at all. Anyways, thank you again for this :) |
|
@Keavon I made a prototype interrupt API here: https://github.com/evshiron/stable-diffusion-webui/tree/feat/interrupt-api If you are in a hurry you may want to try that out. Naive implementation though. |
Splendid, that works well so far as I can tell. And I appreciate the simplicity of the mere four lines of code. Is there anything else you'd need to change about it before opening a PR? |
I'm using this too now, thanks. But the downside is that it adds... |
|
How about I currently don't have a motivation for system status API though, and choosing which status to return seems to be a pain. |
I don't know, it feels too simple to be a PR. Added in #4025. |
That's a good idea, and seems to work so far. Thanks for the suggestion. Thanks also for opening that PR, hopefully both can be merged soon! |
* Add new translations New settings option New extras tab option * Add adjust_steps_if_invalid to find next valid step for ddim uniform sampler * Testing with API added * Update zh_CN.json update translation content to 35c45df * webui.sh: no automatic git pull * Fix latent upscale highres fix AUTOMATIC1111#3888 * Revert "Add cleanup after training" This reverts commit 3ce2bfd. * Added image conditioning to latent upscale. Only comuted if the mask weight is not 1.0 to avoid extra memory. Also includes some code cleanup. * Add missing info on hypernetwork/embedding model log Mentioned here: AUTOMATIC1111#1528 (comment) Also group the saving into one * Fix dataset still being loaded even when training will be skipped * img2img test template and setUp added * extras test template added * Add PNG Info endpoint * Fix space * add postprocess call for scripts * rename french translation to be in line with others * add translators to codeowners with their respective translation files * fix progress response model * add description for state field * update progress response model * Re-add explicit device move * preview current image when opts.show_progress_every_n_steps is enabled * Fix German Localization * Read hypernet strength from PNG info. * allow skip current image in progress api * Italian localization (extended) [Requires Feedback] This is my first version of an alternative localization into Italian language which is a follow-up of the current localization file made by @EugenioBuffo (AUTOMATIC1111#3725), which I thanks, and of my discussion "Italian localization (git newbie)" (AUTOMATIC1111#3633) which covers the main user interface, all the current the Extensions and Scripts, with the following exceptions: txt2img2img (I got errors therefore I removed it from my local installation of SD Web UI) Parameter Sequencer (not installed locally) Booru tag autocompletion (not installed locally) Saving steps of the sampling process (not installed locally) I do not forecast to translate the above scripts in the short period, unless I will install them locally on my machine. I beg your pardon if I am brutally overwriting the originally submitted file but I find quite exhausting to edit and append over a thousand lines of code to the original file. If this is mandatory, then I will delete this commit and start a new one amending the original it_IT.json file. It is for sure not perfect and there are some translations that can be improved, therefore I wish to invite @EugenioBuffo and any other Italian mother language person willing give advice and to help to review this extensive translation . I look forward read any feedback from the community and developers. Thank you. * Final commit for october (19:22) / 22 * Update ar_AR.json * fix broken hires fix * 更新 zh_CN.json * launch tests from launch.py with --tests commandline argument * always add --api when running tests * shorten Hypernetwork strength in infotext and omit it when it's the default value. * rework AUTOMATIC1111#3722 to not introduce duplicate code * Replaced master branch fix with updated fix. * fix broken progress api by previous rework * fix current image in progress api when parallel processing enabled * Update zh_CN.json * Include PLMS in adjust steps as it also can fail in the same way * 长文本添加逗号 * add optimizer save option to shared.opts * We have duplicate linear now * resolve conflicts * add resrgan 8x, allow use 1x and up to 8x extra models, move BSRGAN model, add nearest * 更新 zh_CN.json * feat: add app started callback * Settings to select VAE * Forgot to add this folder * re-order content to match the dump Deprecated content was moved to the bottom to keep (somehow) backwards capability. * update new content * Change VAE search order and thus priority * Update zh_CN.json putting back the sign * Localization Italian - Updates and additions Updated localization with the latest version of these Scripts/Extensions: animator v6 StylePile Alpha Canvas Changed the description for the script "To Infinity and Beyond" (Verso l'infinito e oltre) from 'n' to 'Esegui n volte' (Run n times) Added localization for the 'Random' and 'Random Grid' scripts I changed both the title and the parameters Steps and CFG labels to make it clearer that the min/max order can be inverted. Added a few missing translations and character's corrections here and there. Still a work in progress but I will slowly fix wrong thing when I find them. * Added "--clip-models-path" switch to avoid using default "~/.cache/clip" and enable to run under unprivileged user without homedir * Fix non-square full resolution inpainting. * Add callbacks and param objects * add callback cleardown * Add callback to sd_samplers * docs: add python doc (?) not sure if this available... * prototype interrupt api * Extend extras image cache with upscale_first arg * 更新 zh_CN.json * Denoising strength * Update zh_CN.json update tag complete. * Fix typo from previous commit * Update ko_KR.json Added KR support for Dynamic Prompts extension - https://github.com/mkco5162/sd-dynamic-prompts * Checkpoint cache by combination key of checkpoint and vae * Italian localization - Updated a few terms I've updated a few terms and descriptions. Waiting for review and, hopefully, approval. * Added TI training optimizations option to use xattention optimizations when training option to unload vae when training * 修改争议部分 * outpainting * 将无法本地化的内容移到底部 * inpaint * 更新 zh_CN.json * bug修复 文本太长,遮挡提示框 * Fix VAE refresh button stretching out From AUTOMATIC1111#3986 (comment) * Added some extension KR support Supported extensions https://github.com/adieyal/sd-dynamic-prompts https://github.com/yfszzx/stable-diffusion-webui-images-browser https://github.com/DominikDoom/a1111-sd-webui-tagcomplete https://github.com/lilly1987/AI-WEBUI-scripts-Random * 更新 zh_CN.json * Fixed minor bug when unloading vae during TI training, generating images after training will error out * add initial version of the extensions tab fix broken Restart Gradio button * add requirements for GitPython * disable access to extension stuff for non-local servers * fix scripts I broke with the extension tab changes * fix the error with extension tab not working because of the previous commit * Add Extension Manager strings Since it's fixed and working I'm updating the translations * Italian localization - Updates Extensions Added translations of the new Extensions tab, and a few corrections to some previously translated descriptions/terms. * Add PNG info to pngs only if option is enabled. * make save dir if save dir is not exists * Update zh_CN.json * Update zh_CN.json * Update localizations/zh_CN.json Co-authored-by: dtlnor <dtlnor@hotmail.com> * Update localizations/zh_CN.json Co-authored-by: dtlnor <dtlnor@hotmail.com> * Added Available tab to extensions UI. * Unload sd_model before loading the other * Deleted extra it_IT localization Deleted it_IT localization file outside localization folder as it was not intentionally committed * Removed duplicated string from it_IT localization Removed "Peso dei bordi del punto focale" duplicated string from "Focal point edges weight" * Update localizations/zh_CN.json Co-authored-by: liggest <43201720+liggest@users.noreply.github.com> * make launch.py run installers for extensions that have ones add some more classes to safety module for an extension * add PYTHONPATH for extension's install.py * Update requirements.txt * Italian localization - Additions and updates Added translations for these Extensions/Scripts: Dynamic Prompts Alpha Canvas Artists to study Aesthetic Score Added a few missing translations and corrected some others. Updated to the latest Extension management tool version. While I was able to translate in the statistics the text "Time taken:" because the timing itself is a separate label, I couldn't do the same with the labels "Torch active/reserved: 3881/3892 MiB" and "Sys VRAM: 4859/8192 MiB (59.31%)" because the values (memory, percentage) are embedded in the labels (or perhaps I am not enough acknowledged to be sure I am doing it right simply translating the text). * Update zh_CN.json include new changes * re-order json content * Update zh_CN.json * Update zh_CN.json * Update KR translation More strings in the Extensions tab * fix API returning extra stuff in base64 encoded iamges for AUTOMATIC1111#3972 * Update de_DE.json * Fixed misspelled word on it_IT * Class Name typo and add descriptions to fields. * Update class name and assign back to vars * Release processing resources after it finishes * Update for extensions tab and other minor fizes First commit of november. Extensions tab localized and other minor translations fixes. To other portuguese users: se você tiver sugestões de melhores traduções conforme uso, favor entrar em contato ou enviar PRs referentes a localização. Também seria bem-vindo lusófonos de outros países, caso queiram discutir uma convergência entre diferentes variações do portguês. * prompts_from_file: allow random seeds to be preserved for the list of prompts * rename the seed option from AUTOMATIC1111#4146 * fix for extensions' javascript not loading * Reload VAE without reloading sd checkpoint * switch to gradio 3.8 * fix: should invoke callback as well in api only mode * Save VAE provided by cmd_opts.vae_path * Update ko_KR.json New options in scripts * remove duplicate code from AUTOMATIC1111#3970 * Allow saving "before-highres-fix. (AUTOMATIC1111#4150) * Save image/s before doing highres fix. * do not unnecessarily run VAE one more time when saving intermediate image with hires fix * fix AUTOMATIC1111#3986 breaking --no-half-vae * Update ko_KR.json Fix some changed setting strings and added new ones * resolve conflicts * first revert * now add * pt_BR minor issue with lat comma and a few translation tweaks * Italian localization - Additions and Updates Updated localization with the latest version of these Scripts/Extensions: unprompted (new script) img2tiles random random grid Some new options in the Extras and Settings have been translated too. * fix: Add required parameter to API extras route * New strings, some tweaks and fixes * Italian localization - Additions and Updates (fix typos) Updated localization with the latest version of these Scripts/Extensions: unprompted (new) img2tiles random random grid Some new options in the Extras and Settings have been translated too. P.S.: I fixed a couple of typos. By mistake I uploaded this file also in the main branch of my fork and didn't know how to revert the commit. Sorry for the mess. * Inpaint at full resolution * unify translation style * Update zh_CN.json - re-order some element - update new content * polish translation content * 更新 zh_CN.json * Separate .optim file from model * use hash to check valid optim * polish translation content * Update localizations/zh_CN.json Co-authored-by: dtlnor <dtlnor@hotmail.com> * Update localizations/zh_CN.json Co-authored-by: dtlnor <dtlnor@hotmail.com> * 将无法本地化的内容移到底部 * Delete it_IT.json * 部分无法本地化内容的替代方案 * Fixed misspelled word * 更新 zh_CN.json * Update Traditional Chinese (zh_TW) localisation JSON * Update zh_CN.json - update new content - polish some translation * fix: correct default val of upscale_first to False * Apply missing translations to Traditional Chinese (zh_TW) localisation JSON * fix: loading models without vae from cache * Lift extras generate button a la AUTOMATIC1111#4246. * do not mess with components' visibility for scripts; instead create group components and show/hide those; this will break scripts that create invisible components and rely on UI but the earlier i make this change the better * move option access checking to options class out of various places scattered through code * resolve conflict - first revert * I blame code autocomplete * apply * split before declaring file name * only save if option is enabled * Update shared.py * Rework dropout structure Tested with my own All HNs. * Add to UI * Add recommendations for dropout Co-authored-by: Dynamic <bradje@naver.com> Co-authored-by: Martin Cairns <4314538+MartinCairnsSQL@users.noreply.github.com> Co-authored-by: Vladimir Repin <32306715+mezotaken@users.noreply.github.com> Co-authored-by: dtlnor <dtlnor@hotmail.com> Co-authored-by: Mackerel <mackerel@chickatrice.com> Co-authored-by: random_thoughtss <random_thoughtss@proton.me> Co-authored-by: Muhammad Rizqi Nur <rizqinur2010@gmail.com> Co-authored-by: Bruno Seoane <brunoseoaneamarillo@gmail.com> Co-authored-by: AUTOMATIC <16777216c@gmail.com> Co-authored-by: evshiron <evshiron@gmail.com> Co-authored-by: Strothis <mathis.andreas.stroehlein@gmail.com> Co-authored-by: timntorres <timothynarcisotorres@gmail.com> Co-authored-by: Lunix <lunixwastaken@protonmail.com> Co-authored-by: Riccardo Giovanetti <29801031+Harvester62@users.noreply.github.com> Co-authored-by: Martucci <73501718+M-art-ucci@users.noreply.github.com> Co-authored-by: Modar M. Alfadly <modar.alfadly@gmail.com> Co-authored-by: batvbs <60730393+batvbs@users.noreply.github.com> Co-authored-by: batvbs <batvbs@qq.com> Co-authored-by: blackneoo <blackneoo@gmail.com> Co-authored-by: random-thoughtss <116161560+random-thoughtss@users.noreply.github.com> Co-authored-by: victorca25 <victorca25@users.noreply.github.com> Co-authored-by: Maiko Tan <maiko.tan.coding@gmail.com> Co-authored-by: mawr <mawr@mail.ru> Co-authored-by: DepFA <35278260+dfaker@users.noreply.github.com> Co-authored-by: Fampai <> Co-authored-by: k_sugawara <k_sugawara@radiu5.co.jp> Co-authored-by: Jairo Correa <jn.j41r0@gmail.com> Co-authored-by: Eugenio Buffo <58123757+EugenioBuffo@users.noreply.github.com> Co-authored-by: liggest <43201720+liggest@users.noreply.github.com> Co-authored-by: laksjdjf <aikasama@hotmail.co.jp> Co-authored-by: dhwz <dhwz@gmx.net> Co-authored-by: Keith Dreibelbis <keith@crittercism.com> Co-authored-by: Sihan Wang <31711261+shwang95@users.noreply.github.com> Co-authored-by: timntorres <116157310+timntorres@users.noreply.github.com> Co-authored-by: digburn <digburned@gmail.com> Co-authored-by: innovaciones <sonygarcia99@gmail.com> Co-authored-by: benlisquare <benlisquare> Co-authored-by: benlisquare <116663807+benlisquare@users.noreply.github.com> Co-authored-by: digburn <115176097+digburn@users.noreply.github.com>









No description provided.