Skip to content

Commit d5d684a

Browse files
committed
Fixes
1 parent c39743c commit d5d684a

File tree

2 files changed

+14
-18
lines changed

2 files changed

+14
-18
lines changed

examples/server/frontend.cpp

+8-13
Original file line numberDiff line numberDiff line change
@@ -328,19 +328,14 @@ const std::string html_content = R"xxx(
328328
const data = await response.json();
329329
330330
const select = document.getElementById('preview_mode');
331-
select.innerHTML = '';
332-
data.forEach(preview => {
333-
const option = document.createElement('option');
334-
option.value = preview;
335-
option.textContent = preview;
336-
select.appendChild(option);
337-
});
338-
if (!select.firstChild) {
339-
// preview isn't supported
340-
const option = document.createElement('option');
341-
option.value = "";
342-
option.textContent = "unsupported";
343-
select.appendChild(option);
331+
if (data) {
332+
select.innerHTML = '';
333+
data.forEach(preview => {
334+
const option = document.createElement('option');
335+
option.value = preview;
336+
option.textContent = preview;
337+
select.appendChild(option);
338+
});
344339
}
345340
}
346341

examples/server/main.cpp

+6-5
Original file line numberDiff line numberDiff line change
@@ -888,13 +888,13 @@ bool parseJsonPrompt(std::string json_str, SDParams* params) {
888888
}
889889
try {
890890
bool vae_tiling = payload["vae_tiling"];
891-
printf("VAE_tiling : %s", vae_tiling ? "true" : "false");
892891
if (params->ctxParams.vae_tiling != vae_tiling) {
893892
params->ctxParams.vae_tiling = vae_tiling;
894893
updatectx = true;
895894
}
896895
} catch (...) {
897896
}
897+
898898
try {
899899
std::string model = payload["model"];
900900
if (params->ctxParams.model_path != params->models_dir + model) {
@@ -957,7 +957,7 @@ bool parseJsonPrompt(std::string json_str, SDParams* params) {
957957
try {
958958
std::string schedule = payload["schedule"];
959959
int schedule_found = -1;
960-
for (int m = 0; m < N_SAMPLE_METHODS; m++) {
960+
for (int m = 0; m < N_SCHEDULES; m++) {
961961
if (!strcmp(schedule.c_str(), schedule_str[m])) {
962962
schedule_found = m;
963963
}
@@ -1009,8 +1009,8 @@ void worker_thread() {
10091009
queue_cond.wait(lock, [] { return !task_queue.empty() || stop_worker; });
10101010

10111011
if (!task_queue.empty()) {
1012-
is_busy = true;
1013-
auto task = task_queue.front();
1012+
is_busy = true;
1013+
auto task = task_queue.front();
10141014
task_queue.pop();
10151015
lock.unlock();
10161016
task();
@@ -1080,7 +1080,7 @@ void start_server(SDParams params) {
10801080
bool updateCTX = false;
10811081
try {
10821082
std::string json_str = req.body;
1083-
updateCTX = parseJsonPrompt(json_str, &params);
1083+
updateCTX = parseJsonPrompt(json_str, &params);
10841084
} catch (json::parse_error& e) {
10851085
// assume the request is just a prompt
10861086
// LOG_WARN("Failed to parse json: %s\n Assuming it's just a prompt...\n", e.what());
@@ -1105,6 +1105,7 @@ void start_server(SDParams params) {
11051105
}
11061106

11071107
if (sd_ctx == NULL) {
1108+
printf("Loading sd_ctx\n");
11081109
json task_json = json::object();
11091110
task_json["status"] = "Loading";
11101111
task_json["data"] = json::array();

0 commit comments

Comments
 (0)