mirror of
https://github.com/leejet/stable-diffusion.cpp.git
synced 2025-12-12 13:28:37 +00:00
* add wan vae suppport * add wan model support * add umt5 support * add wan2.1 t2i support * make flash attn work with wan * make wan a little faster * add wan2.1 t2v support * add wan gguf support * add offload params to cpu support * add wan2.1 i2v support * crop image before resize * set default fps to 16 * add diff lora support * fix wan2.1 i2v * introduce sd_sample_params_t * add wan2.2 t2v support * add wan2.2 14B i2v support * add wan2.2 ti2v support * add high noise lora support * sync: update ggml submodule url * avoid build failure on linux * avoid build failure * update ggml * update ggml * fix sd_version_is_wan * update ggml, fix cpu im2col_3d * fix ggml_nn_attention_ext mask * add cache support to ggml runner * fix the issue of illegal memory access * unify image loading processing * add wan2.1/2.2 FLF2V support * fix end_image mask * update to latest ggml * add GGUFReader * update docs
67 lines
2.3 KiB
C++
67 lines
2.3 KiB
C++
#ifndef __UTIL_H__
|
|
#define __UTIL_H__
|
|
|
|
#include <cstdint>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "stable-diffusion.h"
|
|
|
|
#define SAFE_STR(s) ((s) ? (s) : "")
|
|
#define BOOL_STR(b) ((b) ? "true" : "false")
|
|
|
|
bool ends_with(const std::string& str, const std::string& ending);
|
|
bool starts_with(const std::string& str, const std::string& start);
|
|
bool contains(const std::string& str, const std::string& substr);
|
|
|
|
std::string format(const char* fmt, ...);
|
|
|
|
void replace_all_chars(std::string& str, char target, char replacement);
|
|
|
|
int round_up_to(int value, int base);
|
|
|
|
bool file_exists(const std::string& filename);
|
|
bool is_directory(const std::string& path);
|
|
std::string get_full_path(const std::string& dir, const std::string& filename);
|
|
|
|
std::vector<std::string> get_files_from_dir(const std::string& dir);
|
|
|
|
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);
|
|
|
|
sd_image_t* preprocess_id_image(sd_image_t* img);
|
|
|
|
// std::string sd_basename(const std::string& path);
|
|
|
|
typedef struct {
|
|
uint32_t width;
|
|
uint32_t height;
|
|
uint32_t channel;
|
|
float* data;
|
|
} sd_image_f32_t;
|
|
|
|
void normalize_sd_image_f32_t(sd_image_f32_t image, float means[3], float stds[3]);
|
|
|
|
sd_image_f32_t sd_image_t_to_sd_image_f32_t(sd_image_t image);
|
|
|
|
sd_image_f32_t resize_sd_image_f32_t(sd_image_f32_t image, int target_width, int target_height);
|
|
|
|
sd_image_f32_t clip_preprocess(sd_image_f32_t image, int size);
|
|
|
|
std::string path_join(const std::string& p1, const std::string& p2);
|
|
std::vector<std::string> split_string(const std::string& str, char delimiter);
|
|
void pretty_progress(int step, int steps, float time);
|
|
|
|
void log_printf(sd_log_level_t level, const char* file, int line, const char* format, ...);
|
|
|
|
std::string trim(const std::string& s);
|
|
|
|
std::vector<std::pair<std::string, float>> parse_prompt_attention(const std::string& text);
|
|
|
|
#define LOG_DEBUG(format, ...) log_printf(SD_LOG_DEBUG, __FILE__, __LINE__, format, ##__VA_ARGS__)
|
|
#define LOG_INFO(format, ...) log_printf(SD_LOG_INFO, __FILE__, __LINE__, format, ##__VA_ARGS__)
|
|
#define LOG_WARN(format, ...) log_printf(SD_LOG_WARN, __FILE__, __LINE__, format, ##__VA_ARGS__)
|
|
#define LOG_ERROR(format, ...) log_printf(SD_LOG_ERROR, __FILE__, __LINE__, format, ##__VA_ARGS__)
|
|
#endif // __UTIL_H__
|