Skip to content

Commit

Permalink
C2131: expression did not evaluate to a constan
Browse files Browse the repository at this point in the history
  • Loading branch information
ua741 committed Oct 25, 2023
1 parent 2148921 commit b448a37
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions clip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1386,8 +1386,10 @@ bool clip_compare_text_and_image(const clip_ctx * ctx, const int n_threads, cons

// prepare image and text vectors
int projection_dim = ctx->vision_model.hparams.projection_dim;
float img_vec[projection_dim];
float txt_vec[projection_dim];
std::vector<float> img_vec(projection_dim);
std::vector<float> txt_vec(projection_dim);
// float img_vec[projection_dim];
// float txt_vec[projection_dim];

// tokenize and encode text
clip_tokens tokens;
Expand Down Expand Up @@ -1481,8 +1483,9 @@ bool clip_zero_shot_label_image(struct clip_ctx * ctx, const int n_threads, cons

clip_image_preprocess(ctx, input_img, &img_res);

float img_vec[vec_dim];
float* img_vec = new float[vec_dim];
if (!clip_image_encode(ctx, n_threads, &img_res, img_vec, false)) {
delete[] img_vec;
return false;
}

Expand All @@ -1499,12 +1502,10 @@ bool clip_zero_shot_label_image(struct clip_ctx * ctx, const int n_threads, cons
clip_text_encode(ctx, n_threads, &tokens, txt_vec, false);
similarities[i] = clip_similarity_score(img_vec, txt_vec, vec_dim);
}


delete[] img_vec;
delete[] txt_vec;
delete[] similarities;


// apply softmax and sort scores
softmax_with_sorting(similarities, n_labels, scores, indices);

Expand Down

0 comments on commit b448a37

Please sign in to comment.