mirror of
https://github.com/leejet/stable-diffusion.cpp.git
synced 2026-01-02 18:53:36 +00:00
feat: do not convert tensor names by default in convert mode (#1122)
This commit is contained in:
parent
50ff966445
commit
ca5b1969a8
@ -9,6 +9,7 @@ CLI Options:
|
|||||||
--preview-interval <int> interval in denoising steps between consecutive updates of the image preview file (default is 1, meaning updating at
|
--preview-interval <int> interval in denoising steps between consecutive updates of the image preview file (default is 1, meaning updating at
|
||||||
every step)
|
every step)
|
||||||
--canny apply canny preprocessor (edge detection)
|
--canny apply canny preprocessor (edge detection)
|
||||||
|
--convert-name convert tensor name (for convert mode)
|
||||||
-v, --verbose print extra info
|
-v, --verbose print extra info
|
||||||
--color colors the logging tags according to level
|
--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)
|
--taesd-preview-only prevents usage of taesd for decoding the final image. (for use with --preview tae)
|
||||||
|
|||||||
@ -32,6 +32,7 @@ struct SDCliParams {
|
|||||||
|
|
||||||
bool verbose = false;
|
bool verbose = false;
|
||||||
bool canny_preprocess = false;
|
bool canny_preprocess = false;
|
||||||
|
bool convert_name = false;
|
||||||
|
|
||||||
preview_t preview_method = PREVIEW_NONE;
|
preview_t preview_method = PREVIEW_NONE;
|
||||||
int preview_interval = 1;
|
int preview_interval = 1;
|
||||||
@ -69,6 +70,10 @@ struct SDCliParams {
|
|||||||
"--canny",
|
"--canny",
|
||||||
"apply canny preprocessor (edge detection)",
|
"apply canny preprocessor (edge detection)",
|
||||||
true, &canny_preprocess},
|
true, &canny_preprocess},
|
||||||
|
{"",
|
||||||
|
"--convert-name",
|
||||||
|
"convert tensor name (for convert mode)",
|
||||||
|
true, &canny_preprocess},
|
||||||
{"-v",
|
{"-v",
|
||||||
"--verbose",
|
"--verbose",
|
||||||
"print extra info",
|
"print extra info",
|
||||||
@ -174,6 +179,7 @@ struct SDCliParams {
|
|||||||
<< " verbose: " << (verbose ? "true" : "false") << ",\n"
|
<< " verbose: " << (verbose ? "true" : "false") << ",\n"
|
||||||
<< " color: " << (color ? "true" : "false") << ",\n"
|
<< " color: " << (color ? "true" : "false") << ",\n"
|
||||||
<< " canny_preprocess: " << (canny_preprocess ? "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_method: " << previews_str[preview_method] << ",\n"
|
||||||
<< " preview_interval: " << preview_interval << ",\n"
|
<< " preview_interval: " << preview_interval << ",\n"
|
||||||
<< " preview_path: \"" << preview_path << "\",\n"
|
<< " preview_path: \"" << preview_path << "\",\n"
|
||||||
@ -387,7 +393,8 @@ int main(int argc, const char* argv[]) {
|
|||||||
ctx_params.vae_path.c_str(),
|
ctx_params.vae_path.c_str(),
|
||||||
cli_params.output_path.c_str(),
|
cli_params.output_path.c_str(),
|
||||||
ctx_params.wtype,
|
ctx_params.wtype,
|
||||||
ctx_params.tensor_type_rules.c_str());
|
ctx_params.tensor_type_rules.c_str(),
|
||||||
|
cli_params.convert_name);
|
||||||
if (!success) {
|
if (!success) {
|
||||||
LOG_ERROR("convert '%s'/'%s' to '%s' failed",
|
LOG_ERROR("convert '%s'/'%s' to '%s' failed",
|
||||||
ctx_params.model_path.c_str(),
|
ctx_params.model_path.c_str(),
|
||||||
|
|||||||
11
model.cpp
11
model.cpp
@ -1783,7 +1783,12 @@ int64_t ModelLoader::get_params_mem_size(ggml_backend_t backend, ggml_type type)
|
|||||||
return mem_size;
|
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;
|
ModelLoader model_loader;
|
||||||
|
|
||||||
if (!model_loader.init_from_file(input_path)) {
|
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;
|
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);
|
bool success = model_loader.save_to_gguf_file(output_path, (ggml_type)output_type, tensor_type_rules);
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -365,7 +365,8 @@ SD_API bool convert(const char* input_path,
|
|||||||
const char* vae_path,
|
const char* vae_path,
|
||||||
const char* output_path,
|
const char* output_path,
|
||||||
enum sd_type_t output_type,
|
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,
|
SD_API bool preprocess_canny(sd_image_t image,
|
||||||
float high_threshold,
|
float high_threshold,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user