@@ -116,6 +116,7 @@ struct SDParams {
116116 bool canny_preprocess = false ;
117117 bool color = false ;
118118 int upscale_repeats = 1 ;
119+ int upscale_tile = 128 ;
119120
120121 // Photo Maker
121122 std::string photo_maker_path;
@@ -201,6 +202,7 @@ void print_params(SDParams params) {
201202 printf (" vae_tiling: %s\n " , params.vae_tiling_params .enabled ? " true" : " false" );
202203 printf (" force_sdxl_vae_conv_scale: %s\n " , params.force_sdxl_vae_conv_scale ? " true" : " false" );
203204 printf (" upscale_repeats: %d\n " , params.upscale_repeats );
205+ printf (" upscale_tile: %d\n " , params.upscale_tile );
204206 printf (" chroma_use_dit_mask: %s\n " , params.chroma_use_dit_mask ? " true" : " false" );
205207 printf (" chroma_use_t5_mask: %s\n " , params.chroma_use_t5_mask ? " true" : " false" );
206208 printf (" chroma_t5_mask_pad: %d\n " , params.chroma_t5_mask_pad );
@@ -235,6 +237,7 @@ void print_usage(int argc, const char* argv[]) {
235237 printf (" --embd-dir [EMBEDDING_PATH] path to embeddings\n " );
236238 printf (" --upscale-model [ESRGAN_PATH] path to esrgan model. For img_gen mode, upscale images after generate, just RealESRGAN_x4plus_anime_6B supported by now\n " );
237239 printf (" --upscale-repeats Run the ESRGAN upscaler this many times (default 1)\n " );
240+ printf (" --upscale-tile Tile size for the ESRGAN upscaler (default 128)\n " );
238241 printf (" --type [TYPE] weight type (examples: f32, f16, q4_0, q4_1, q5_0, q5_1, q8_0, q2_K, q3_K, q4_K)\n " );
239242 printf (" If not specified, the default is the type of the weight file\n " );
240243 printf (" --tensor-type-rules [EXPRESSION] weight type per tensor pattern (example: \" ^vae\\ .=f16,model\\ .=q8_0\" )\n " );
@@ -527,6 +530,7 @@ void parse_args(int argc, const char** argv, SDParams& params) {
527530 options.int_options = {
528531 {" -t" , " --threads" , " " , ¶ms.n_threads },
529532 {" " , " --upscale-repeats" , " " , ¶ms.upscale_repeats },
533+ {" " ," --upscale-tile" , " " , ¶ms.upscale_tile },
530534 {" -H" , " --height" , " " , ¶ms.height },
531535 {" -W" , " --width" , " " , ¶ms.width },
532536 {" " , " --steps" , " " , ¶ms.sample_params .sample_steps },
@@ -917,6 +921,11 @@ void parse_args(int argc, const char** argv, SDParams& params) {
917921 exit (1 );
918922 }
919923
924+ if (params.upscale_tile < 1 ) {
925+ fprintf (stderr, " error: upscale tile size must be at least 1\n " );
926+ exit (1 );
927+ }
928+
920929 if (params.mode == UPSCALE) {
921930 if (params.esrgan_path .length () == 0 ) {
922931 fprintf (stderr, " error: upscale mode needs an upscaler model (--upscale-model)\n " );
@@ -1486,7 +1495,8 @@ int main(int argc, const char* argv[]) {
14861495 upscaler_ctx_t * upscaler_ctx = new_upscaler_ctx (params.esrgan_path .c_str (),
14871496 params.offload_params_to_cpu ,
14881497 params.diffusion_conv_direct ,
1489- params.n_threads );
1498+ params.n_threads ,
1499+ params.upscale_tile );
14901500
14911501 if (upscaler_ctx == NULL ) {
14921502 printf (" new_upscaler_ctx failed\n " );
0 commit comments