Skip to content

Commit

Permalink
refactor: meta
Browse files Browse the repository at this point in the history
Signed-off-by: thxCode <thxcode0824@gmail.com>
  • Loading branch information
thxCode committed Dec 27, 2024
1 parent 3f4b8bb commit 1249df5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
33 changes: 28 additions & 5 deletions llama-box/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,13 @@ struct server_context {
}

if (sd_params.model_alias.empty()) {
sd_params.model_alias = sd_params.model.substr(sd_params.model.find_last_of('/') + 1);
if (sd_params.model.find_last_of('/') != std::string::npos) {
sd_params.model_alias = sd_params.model.substr(sd_params.model.find_last_of('/') + 1);
} else if (sd_params.model.find_last_of('\\') != std::string::npos) {
sd_params.model_alias = sd_params.model.substr(sd_params.model.find_last_of('\\') + 1);
} else {
sd_params.model_alias = sd_params.model;
}
}
if (sd_params.sampling.strength <= 0.0f) {
sd_params.sampling.strength = sd_ctx->get_default_strength();
Expand Down Expand Up @@ -977,7 +983,13 @@ struct server_context {
/* LLAMA */

if (llm_params.model_alias.empty()) {
llm_params.model_alias = llm_params.model.substr(llm_params.model.find_last_of('/') + 1);
if (llm_params.model.find_last_of('/') != std::string::npos) {
llm_params.model_alias = llm_params.model.substr(llm_params.model.find_last_of('/') + 1);
} else if (llm_params.model.find_last_of('\\') != std::string::npos) {
llm_params.model_alias = llm_params.model.substr(llm_params.model.find_last_of('\\') + 1);
} else {
llm_params.model_alias = llm_params.model;
}
}

// load multimodal projection model
Expand Down Expand Up @@ -3643,12 +3655,21 @@ struct server_context {

if (sd_ctx != nullptr) {
return json{
{"max_batch_count", sd_params.max_batch_count},
{"max_height", sd_params.sampling.height},
{"max_width", sd_params.sampling.width},
{"guidance", sd_params.sampling.guidance},
{"strength", sd_params.sampling.strength},
{"sample_method", sd_sample_method_to_argument(sd_params.sampling.sample_method)},
{"sampling_steps", sd_params.sampling.sampling_steps},
{"cfg_scale", sd_params.sampling.cfg_scale},
{"slg_scale", sd_params.sampling.slg_scale},
{"slg_skip_layers", sd_params.sampling.slg_skip_layers},
{"slg_start", sd_params.sampling.slg_start},
{"slg_end", sd_params.sampling.slg_end},
{"schedule_method", sd_schedule_to_argument(sd_params.sampling.schedule_method)},
{"max_height", sd_params.sampling.height},
{"max_width", sd_params.sampling.width},
{"max_batch_count", sd_params.max_batch_count},
{"negative_prompt", sd_params.sampling.negative_prompt},
{"n_slot", llm_params.n_parallel},
};
}

Expand All @@ -3663,6 +3684,8 @@ struct server_context {
{"size", llama_model_size(llm_model)},
{"n_ctx", llama_n_ctx(llm_ctx)},
{"n_slot", llm_params.n_parallel},
{"support_vision", llm_ctx_clip != nullptr},
{"support_speculative", llm_ctx_draft != nullptr},
{"support_tool_calls", support_tool_calls},
};
}
Expand Down
4 changes: 2 additions & 2 deletions llama-box/stablediffusion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct stablediffusion_params_sampling {
std::vector<int> slg_skip_layers = {7, 8, 9};
float slg_start = 0.01;
float slg_end = 0.2;
schedule_t schedule_method = DEFAULT;
schedule_t schedule_method = DISCRETE;
std::string negative_prompt;
float control_strength = 0.9f;
bool control_canny = false;
Expand Down Expand Up @@ -415,7 +415,7 @@ stablediffusion_context *common_sd_init_from_params(stablediffusion_params param
stablediffusion_params_sampling wparams = params.sampling;
wparams.sampling_steps = 1; // sample only once
wparams.sample_method = EULER;
wparams.schedule_method = DEFAULT;
wparams.schedule_method = DISCRETE;
stablediffusion_sampling_stream *stream = sc->generate_stream("a lovely cat", wparams);
sc->sample_stream(stream);
stablediffusion_generated_image img = sc->result_image_stream(stream);
Expand Down

0 comments on commit 1249df5

Please sign in to comment.