@@ -965,6 +965,7 @@ struct SDGenerationParams {
965965 std::string control_video_path;
966966 bool auto_resize_ref_image = true ;
967967 bool increase_ref_index = false ;
968+ bool embed_image_metadata = true ;
968969
969970 std::vector<int > skip_layers = {7 , 8 , 9 };
970971 sd_sample_params_t sample_params;
@@ -1199,10 +1200,16 @@ struct SDGenerationParams {
11991200 " disable auto resize of ref images" ,
12001201 false ,
12011202 &auto_resize_ref_image},
1203+ {" " ,
1204+ " --disable-image-metadata" ,
1205+ " do not embed generation metadata on image files" ,
1206+ false ,
1207+ &embed_image_metadata},
12021208 {" " ,
12031209 " --vae-tiling" ,
12041210 " process vae in tiles to reduce memory usage" ,
1205- true , &vae_tiling_params.enabled },
1211+ true ,
1212+ &vae_tiling_params.enabled },
12061213 };
12071214
12081215 auto on_seed_arg = [&](int argc, const char ** argv, int index) {
@@ -1567,6 +1574,7 @@ struct SDGenerationParams {
15671574
15681575 load_if_exists (" auto_resize_ref_image" , auto_resize_ref_image);
15691576 load_if_exists (" increase_ref_index" , increase_ref_index);
1577+ load_if_exists (" embed_image_metadata" , embed_image_metadata);
15701578
15711579 load_if_exists (" skip_layers" , skip_layers);
15721580 load_if_exists (" high_noise_skip_layers" , high_noise_skip_layers);
@@ -2094,3 +2102,65 @@ uint8_t* load_image_from_memory(const char* image_bytes,
20942102 int expected_channel = 3 ) {
20952103 return load_image_common (true , image_bytes, len, width, height, expected_width, expected_height, expected_channel);
20962104}
2105+
2106+ std::string get_image_params (const SDContextParams& ctx_params, const SDGenerationParams& gen_params, int64_t seed) {
2107+ std::string parameter_string;
2108+ if (gen_params.prompt_with_lora .size () != 0 ) {
2109+ parameter_string += gen_params.prompt_with_lora + " \n " ;
2110+ } else {
2111+ parameter_string += gen_params.prompt + " \n " ;
2112+ }
2113+ if (gen_params.negative_prompt .size () != 0 ) {
2114+ parameter_string += " Negative prompt: " + gen_params.negative_prompt + " \n " ;
2115+ }
2116+ parameter_string += " Steps: " + std::to_string (gen_params.sample_params .sample_steps ) + " , " ;
2117+ parameter_string += " CFG scale: " + std::to_string (gen_params.sample_params .guidance .txt_cfg ) + " , " ;
2118+ if (gen_params.sample_params .guidance .slg .scale != 0 && gen_params.skip_layers .size () != 0 ) {
2119+ parameter_string += " SLG scale: " + std::to_string (gen_params.sample_params .guidance .txt_cfg ) + " , " ;
2120+ parameter_string += " Skip layers: [" ;
2121+ for (const auto & layer : gen_params.skip_layers ) {
2122+ parameter_string += std::to_string (layer) + " , " ;
2123+ }
2124+ parameter_string += " ], " ;
2125+ parameter_string += " Skip layer start: " + std::to_string (gen_params.sample_params .guidance .slg .layer_start ) + " , " ;
2126+ parameter_string += " Skip layer end: " + std::to_string (gen_params.sample_params .guidance .slg .layer_end ) + " , " ;
2127+ }
2128+ parameter_string += " Guidance: " + std::to_string (gen_params.sample_params .guidance .distilled_guidance ) + " , " ;
2129+ parameter_string += " Eta: " + std::to_string (gen_params.sample_params .eta ) + " , " ;
2130+ parameter_string += " Seed: " + std::to_string (seed) + " , " ;
2131+ parameter_string += " Size: " + std::to_string (gen_params.width ) + " x" + std::to_string (gen_params.height ) + " , " ;
2132+ parameter_string += " Model: " + sd_basename (ctx_params.model_path ) + " , " ;
2133+ parameter_string += " RNG: " + std::string (sd_rng_type_name (ctx_params.rng_type )) + " , " ;
2134+ if (ctx_params.sampler_rng_type != RNG_TYPE_COUNT) {
2135+ parameter_string += " Sampler RNG: " + std::string (sd_rng_type_name (ctx_params.sampler_rng_type )) + " , " ;
2136+ }
2137+ parameter_string += " Sampler: " + std::string (sd_sample_method_name (gen_params.sample_params .sample_method ));
2138+ if (!gen_params.custom_sigmas .empty ()) {
2139+ parameter_string += " , Custom Sigmas: [" ;
2140+ for (size_t i = 0 ; i < gen_params.custom_sigmas .size (); ++i) {
2141+ std::ostringstream oss;
2142+ oss << std::fixed << std::setprecision (4 ) << gen_params.custom_sigmas [i];
2143+ parameter_string += oss.str () + (i == gen_params.custom_sigmas .size () - 1 ? " " : " , " );
2144+ }
2145+ parameter_string += " ]" ;
2146+ } else if (gen_params.sample_params .scheduler != SCHEDULER_COUNT) { // Only show schedule if not using custom sigmas
2147+ parameter_string += " " + std::string (sd_scheduler_name (gen_params.sample_params .scheduler ));
2148+ }
2149+ parameter_string += " , " ;
2150+ for (const auto & te : {ctx_params.clip_l_path , ctx_params.clip_g_path , ctx_params.t5xxl_path , ctx_params.llm_path , ctx_params.llm_vision_path }) {
2151+ if (!te.empty ()) {
2152+ parameter_string += " TE: " + sd_basename (te) + " , " ;
2153+ }
2154+ }
2155+ if (!ctx_params.diffusion_model_path .empty ()) {
2156+ parameter_string += " Unet: " + sd_basename (ctx_params.diffusion_model_path ) + " , " ;
2157+ }
2158+ if (!ctx_params.vae_path .empty ()) {
2159+ parameter_string += " VAE: " + sd_basename (ctx_params.vae_path ) + " , " ;
2160+ }
2161+ if (gen_params.clip_skip != -1 ) {
2162+ parameter_string += " Clip skip: " + std::to_string (gen_params.clip_skip ) + " , " ;
2163+ }
2164+ parameter_string += " Version: stable-diffusion.cpp" ;
2165+ return parameter_string;
2166+ }
0 commit comments