{"record":{"id":"d2f5da8c9e4e6cc3","repo":"mudler/LocalAI","slug":"failed-to-load-mask-image-from-s-n","errorCode":null,"errorMessage":"Failed to load mask image from '%s'\\n","messagePattern":"Failed to load mask image from '(.+?)'\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/go/stablediffusion-ggml/cpp/gosd.cpp","lineNumber":890,"sourceCode":"        p->init_image = {(uint32_t)width, (uint32_t)height, 3, input_image_buffer};\n        p->strength = strength;\n        fprintf(stderr, \"Using img2img with strength: %.2f\\n\", strength);\n    } else {\n        // No input image, use empty image for text-to-image\n        p->init_image = {(uint32_t)width, (uint32_t)height, 3, NULL};\n        p->strength = 0.0f;\n    }\n\n    // Handle mask image for inpainting\n    if (has_mask_image) {\n        fprintf(stderr, \"Loading mask image: %s\\n\", mask_image);\n\n        int c = 0;\n        int mask_width = 0;\n        int mask_height = 0;\n        mask_image_buffer = stbi_load(mask_image, &mask_width, &mask_height, &c, 1);\n        if (mask_image_buffer == NULL) {\n            fprintf(stderr, \"Failed to load mask image from '%s'\\n\", mask_image);\n            if (input_image_buffer) free(input_image_buffer);\n            return 1;\n        }\n\n        // Resize mask if dimensions don't match\n        if (mask_width != width || mask_height != height) {\n            fprintf(stderr, \"Resizing mask image from %dx%d to %dx%d\\n\", mask_width, mask_height, width, height);\n\n            uint8_t* resized_mask_buffer = (uint8_t*)malloc(height * width);\n            if (resized_mask_buffer == NULL) {\n                fprintf(stderr, \"Failed to allocate memory for resized mask\\n\");\n                free(mask_image_buffer);\n                if (input_image_buffer) free(input_image_buffer);\n                return 1;\n            }\n\n            stbir_resize(mask_image_buffer, mask_width, mask_height, 0,\n                         resized_mask_buffer, width, height, 0, STBIR_TYPE_UINT8,","sourceCodeStart":872,"sourceCodeEnd":908,"githubUrl":"https://github.com/mudler/LocalAI/blob/44413a9d06bf5bc52ce088ba8ca74e5a2e8bee26/backend/go/stablediffusion-ggml/cpp/gosd.cpp#L872-L908","documentation":"The mask image path given for inpainting could not be decoded. Guard: verify the mask file exists, is a supported image format, and matches the input image dimensions before starting the diffusion run.","triggerScenarios":"Thrown at backend/go/stablediffusion-ggml/cpp/gosd.cpp:890 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the mask image path is correct and the file exists.","Confirm the mask file is a valid image in a supported format (PNG/JPEG).","Check file permissions on the mask image."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"44413a9d06bf5bc52ce088ba8ca74e5a2e8bee26","analyzedAt":"2026-08-15T10:13:50.291Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}