Skip to content

Commit da6db07

Browse files
authored
feat: stream model conversion (#1581)
1 parent e9dee54 commit da6db07

12 files changed

Lines changed: 673 additions & 79 deletions

File tree

examples/cli/main.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,8 @@ int main(int argc, const char* argv[]) {
653653
cli_params.output_path.c_str(),
654654
ctx_params.wtype,
655655
ctx_params.tensor_type_rules.c_str(),
656-
cli_params.convert_name);
656+
cli_params.convert_name,
657+
ctx_params.n_threads);
657658
if (!success) {
658659
LOG_ERROR("convert '%s'/'%s' to '%s' failed",
659660
ctx_params.model_path.c_str(),

examples/server/routes_sdapi.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ static nlohmann::json prepare_info_field(const SDContextParams& ctx_params,
281281
jsoninfo["clip_skip"] = gen_params.clip_skip;
282282
}
283283
if (gen_params.sample_params.scheduler != scheduler_t::SCHEDULER_COUNT) {
284-
jsoninfo["extra_generation_params"] = nlohmann::json::object();
284+
jsoninfo["extra_generation_params"] = nlohmann::json::object();
285285
jsoninfo["extra_generation_params"]["Schedule type"] = sd_scheduler_name(gen_params.sample_params.scheduler);
286286
}
287287
if (img2img) {
@@ -363,18 +363,18 @@ void register_sdapi_endpoints(httplib::Server& svr, ServerRuntime& rt) {
363363
continue;
364364
}
365365

366-
bool embed_meta = request.gen_params.embed_image_metadata;
366+
bool embed_meta = request.gen_params.embed_image_metadata;
367367

368368
std::string params = get_image_params(*runtime->ctx_params,
369369
request.gen_params,
370370
request.gen_params.seed + i / images_per_batch);
371371

372-
auto image_bytes = encode_image_to_vector(EncodedImageFormat::PNG,
373-
results[i].data,
374-
results[i].width,
375-
results[i].height,
376-
results[i].channel,
377-
embed_meta ? params : "");
372+
auto image_bytes = encode_image_to_vector(EncodedImageFormat::PNG,
373+
results[i].data,
374+
results[i].width,
375+
results[i].height,
376+
results[i].channel,
377+
embed_meta ? params : "");
378378

379379
if (image_bytes.empty()) {
380380
LOG_ERROR("write image to mem failed");

include/stable-diffusion.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,8 @@ SD_API bool convert_with_components(const char* model_path,
521521
const char* output_path,
522522
enum sd_type_t output_type,
523523
const char* tensor_type_rules,
524-
bool convert_name);
524+
bool convert_name,
525+
int n_threads);
525526

526527
SD_API bool preprocess_canny(sd_image_t image,
527528
float high_threshold,

0 commit comments

Comments
 (0)