diff --git a/examples/cli/README.md b/examples/cli/README.md index da7734d..d6cb6aa 100644 --- a/examples/cli/README.md +++ b/examples/cli/README.md @@ -9,6 +9,7 @@ CLI Options: --preview-interval interval in denoising steps between consecutive updates of the image preview file (default is 1, meaning updating at every step) --canny apply canny preprocessor (edge detection) + --convert-name convert tensor name (for convert mode) -v, --verbose print extra info --color colors the logging tags according to level --taesd-preview-only prevents usage of taesd for decoding the final image. (for use with --preview tae) diff --git a/examples/cli/main.cpp b/examples/cli/main.cpp index a1b92f7..eb6f9da 100644 --- a/examples/cli/main.cpp +++ b/examples/cli/main.cpp @@ -32,6 +32,7 @@ struct SDCliParams { bool verbose = false; bool canny_preprocess = false; + bool convert_name = false; preview_t preview_method = PREVIEW_NONE; int preview_interval = 1; @@ -69,6 +70,10 @@ struct SDCliParams { "--canny", "apply canny preprocessor (edge detection)", true, &canny_preprocess}, + {"", + "--convert-name", + "convert tensor name (for convert mode)", + true, &canny_preprocess}, {"-v", "--verbose", "print extra info", @@ -174,6 +179,7 @@ struct SDCliParams { << " verbose: " << (verbose ? "true" : "false") << ",\n" << " color: " << (color ? "true" : "false") << ",\n" << " canny_preprocess: " << (canny_preprocess ? "true" : "false") << ",\n" + << " convert_name: " << (convert_name ? "true" : "false") << ",\n" << " preview_method: " << previews_str[preview_method] << ",\n" << " preview_interval: " << preview_interval << ",\n" << " preview_path: \"" << preview_path << "\",\n" @@ -387,7 +393,8 @@ int main(int argc, const char* argv[]) { ctx_params.vae_path.c_str(), cli_params.output_path.c_str(), ctx_params.wtype, - ctx_params.tensor_type_rules.c_str()); + ctx_params.tensor_type_rules.c_str(), + cli_params.convert_name); if (!success) { LOG_ERROR("convert '%s'/'%s' to '%s' failed", ctx_params.model_path.c_str(), diff --git a/model.cpp b/model.cpp index 561eb3c..b5f7344 100644 --- a/model.cpp +++ b/model.cpp @@ -1783,7 +1783,12 @@ int64_t ModelLoader::get_params_mem_size(ggml_backend_t backend, ggml_type type) return mem_size; } -bool convert(const char* input_path, const char* vae_path, const char* output_path, sd_type_t output_type, const char* tensor_type_rules) { +bool convert(const char* input_path, + const char* vae_path, + const char* output_path, + sd_type_t output_type, + const char* tensor_type_rules, + bool convert_name) { ModelLoader model_loader; if (!model_loader.init_from_file(input_path)) { @@ -1797,7 +1802,9 @@ bool convert(const char* input_path, const char* vae_path, const char* output_pa return false; } } - model_loader.convert_tensors_name(); + if (convert_name) { + model_loader.convert_tensors_name(); + } bool success = model_loader.save_to_gguf_file(output_path, (ggml_type)output_type, tensor_type_rules); return success; } diff --git a/stable-diffusion.h b/stable-diffusion.h index 30583ea..9bc1fba 100644 --- a/stable-diffusion.h +++ b/stable-diffusion.h @@ -365,7 +365,8 @@ SD_API bool convert(const char* input_path, const char* vae_path, const char* output_path, enum sd_type_t output_type, - const char* tensor_type_rules); + const char* tensor_type_rules, + bool convert_name); SD_API bool preprocess_canny(sd_image_t image, float high_threshold,