@@ -931,18 +931,6 @@ int main(int argc, const char* argv[]) {
931
931
}
932
932
}
933
933
934
- if (params.mask_path != " " ) {
935
- int c = 0 ;
936
- mask_image_buffer = stbi_load (params.mask_path .c_str (), ¶ms.width , ¶ms.height , &c, 1 );
937
- } else {
938
- std::vector<uint8_t > arr (params.width * params.height , 255 );
939
- mask_image_buffer = arr.data ();
940
- }
941
- sd_image_t mask_image = {(uint32_t )params.width ,
942
- (uint32_t )params.height ,
943
- 1 ,
944
- mask_image_buffer};
945
-
946
934
sd_image_t * results;
947
935
if (params.mode == TXT2IMG) {
948
936
results = txt2img (sd_ctx,
@@ -1011,6 +999,19 @@ int main(int argc, const char* argv[]) {
1011
999
free_sd_ctx (sd_ctx);
1012
1000
return 0 ;
1013
1001
} else {
1002
+ if (params.mask_path != " " ) {
1003
+ int c = 0 ;
1004
+ mask_image_buffer = stbi_load (params.mask_path .c_str (), ¶ms.width , ¶ms.height , &c, 1 );
1005
+ } else {
1006
+ std::vector<uint8_t > arr (params.width * params.height , 255 );
1007
+ for (uint8_t dummy_arr : arr) if (dummy_arr) break ; // dummy cycle to avoid -O3 optimization
1008
+ mask_image_buffer = arr.data ();
1009
+ }
1010
+ sd_image_t mask_image = {(uint32_t )params.width ,
1011
+ (uint32_t )params.height ,
1012
+ 1 ,
1013
+ mask_image_buffer};
1014
+ LOG_DEBUG (" img2img: created mask with 0x%x fill" , *mask_image.data );
1014
1015
results = img2img (sd_ctx,
1015
1016
input_image,
1016
1017
mask_image,
0 commit comments