@@ -96,7 +96,7 @@ struct SDParams {
96
96
bool vae_tiling = false ;
97
97
bool control_net_cpu = false ;
98
98
bool canny_preprocess = false ;
99
- int upscale_repeats = 1 ;
99
+ int upscale_repeats = 1 ;
100
100
};
101
101
102
102
void print_params (SDParams params) {
@@ -174,7 +174,7 @@ void print_usage(int argc, const char* argv[]) {
174
174
printf (" --vae-tiling process vae in tiles to reduce memory usage\n " );
175
175
printf (" --control-net-cpu keep controlnet in cpu (for low vram)\n " );
176
176
printf (" --canny apply canny preprocessor (edge detection)\n " );
177
- printf (" -v, --verbose print extra info\n " );
177
+ printf (" -v, --verbose print extra info\n " );
178
178
}
179
179
180
180
void parse_args (int argc, const char ** argv, SDParams& params) {
@@ -714,34 +714,31 @@ int main(int argc, const char* argv[]) {
714
714
715
715
int upscale_factor = 4 ; // unused for RealESRGAN_x4plus_anime_6B.pth
716
716
if (params.esrgan_path .size () > 0 && params.upscale_repeats > 0 ) {
717
- upscaler_ctx_t * upscaler_ctx = new_upscaler_ctx (params.esrgan_path .c_str (),
718
- params.n_threads ,
719
- params.wtype );
717
+ upscaler_ctx_t * upscaler_ctx = new_upscaler_ctx (params.esrgan_path .c_str (),
718
+ params.n_threads ,
719
+ params.wtype );
720
720
721
- if (upscaler_ctx == NULL ) {
722
- printf (" new_upscaler_ctx failed\n " );
723
- } else {
724
- for (int i = 0 ; i < params.batch_count ; i++) {
725
- if (results[i].data == NULL ) {
726
- continue ;
727
- }
728
- sd_image_t current_image = results[i];
729
- for (int u = 0 ; u < params.upscale_repeats ; ++u) {
730
- sd_image_t upscaled_image = upscale (upscaler_ctx, current_image, upscale_factor);
731
- if (u > 0 ) { // Free the previous iteration's image data if not the first upscale
732
- free (current_image.data );
721
+ if (upscaler_ctx == NULL ) {
722
+ printf (" new_upscaler_ctx failed\n " );
723
+ } else {
724
+ for (int i = 0 ; i < params.batch_count ; i++) {
725
+ if (results[i].data == NULL ) {
726
+ continue ;
733
727
}
734
- if (upscaled_image.data == NULL ) {
735
- printf (" upscale failed\n " );
736
- break ;
728
+ sd_image_t current_image = results[i];
729
+ for (int u = 0 ; u < params.upscale_repeats ; ++u) {
730
+ sd_image_t upscaled_image = upscale (upscaler_ctx, current_image, upscale_factor);
731
+ if (upscaled_image.data == NULL ) {
732
+ printf (" upscale failed\n " );
733
+ break ;
734
+ }
735
+ free (current_image.data );
736
+ current_image = upscaled_image;
737
737
}
738
- current_image = upscaled_image;
738
+ results[i] = current_image; // Set the final upscaled image as the result
739
739
}
740
- results[i] = current_image; // Set the final upscaled image as the result
741
740
}
742
741
}
743
- }
744
-
745
742
746
743
size_t last = params.output_path .find_last_of (" ." );
747
744
std::string dummy_name = last != std::string::npos ? params.output_path .substr (0 , last) : params.output_path ;
0 commit comments