New upscale button for images; Fix a bug where the string seed would get appended with numbers

This commit is contained in:
cmdr2 2022-10-19 21:58:51 +05:30
parent e287df1320
commit 253d355bd2
2 changed files with 22 additions and 3 deletions

View File

@ -108,7 +108,7 @@
<ul id="editor-settings-entries" class="collapsible-content">
<li><table>
<tr><b class="settings-subheader">Image Settings</b></tr>
<tr class="pl-5"><td><label for="seed">Seed:</label></td><td><input id="seed" name="seed" size="10" value="30000"> <input id="random_seed" name="random_seed" type="checkbox" checked> <label for="random_seed">Random</label></td></tr>
<tr class="pl-5"><td><label for="seed">Seed:</label></td><td><input id="seed" name="seed" size="10" value="30000"> <input id="random_seed" name="random_seed" type="checkbox" checked><label for="random_seed">Random</label></td></tr>
<tr class="pl-5"><td><label for="num_outputs_total">Number of Images:</label></td><td><input id="num_outputs_total" name="num_outputs_total" value="1" size="1"> <label><small>(total)</small></label> <input id="num_outputs_parallel" name="num_outputs_parallel" value="1" size="1"> <label for="num_outputs_parallel"><small>(in parallel)</small></label></td></tr>
<tr class="pl-5"><td><label for="stable_diffusion_model">Model:</label></td><td>
<select id="stable_diffusion_model" name="stable_diffusion_model">

View File

@ -369,7 +369,8 @@ function showImages(reqBody, res, outputContainer, livePreview) {
let buttons = [
{ text: 'Use as Input', on_click: onUseAsInputClick },
{ text: 'Download', on_click: onDownloadImageClick },
{ text: 'Make Similar Images', on_click: onMakeSimilarClick }
{ text: 'Make Similar Images', on_click: onMakeSimilarClick },
{ text: 'Upscale', on_click: onUpscaleClick, filter: (req, img) => !req.use_upscale }
]
// include the plugins
@ -445,6 +446,24 @@ function onMakeSimilarClick(req, img) {
createTask(newTaskRequest)
}
function onUpscaleClick(req, img) {
let newTaskRequest = getCurrentUserRequest()
const imageSeed = img.getAttribute('data-seed')
newTaskRequest.reqBody = Object.assign({}, req, {
num_outputs: 1,
use_cpu: useCPUField.checked,
use_upscale: upscaleModelField.value,
seed: imageSeed
})
newTaskRequest.numOutputsTotal = 1
newTaskRequest.batchCount = 1
newTaskRequest.seed = newTaskRequest.reqBody.seed
createTask(newTaskRequest)
}
// makes a single image. don't call this directly, use makeImage() instead
async function doMakeImage(task) {
if (task.stopped) {
@ -710,7 +729,7 @@ async function checkTasks() {
})
}
if (genSeeds) {
newTask.reqBody.seed = startSeed + (i * newTask.reqBody.num_outputs)
newTask.reqBody.seed = parseInt(startSeed) + (i * newTask.reqBody.num_outputs)
newTask.seed = newTask.reqBody.seed
} else if (newTask.seed !== newTask.reqBody.seed) {
newTask.seed = newTask.reqBody.seed