diff --git a/examples/cli/main.cpp b/examples/cli/main.cpp index fa2a078..d01e863 100644 --- a/examples/cli/main.cpp +++ b/examples/cli/main.cpp @@ -81,7 +81,7 @@ struct SDParams { bool vae_tiling = false; }; -static std::string basename(const std::string& path) { +static std::string sd_basename(const std::string& path) { size_t pos = path.find_last_of('/'); if (pos != std::string::npos) { return path.substr(pos + 1); @@ -443,7 +443,7 @@ std::string get_image_params(SDParams params, int64_t seed) { parameter_string += "CFG scale: " + std::to_string(params.cfg_scale) + ", "; parameter_string += "Seed: " + std::to_string(seed) + ", "; parameter_string += "Size: " + std::to_string(params.width) + "x" + std::to_string(params.height) + ", "; - parameter_string += "Model: " + basename(params.model_path) + ", "; + parameter_string += "Model: " + sd_basename(params.model_path) + ", "; parameter_string += "RNG: " + std::string(rng_type_to_str[params.rng_type]) + ", "; parameter_string += "Sampler: " + std::string(sample_method_str[params.sample_method]); if (params.schedule == KARRAS) { diff --git a/stable-diffusion.h b/stable-diffusion.h index ece010f..c25791e 100644 --- a/stable-diffusion.h +++ b/stable-diffusion.h @@ -79,10 +79,18 @@ enum sd_type_t { SD_API const char* sd_type_name(enum sd_type_t type); +enum sd_log_level_t { + SD_LOG_DEBUG, + SD_LOG_INFO, + SD_LOG_WARN, + SD_LOG_ERROR +}; + typedef void (*sd_log_cb_t)(enum sd_log_level_t level, const char* text, void* data); SD_API void sd_set_log_callback(sd_log_cb_t sd_log_cb, void* data); SD_API int32_t get_num_physical_cores(); +SD_API const char* sd_get_system_info(); typedef struct { uint32_t width; @@ -133,15 +141,6 @@ SD_API sd_image_t* img2img(sd_ctx_t* sd_ctx, int64_t seed, int batch_count); -SD_API const char* sd_get_system_info(); - -enum sd_log_level_t { - SD_LOG_DEBUG, - SD_LOG_INFO, - SD_LOG_WARN, - SD_LOG_ERROR -}; - typedef struct upscaler_ctx_t upscaler_ctx_t; SD_API upscaler_ctx_t* new_upscaler_ctx(const char* esrgan_path, diff --git a/util.cpp b/util.cpp index 99eb609..4057d13 100644 --- a/util.cpp +++ b/util.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -140,7 +141,7 @@ std::u32string unicode_value_to_utf32(int unicode_value) { return utf32_string; } -std::string basename(const std::string& path) { +std::string sd_basename(const std::string& path) { size_t pos = path.find_last_of('/'); if (pos != std::string::npos) { return path.substr(pos + 1); @@ -211,7 +212,7 @@ void log_printf(sd_log_level_t level, const char* file, int line, const char* fo static char log_buffer[LOG_BUFFER_SIZE]; - int written = snprintf(log_buffer, LOG_BUFFER_SIZE, "[%s] %s:%-4d - ", level_str, basename(file).c_str(), line); + int written = snprintf(log_buffer, LOG_BUFFER_SIZE, "[%s] %s:%-4d - ", level_str, sd_basename(file).c_str(), line); if (written >= 0 && written < LOG_BUFFER_SIZE) { vsnprintf(log_buffer + written, LOG_BUFFER_SIZE - written, format, args); diff --git a/util.h b/util.h index 547db67..3a61165 100644 --- a/util.h +++ b/util.h @@ -20,7 +20,7 @@ std::u32string utf8_to_utf32(const std::string& utf8_str); std::string utf32_to_utf8(const std::u32string& utf32_str); std::u32string unicode_value_to_utf32(int unicode_value); -std::string basename(const std::string& path); +std::string sd_basename(const std::string& path); std::string path_join(const std::string& p1, const std::string& p2);