mudler/LocalAI · error

Failed to load image from '%s'\n

Error message

Failed to load image from '%s'\n

What it means

An input image could not be decoded from the given path. Guard: verify the file exists and is a supported image format before use; return an invalid-argument error naming the path.

Source

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

void sd_vid_gen_params_set_seed(sd_vid_gen_params_t *params, int64_t seed) {
    params->seed = seed;
}

void sd_vid_gen_params_set_video_frames(sd_vid_gen_params_t *params, int n) {
    params->video_frames = n;
}

// Load an image file into an sd_image_t, resizing to target dims if needed.
// Returns a heap-allocated buffer the caller must free (or nullptr on failure).
static uint8_t* load_and_resize_image(const char* path, int target_width, int target_height, sd_image_t* out) {
    if (!path || strlen(path) == 0) {
        *out = {0, 0, 0, nullptr};
        return nullptr;
    }
    int c = 0, img_w = 0, img_h = 0;
    uint8_t* buf = stbi_load(path, &img_w, &img_h, &c, 3);
    if (!buf) {
        fprintf(stderr, "Failed to load image from '%s'\n", path);
        *out = {0, 0, 0, nullptr};
        return nullptr;
    }
    if (img_w != target_width || img_h != target_height) {
        fprintf(stderr, "Resizing image from %dx%d to %dx%d\n", img_w, img_h, target_width, target_height);
        uint8_t* resized = (uint8_t*)malloc((size_t)target_width * target_height * 3);
        if (!resized) { free(buf); *out = {0, 0, 0, nullptr}; return nullptr; }
        stbir_resize(buf, img_w, img_h, 0,
                     resized, target_width, target_height, 0, STBIR_TYPE_UINT8,
                     3, STBIR_ALPHA_CHANNEL_NONE, 0,
                     STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP,
                     STBIR_FILTER_BOX, STBIR_FILTER_BOX,
                     STBIR_COLORSPACE_SRGB, nullptr);
        free(buf);
        buf = resized;
    }
    *out = {(uint32_t)target_width, (uint32_t)target_height, 3, buf};
    return buf;

View on GitHub (pinned to 44413a9d06)

Solutions

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

When it happens

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