-
Notifications
You must be signed in to change notification settings - Fork 3k
web ui: display in-progress images #181
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -67,6 +67,9 @@ <h2 id="header">Stable Diffusion Dream Server</h2> | |
| <button type="button" id="reset-seed">↺</button> | ||
| <span>•</span> | ||
| <button type="button" id="reset-all">Reset to Defaults</button> | ||
| <br> | ||
| <label for="progress_images">Display in-progress images (slows down generation):</label> | ||
| <input type="checkbox" name="progress_images" id="progress_images"> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Quick consistency nitpick, can this be named progress-images?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure. The underscore was just for consistency with
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, this file seems to consistently use underscores for names, so I've left it as-is for now.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @TesseractCat are there still issues, or are we good to go? (I've re-requested a review. Hope that's etiquette.)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lstein could this get merged as-is, and then @TesseractCat can submit any further style nits in a followup PR? I'd like to stop needing to rebase this PR, and to get #182 in. |
||
| <div id="gfpgan"> | ||
| <p><em>The options below require the GFPGAN and ESRGAN packages to be installed</em></p> | ||
| <label title="Strength of the gfpgan (face fixing) algorithm." for="gfpgan_strength">GPFGAN Strength:</label> | ||
|
|
@@ -83,10 +86,13 @@ <h2 id="header">Stable Diffusion Dream Server</h2> | |
| </fieldset> | ||
| </form> | ||
| <div id="about">For news and support for this web service, visit our <a href="http://github.com/lstein/stable-diffusion">GitHub site</a></div> | ||
| <br> | ||
| <progress id="progress" value="0" max="1"></progress> | ||
| <div id="scaling-inprocess-message"> | ||
| <i><span>Postprocessing...</span><span id="processing_cnt">1/3</span></i> | ||
| <div id="progress-section"> | ||
| <progress id="progress-bar" value="0" max="1"></progress> | ||
| <br> | ||
| <img id="progress-image" src='data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg"/>'></img> | ||
| <div id="scaling-inprocess-message"> | ||
| <i><span>Postprocessing...</span><span id="processing_cnt">1/3</span></i> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| <div id="results"> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,14 +53,22 @@ function clearFields(form) { | |
| form.prompt.value = prompt; | ||
| } | ||
|
|
||
| const BLANK_IMAGE_URL = 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg"/>'; | ||
| async function generateSubmit(form) { | ||
| const prompt = document.querySelector("#prompt").value; | ||
|
|
||
| // Convert file data to base64 | ||
| let formData = Object.fromEntries(new FormData(form)); | ||
| formData.initimg = formData.initimg.name !== '' ? await toBase64(formData.initimg) : null; | ||
|
|
||
| document.querySelector('progress').setAttribute('max', formData.steps); | ||
| let progressSectionEle = document.querySelector('#progress-section'); | ||
| progressSectionEle.style.display = 'initial'; | ||
| let progressEle = document.querySelector('#progress-bar'); | ||
| progressEle.setAttribute('max', formData.steps); | ||
| let progressImageEle = document.querySelector('#progress-image'); | ||
| progressImageEle.src = BLANK_IMAGE_URL; | ||
|
|
||
| progressImageEle.style.display = {}.hasOwnProperty.call(formData, 'progress_images') ? 'initial': 'none'; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not just do
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should never do |
||
|
|
||
| // Post as JSON, using Fetch streaming to get results | ||
| fetch(form.action, { | ||
|
|
@@ -73,22 +81,31 @@ async function generateSubmit(form) { | |
| while (true) { | ||
| let {value, done} = await reader.read(); | ||
| value = new TextDecoder().decode(value); | ||
| if (done) break; | ||
| if (done) { | ||
| progressSectionEle.style.display = 'none'; | ||
| break; | ||
| } | ||
|
|
||
| for (let event of value.split('\n').filter(e => e !== '')) { | ||
| const data = JSON.parse(event); | ||
|
|
||
| if (data.event == 'result') { | ||
| noOutputs = false; | ||
| document.querySelector("#no-results-message")?.remove(); | ||
| appendOutput(data.files[0],data.files[1],data.config) | ||
| } else if (data.event == 'upscaling-started') { | ||
| document.getElementById("processing_cnt").textContent=data.processed_file_cnt; | ||
| document.getElementById("scaling-inprocess-message").style.display = "block"; | ||
| } else if (data.event == 'upscaling-done') { | ||
| document.getElementById("scaling-inprocess-message").style.display = "none"; | ||
| appendOutput(data.files[0],data.files[1],data.config); | ||
| progressEle.setAttribute('value', 0); | ||
| progressEle.setAttribute('max', formData.steps); | ||
| progressImageEle.src = BLANK_IMAGE_URL; | ||
| } else if (data.event == 'upscaling-started') { | ||
| document.getElementById("processing_cnt").textContent=data.processed_file_cnt; | ||
| document.getElementById("scaling-inprocess-message").style.display = "block"; | ||
| } else if (data.event == 'upscaling-done') { | ||
| document.getElementById("scaling-inprocess-message").style.display = "none"; | ||
| } else if (data.event == 'step') { | ||
| document.querySelector('progress').setAttribute('value', data.step.toString()); | ||
| progressEle.setAttribute('value', data.step); | ||
| if (data.url) { | ||
| progressImageEle.src = data.url; | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably should be
processed_file_count, also since this is intended to be consumed by JS, maybe this should beprocessedFileCount.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not related to this PR.