Skip to content

Commit

Permalink
improve quiet mode for SD
Browse files Browse the repository at this point in the history
  • Loading branch information
LostRuins committed Mar 12, 2024
1 parent 60d2345 commit 88705cb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions otherarch/sdcpp/sdtype_adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ sd_generation_outputs sdtype_generate(const sd_generation_inputs inputs)
sd_image_t* control_image = NULL;

bool is_quiet = inputs.quiet;
set_sd_quiet(is_quiet);

//sanitize prompts, remove quotes and limit lengths
std::string cleanprompt = clean_input_prompt(inputs.prompt);
Expand All @@ -272,6 +273,8 @@ sd_generation_outputs sdtype_generate(const sd_generation_inputs inputs)
if(!is_quiet)
{
printf("\nGenerating Image (%d steps)\n",inputs.sample_steps);
}else{
printf("\nGenerating (%d st.)\n",inputs.sample_steps);
}

fflush(stdout);
Expand Down
7 changes: 6 additions & 1 deletion otherarch/sdcpp/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,12 @@ std::string path_join(const std::string& p1, const std::string& p2) {
}

static int sdloglevel = 0; //-1 = hide all, 0 = normal, 1 = showall
static bool sdquiet = false;
void pretty_progress(int step, int steps, float time) {
if (step == 0) {
return;
}
if(sdloglevel<0)
if(sdloglevel<0 || sdquiet)
{
return;
}
Expand Down Expand Up @@ -279,6 +280,10 @@ bool get_sd_log_level()
{
return sdloglevel;
}
void set_sd_quiet(bool quiet)
{
sdquiet = quiet;
}

void log_printf(sd_log_level_t level, const char* file, int line, const char* format, ...) {
va_list args;
Expand Down
1 change: 1 addition & 0 deletions otherarch/sdcpp/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ std::string trim(const std::string& s);
void log_message(const char* format, ...);
void set_sd_log_level(int log);
bool get_sd_log_level();
void set_sd_quiet(bool quiet);
#define LOG_DEBUG(...) log_message(__VA_ARGS__)
#define LOG_INFO(...) log_message(__VA_ARGS__)
#define LOG_WARN(...) log_message(__VA_ARGS__)
Expand Down

0 comments on commit 88705cb

Please sign in to comment.