Open
Description
The current implementation of clip_model_load()
seems incorrectly assigns mean and standard deviation values to the image_mean
and image_std
fields.
The existing code fetches data for all three color channels (presumably RGB) but fails to iterate through the retrieved arrays. This results in all channels being assigned the first value of the respective image_mean
and image_std
arrays.
The original code is as this:
int idx_mean = get_key_idx(ctx, KEY_IMAGE_MEAN);
int idx_std = get_key_idx(ctx, KEY_IMAGE_STD);
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));
}
To rectify this, the code should access the correct index within the retrieved arrays for each color channel, as shown below:
int idx_mean = get_key_idx(ctx, KEY_IMAGE_MEAN);
int idx_std = get_key_idx(ctx, KEY_IMAGE_STD);
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);
}
Metadata
Metadata
Assignees
Labels
No labels