Skip to content

image_mean and image_std are not read properly from gguf file #104

@herf

Description

@herf

Around L539 in clip.cpp:

        for (int i = 0; i < 3; ++i) {
            new_clip->image_mean[i] = *((float *)gguf_get_arr_data(ctx, idx_mean));
            new_clip->image_std[i] = *((float *)gguf_get_arr_data(ctx, idx_std));
        }

This code will read the mean[0] and std[0] into all three members (rather than the actual vector[3]).

It should say:

        for (int i = 0; i < 3; ++i) {
            new_clip->image_mean[i] = ((float *)gguf_get_arr_data(ctx, idx_mean))[i];
            new_clip->image_std[i] = ((float *)gguf_get_arr_data(ctx, idx_std))[i];
        }

Probably should also validate the array size before doing this - is gguf_get_arr_n() "length"?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions