Skip to content

Commit f52d59d

Browse files
authored
llava : fix clip loading GGUFs with missing description (#12660)
1 parent 52de2e5 commit f52d59d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

examples/llava/clip.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1396,14 +1396,16 @@ struct clip_ctx * clip_init(const char * fname, struct clip_context_params ctx_p
13961396
const int n_kv = gguf_get_n_kv(ctx);
13971397
const int ftype = get_u32(ctx, KEY_FTYPE);
13981398
const std::string ftype_str = get_ftype(ftype);
1399-
const int idx_desc = get_key_idx(ctx, KEY_DESCRIPTION);
1400-
const std::string description = gguf_get_val_str(ctx, idx_desc);
14011399
const int idx_name = gguf_find_key(ctx, KEY_NAME);
14021400
if (idx_name != -1) { // make name optional temporarily as some of the uploaded models missing it due to a bug
14031401
const std::string name = gguf_get_val_str(ctx, idx_name);
14041402
LOG_INF("%s: model name: %s\n", __func__, name.c_str());
14051403
}
1406-
LOG_INF("%s: description: %s\n", __func__, description.c_str());
1404+
const int idx_desc = get_key_idx(ctx, KEY_DESCRIPTION);
1405+
if (idx_desc != -1) { // ditto
1406+
const std::string description = gguf_get_val_str(ctx, idx_desc);
1407+
LOG_INF("%s: description: %s\n", __func__, description.c_str());
1408+
}
14071409
LOG_INF("%s: GGUF version: %d\n", __func__, gguf_get_version(ctx));
14081410
LOG_INF("%s: alignment: %zu\n", __func__, gguf_get_alignment(ctx));
14091411
LOG_INF("%s: n_tensors: %d\n", __func__, n_tensors);

0 commit comments

Comments
 (0)