refactor: optimize the printing of version log (#1102)

This commit is contained in:
leejet 2025-12-16 23:11:27 +08:00 committed by GitHub
parent ebe9d26a72
commit c3ad6a13e1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 20 deletions

View File

@ -31,7 +31,6 @@ struct SDCliParams {
std::string output_path = "output.png";
bool verbose = false;
bool version = false;
bool canny_preprocess = false;
preview_t preview_method = PREVIEW_NONE;
@ -74,10 +73,6 @@ struct SDCliParams {
"--verbose",
"print extra info",
true, &verbose},
{"",
"--version",
"print stable-diffusion.cpp version",
true, &version},
{"",
"--color",
"colors the logging tags according to level",
@ -354,9 +349,6 @@ int main(int argc, const char* argv[]) {
SDGenerationParams gen_params;
parse_args(argc, argv, cli_params, ctx_params, gen_params);
if (cli_params.verbose || cli_params.version) {
std::cout << version_string() << "\n";
}
if (gen_params.video_frames > 4) {
size_t last_dot_pos = cli_params.preview_path.find_last_of(".");
std::string base_path = cli_params.preview_path;
@ -384,12 +376,11 @@ int main(int argc, const char* argv[]) {
cli_params.preview_noisy,
(void*)&cli_params);
if (cli_params.verbose) {
LOG_INFO("%s", sd_get_system_info());
LOG_INFO("%s", cli_params.to_string().c_str());
LOG_INFO("%s", ctx_params.to_string().c_str());
LOG_INFO("%s", gen_params.to_string().c_str());
}
LOG_DEBUG("version: %s", version_string().c_str());
LOG_DEBUG("%s", sd_get_system_info());
LOG_DEBUG("%s", cli_params.to_string().c_str());
LOG_DEBUG("%s", ctx_params.to_string().c_str());
LOG_DEBUG("%s", gen_params.to_string().c_str());
if (cli_params.mode == CONVERT) {
bool success = convert(ctx_params.model_path.c_str(),

View File

@ -262,6 +262,10 @@ void sd_log_cb(enum sd_log_level_t level, const char* log, void* data) {
}
int main(int argc, const char** argv) {
if (argc > 1 && std::string(argv[1]) == "--version") {
std::cout << version_string() << "\n";
return EXIT_SUCCESS;
}
SDSvrParams svr_params;
SDContextParams ctx_params;
SDGenerationParams default_gen_params;
@ -271,12 +275,11 @@ int main(int argc, const char** argv) {
log_verbose = svr_params.verbose;
log_color = svr_params.color;
if (svr_params.verbose) {
LOG_INFO("%s", sd_get_system_info());
LOG_INFO("%s", svr_params.to_string().c_str());
LOG_INFO("%s", ctx_params.to_string().c_str());
LOG_INFO("%s", default_gen_params.to_string().c_str());
}
LOG_DEBUG("version: %s", version_string().c_str());
LOG_DEBUG("%s", sd_get_system_info());
LOG_DEBUG("%s", svr_params.to_string().c_str());
LOG_DEBUG("%s", ctx_params.to_string().c_str());
LOG_DEBUG("%s", default_gen_params.to_string().c_str());
sd_ctx_params_t sd_ctx_params = ctx_params.to_sd_ctx_params_t(false, false, false);
sd_ctx_t* sd_ctx = new_sd_ctx(&sd_ctx_params);