Skip to content
This repository was archived by the owner on Nov 27, 2024. It is now read-only.

Commit 10111e3

Browse files
committed
ImageToImage output to input support
1 parent 4ae24c8 commit 10111e3

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

OnnxStack.WebUI/Pages/StableDiffusion/ImageToImage.cshtml

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
await Html.RenderPartialAsync("_PromptOptionsForm", Model.Prompt);
4040
await Html.RenderPartialAsync("_SchedulerOptionsForm", Model.Options);
4141
}
42-
<div class="d-flex flex-column flex-grow-0 w-100" >
42+
<div class="d-flex flex-column flex-grow-0 w-100">
4343
<div class="d-flex flex-row gap-2 justify-content-end" autocomplete="off">
4444
<button type="button" class="btn-cancel btn btn-warning w-100" disabled>Cancel</button>
4545
<button id="btn-execute" type="button" class="btn btn-success w-100" disabled>Generate</button>
@@ -98,7 +98,7 @@
9898
</div>
9999
<div class="d-flex flex-row gap-2 pt-2">
100100
<button type="button" class="btn btn-sm btn-success w-100" disabled>Download</button>
101-
<button type="button" class="btn btn-sm btn-info w-100" disabled>Image To Image</button>
101+
<button type="button" class="btn btn-sm btn-info w-100" disabled>Image To Image</button>
102102
</div>
103103
</div>
104104
</script>
@@ -141,7 +141,7 @@
141141
<li><a class="dropdown-item" href="{{blueprintUrl}}" download="{{blueprintName}}">Download JSON</a></li>
142142
</ul>
143143
</div>
144-
<button type="button" class="btn btn-sm btn-info w-100" disabled>Image To Image</button>
144+
<button id="button-img2img" type="button" class="btn btn-sm btn-info w-100">Image To Image</button>
145145
</div>
146146
</div>
147147
</script>
@@ -233,7 +233,7 @@
233233
if (!validateForm(schedulerParameterForm))
234234
return;
235235
236-
const inputImageUrl = getInputImageUrl();
236+
const inputImageUrl = getImageUrl("#img-input");
237237
if (!inputImageUrl)
238238
return;
239239
@@ -338,19 +338,19 @@
338338
return +$("option:selected", textBoxHeight).val();
339339
}
340340
341-
const getInputImageUrl = () => {
342-
const imageName = getInputImageName();
341+
const getImageUrl = (img) => {
342+
const imageName = getImageName(img);
343343
if (!imageName)
344344
return null;
345345
346-
const inputImageUrl = $("#img-input").attr("src");
346+
const inputImageUrl = $(img).attr("src");
347347
if (!inputImageUrl)
348348
return null;
349349
return inputImageUrl.split("?")[0];
350350
}
351351
352-
const getInputImageName = () => {
353-
const inputImageName = $("#img-input").data("name");
352+
const getImageName = (img) => {
353+
const inputImageName = $(img).data("name");
354354
if (!inputImageName)
355355
return null;
356356
return inputImageName;
@@ -372,10 +372,18 @@
372372
}
373373
});
374374
375+
$(document).on("click", "#button-img2img", async function () {
376+
const outputImage = getImageName("#img-result");
377+
const outputImageUrl = getImageUrl("#img-result");
378+
if (outputImageUrl) {
379+
addInputResult(getWidth(), getHeight(), inputResultTemplate, { imageUrl: outputImageUrl, imageName: outputImage });
380+
buttonExecute.removeAttr("disabled");
381+
}
382+
});
375383
376384
const setInitialImage = () => {
377385
const image = $("#InitialImage_Name").val();
378-
if(!image)
386+
if (!image)
379387
return;
380388
381389
const imageUrl = $("#InitialImage_Url").val();
@@ -389,8 +397,8 @@
389397
}
390398
391399
const updateInputImageContainer = () => {
392-
const url = getInputImageUrl();
393-
const name = getInputImageName();
400+
const url = getImageUrl("#img-input");
401+
const name = getImageName("#img-input");
394402
addInputResult(getWidth(), getHeight(), inputResultTemplate, { imageUrl: url, imageName: name });
395403
}
396404

0 commit comments

Comments
 (0)