mudler/LocalAI · error

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

Error message

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

What it means

The reference image path could not be decoded. Guard: verify the reference file exists and is a supported image format before starting the diffusion run; return a clear invalid-argument error.

Source

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

    std::vector<sd_image_t> ref_images_vec;
    std::vector<uint8_t*> ref_image_buffers;

    if (ref_images_count > 0 && ref_images != NULL) {
        fprintf(stderr, "Loading %d reference images\n", ref_images_count);

        for (int i = 0; i < ref_images_count; i++) {
            if (ref_images[i] == NULL || strlen(ref_images[i]) == 0) {
                continue;
            }

            fprintf(stderr, "Loading reference image %d: %s\n", i + 1, ref_images[i]);

            int c = 0;
            int ref_width = 0;
            int ref_height = 0;
            uint8_t* ref_image_buffer = stbi_load(ref_images[i], &ref_width, &ref_height, &c, 3);
            if (ref_image_buffer == NULL) {
                fprintf(stderr, "Failed to load reference image from '%s'\n", ref_images[i]);
                continue;
            }
            if (c < 3) {
                fprintf(stderr, "Reference image must have at least 3 channels, got %d\n", c);
                free(ref_image_buffer);
                continue;
            }

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

                uint8_t* resized_ref_buffer = (uint8_t*)malloc(height * width * 3);
                if (resized_ref_buffer == NULL) {
                    fprintf(stderr, "Failed to allocate memory for resized reference image\n");
                    free(ref_image_buffer);
                    continue;
                }

View on GitHub (pinned to 44413a9d06)

Solutions

  1. Verify the reference image path is correct and the file exists.
  2. Confirm the reference file is a valid image in a supported format.
  3. Check file permissions on the reference image.

When it happens

Trigger: Thrown at backend/go/stablediffusion-ggml/cpp/gosd.cpp:945 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/ffa413ba829779f0. Report an issue: GitHub.