Skip to content

Commit

Permalink
Merge pull request #287 from zero01101/testing
Browse files Browse the repository at this point in the history
updates hardcoded schedulers to API call for webUI 1.9.3
  • Loading branch information
zero01101 committed Apr 27, 2024
2 parents f12703a + 42dfd01 commit b2dab98
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 16 deletions.
19 changes: 3 additions & 16 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -137,20 +137,7 @@
<label>Sampler:</label>
<div id="sampler-ac-select"></div>
<label>Scheduler:</label>
<br />
<select
id="schedulerSelect"
name="schedulerSelect"
onchange="changeScheduler()">
<option value="Automatic" selected="selected">Automatic</option>
<option value="Uniform">Uniform</option>
<option value="Karras">Karras</option>
<option value="Exponential">Exponential</option>
<option value="Polyexponential">Polyexponential</option>
<option value="SGM Uniform">SGM Uniform</option>
</select>
<!-- TODO scheduler isn't exposed via API that i can tell, un-hardcode when that's changed, add to localstorage settings, turn into magic type search autocomplete selectbox, disable selected attribute, all the stuff -->
<br />
<div id="scheduler-ac-select"></div>
<label for="seed">Seed (-1 for random):</label>
<br />
<input
Expand Down Expand Up @@ -352,7 +339,7 @@
<br />
<span id="version">
<a href="https://github.com/zero01101/openOutpaint" target="_blank">
v20240413.001
v20240427.001
</a>
<br />
<a
Expand Down Expand Up @@ -575,7 +562,7 @@

<!-- Content -->
<script src="js/prompt.js?v=7a1c68c" type="text/javascript"></script>
<script src="js/index.js?v=6e33053" type="text/javascript"></script>
<script src="js/index.js?v=5fc4006" type="text/javascript"></script>

<script
src="js/ui/floating/history.js?v=4f29db4"
Expand Down
41 changes: 41 additions & 0 deletions js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ async function testHostConnection() {
getSamplers();
getUpscalers();
getModels();
getSchedulers();
extensions.getExtensions(
controlNetModelAutoComplete,
controlNetModuleAutoComplete,
Expand Down Expand Up @@ -680,6 +681,11 @@ const samplerAutoComplete = createAutoComplete(
document.getElementById("sampler-ac-select")
);

const schedulerAutoComplete = createAutoComplete(
"Scheduler",
document.getElementById("scheduler-ac-select")
);

const upscalerAutoComplete = createAutoComplete(
"Upscaler",
document.getElementById("upscaler-ac-select")
Expand Down Expand Up @@ -1441,6 +1447,41 @@ async function getSamplers() {
}
}

async function getSchedulers() {
var url = document.getElementById("host").value + "/sdapi/v1/schedulers";

try {
const response = await fetch(url);
const data = await response.json();

schedulerAutoComplete.onchange.on(({value}) => {
stableDiffusionData.scheduler = value;
localStorage.setItem("openoutpaint/scheduler", value);
});

schedulerAutoComplete.options = data.map((scheduler) => ({
name: scheduler.label,
value: scheduler.label,
}));

if (localStorage.getItem("openoutpaint/scheduler") != null) {
schedulerAutoComplete.value = localStorage.getItem(
"openoutpaint/scheduler"
);
} else {
schedulerAutoComplete.value = data[0].name;
localStorage.setItem(
"openoutpaint/scheduler",
schedulerAutoComplete.value
);
}
stableDiffusionData.scheduler = schedulerAutoComplete.value;
} catch (e) {
console.warn("[index] Failed to fetch schedulers");
console.warn(e);
}
}

async function upscaleAndDownload(
download = false,
add_resource = false,
Expand Down

0 comments on commit b2dab98

Please sign in to comment.