Skip to content

Commit 0079543

Browse files
committed
update api again
1 parent 84abdd7 commit 0079543

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

examples/server/main.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ struct SDRequestParams {
107107
1,
108108
3.5,
109109
sd_slg_params_t{NULL, 0, 0.01, 0.2, 0}},
110-
DEFAULT,
111-
SAMPLE_METHOD_DEFAULT,
110+
SCHEDULER_COUNT,
111+
SAMPLE_METHOD_COUNT,
112112
20,
113113
0, 0};
114114
float strength = 1.f;
@@ -219,7 +219,7 @@ void print_params(SDParams params) {
219219
printf(" width: %d\n", params.lastRequest.width);
220220
printf(" height: %d\n", params.lastRequest.height);
221221
printf(" sample_method: %s\n", sd_sample_method_name(params.lastRequest.sample_params.sample_method));
222-
printf(" schedule: %s\n", sd_schedule_name(params.lastRequest.sample_params.scheduler));
222+
printf(" schedule: %s\n", sd_scheduler_name(params.lastRequest.sample_params.scheduler));
223223
printf(" sample_steps: %d\n", params.lastRequest.sample_params.sample_steps);
224224
printf(" strength(img2img): %.2f\n", params.lastRequest.strength);
225225
printf(" rng: %s\n", sd_rng_type_name(params.ctxParams.rng_type));
@@ -580,8 +580,8 @@ void parse_args(int argc, const char** argv, SDParams& params) {
580580
return -1;
581581
}
582582
const char* arg = argv[index];
583-
params.lastRequest.sample_params.scheduler = str_to_schedule(arg);
584-
if (params.lastRequest.sample_params.scheduler == SCHEDULE_COUNT) {
583+
params.lastRequest.sample_params.scheduler = str_to_scheduler(arg);
584+
if (params.lastRequest.sample_params.scheduler == SCHEDULER_COUNT) {
585585
fprintf(stderr, "error: invalid scheduler %s\n",
586586
arg);
587587
return -1;
@@ -707,7 +707,7 @@ std::string get_image_params(SDParams params, int64_t seed) {
707707
parameter_string += "Model: " + sd_basename(params.ctxParams.model_path) + ", ";
708708
parameter_string += "RNG: " + std::string(sd_rng_type_name(params.ctxParams.rng_type)) + ", ";
709709
parameter_string += "Sampler: " + std::string(sd_sample_method_name(params.lastRequest.sample_params.sample_method));
710-
if (params.lastRequest.sample_params.scheduler == KARRAS) {
710+
if (params.lastRequest.sample_params.scheduler == KARRAS_SCHEDULER) {
711711
parameter_string += " karras";
712712
}
713713
parameter_string += ", ";
@@ -1048,9 +1048,9 @@ bool parseJsonPrompt(std::string json_str, SDParams* params) {
10481048
}},
10491049
{"scheduler", [&](const json& o) -> bool {
10501050
std::string schedule = o.get<std::string>();
1051-
scheduler_t schedule_found = str_to_schedule(schedule.c_str());
1051+
scheduler_t schedule_found = str_to_scheduler(schedule.c_str());
10521052
bool change = false;
1053-
if (schedule_found != SCHEDULE_COUNT) {
1053+
if (schedule_found != SCHEDULER_COUNT) {
10541054
if (params->lastRequest.sample_params.scheduler != schedule_found) {
10551055
params->lastRequest.sample_params.scheduler = schedule_found;
10561056
change = true;
@@ -1710,8 +1710,8 @@ bool parseJsonPrompt(std::string json_str, SDParams* params) {
17101710
}
17111711
try {
17121712
std::string schedule = payload["schedule"];
1713-
scheduler_t schedule_found = str_to_schedule(schedule.c_str());
1714-
if (schedule_found != SCHEDULE_COUNT) {
1713+
scheduler_t schedule_found = str_to_scheduler(schedule.c_str());
1714+
if (schedule_found != SCHEDULER_COUNT) {
17151715
if (params->lastRequest.sample_params.scheduler != schedule_found) {
17161716
params->lastRequest.sample_params.scheduler = schedule_found;
17171717
}
@@ -2214,7 +2214,7 @@ void start_server(SDParams params) {
22142214
context_params["n_threads"] = params.ctxParams.n_threads;
22152215
context_params["wtype"] = params.ctxParams.wtype;
22162216
context_params["rng_type"] = params.ctxParams.rng_type;
2217-
context_params["schedule"] = sd_schedule_name(params.lastRequest.sample_params.scheduler);
2217+
context_params["schedule"] = sd_scheduler_name(params.lastRequest.sample_params.scheduler);
22182218
context_params["keep_clip_on_cpu"] = params.ctxParams.keep_clip_on_cpu;
22192219
context_params["keep_control_net_on_cpu"] = params.ctxParams.keep_control_net_on_cpu;
22202220
context_params["keep_vae_on_cpu"] = params.ctxParams.keep_vae_on_cpu;
@@ -2302,17 +2302,17 @@ void start_server(SDParams params) {
23022302
sd_log(SD_LOG_WARN, "/schedules endpoint is soon to be deprecated, use /schedulers instead");
23032303
using json = nlohmann::json;
23042304
json response;
2305-
for (int s = 0; s < SCHEDULE_COUNT; s++) {
2306-
response.push_back(sd_schedule_name((scheduler_t)s));
2305+
for (int s = 0; s < SCHEDULER_COUNT; s++) {
2306+
response.push_back(sd_scheduler_name((scheduler_t)s));
23072307
}
23082308
res.set_content(response.dump(), "application/json");
23092309
});
23102310

23112311
svr->Get("/schedulers", [](const httplib::Request& req, httplib::Response& res) {
23122312
using json = nlohmann::json;
23132313
json response;
2314-
for (int s = 0; s < SCHEDULE_COUNT; s++) {
2315-
response.push_back(sd_schedule_name((scheduler_t)s));
2314+
for (int s = 0; s < SCHEDULER_COUNT; s++) {
2315+
response.push_back(sd_scheduler_name((scheduler_t)s));
23162316
}
23172317
res.set_content(response.dump(), "application/json");
23182318
});

0 commit comments

Comments
 (0)