diff --git a/otherarch/sdcpp/sdtype_adapter.cpp b/otherarch/sdcpp/sdtype_adapter.cpp index 345dd7a27..f2bf7dca7 100644 --- a/otherarch/sdcpp/sdtype_adapter.cpp +++ b/otherarch/sdcpp/sdtype_adapter.cpp @@ -521,9 +521,11 @@ sd_generation_outputs sdtype_generate(const sd_generation_inputs inputs) int img2imgW = sd_params->width; //for img2img input int img2imgH = sd_params->height; int img2imgC = 3; // Assuming RGB image - std::vector resized_image_buf(img2imgW * img2imgH * img2imgC); - std::vector resized_mask_buf(img2imgW * img2imgH * img2imgC); - std::vector> resized_extraimage_bufs(max_extra_images, std::vector(img2imgW * img2imgH * img2imgC)); + //because the reference image can be larger than the output image, allocate at least enough for 1024x1024 + const int imgMemNeed = std::max(img2imgW * img2imgH * img2imgC + 512, 1024 * 1024 * img2imgC + 512); + std::vector resized_image_buf(imgMemNeed); + std::vector resized_mask_buf(imgMemNeed); + std::vector> resized_extraimage_bufs(max_extra_images, std::vector(imgMemNeed)); std::string ts = get_timestamp_str(); if(!sd_is_quiet) @@ -623,6 +625,18 @@ sd_generation_outputs sdtype_generate(const sd_generation_inputs inputs) } } + //round dims down to 64 + desiredWidth = rounddown_64(desiredWidth); + desiredHeight = rounddown_64(desiredHeight); + if(desiredWidth<64) + { + desiredWidth = 64; + } + if(desiredHeight<64) + { + desiredHeight = 64; + } + if(!sd_is_quiet && sddebugmode==1) { printf("Resize Extraimg: %dx%d to %dx%d\n",nx2,ny2,desiredWidth,desiredHeight);