mudler/LocalAI · error

Failed to load mask image from '%s'\n

Error message

Failed to load mask image from '%s'\n

What it means

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.

Source

Thrown at backend/go/stablediffusion-ggml/cpp/gosd.cpp:890

        p->init_image = {(uint32_t)width, (uint32_t)height, 3, input_image_buffer};
        p->strength = strength;
        fprintf(stderr, "Using img2img with strength: %.2f\n", strength);
    } else {
        // No input image, use empty image for text-to-image
        p->init_image = {(uint32_t)width, (uint32_t)height, 3, NULL};
        p->strength = 0.0f;
    }

    // Handle mask image for inpainting
    if (has_mask_image) {
        fprintf(stderr, "Loading mask image: %s\n", mask_image);

        int c = 0;
        int mask_width = 0;
        int mask_height = 0;
        mask_image_buffer = stbi_load(mask_image, &mask_width, &mask_height, &c, 1);
        if (mask_image_buffer == NULL) {
            fprintf(stderr, "Failed to load mask image from '%s'\n", mask_image);
            if (input_image_buffer) free(input_image_buffer);
            return 1;
        }

        // Resize mask if dimensions don't match
        if (mask_width != width || mask_height != height) {
            fprintf(stderr, "Resizing mask image from %dx%d to %dx%d\n", mask_width, mask_height, width, height);

            uint8_t* resized_mask_buffer = (uint8_t*)malloc(height * width);
            if (resized_mask_buffer == NULL) {
                fprintf(stderr, "Failed to allocate memory for resized mask\n");
                free(mask_image_buffer);
                if (input_image_buffer) free(input_image_buffer);
                return 1;
            }

            stbir_resize(mask_image_buffer, mask_width, mask_height, 0,
                         resized_mask_buffer, width, height, 0, STBIR_TYPE_UINT8,

View on GitHub (pinned to 44413a9d06)

Solutions

  1. Verify the mask image path is correct and the file exists.
  2. Confirm the mask file is a valid image in a supported format (PNG/JPEG).
  3. Check file permissions on the mask image.

When it happens

Trigger: Thrown at backend/go/stablediffusion-ggml/cpp/gosd.cpp:890 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of mudler/LocalAI@44413a9d06 (2026-08-15). Data as JSON: /api/errors/d2f5da8c9e4e6cc3. Report an issue: GitHub.