Skip to content

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

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"?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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