| 179 | } |
| 180 | |
| 181 | static struct llava_image_embed * load_image(llava_context * ctx_llava, gpt_params * params) { |
| 182 | |
| 183 | // load and preprocess the image |
| 184 | llava_image_embed * embed = NULL; |
| 185 | auto prompt = params->prompt; |
| 186 | if (prompt_contains_image(prompt)) { |
| 187 | if (!params->image.empty()) { |
| 188 | printf("using base64 encoded image instead of command line image path\n"); |
| 189 | } |
| 190 | embed = llava_image_embed_make_with_prompt_base64(ctx_llava->ctx_clip, params->n_threads, prompt); |
| 191 | if (!embed) { |
| 192 | fprintf(stderr, "%s: can't load image from prompt\n", __func__); |
| 193 | return NULL; |
| 194 | } |
| 195 | params->prompt = remove_image_from_prompt(prompt); |
| 196 | } else { |
| 197 | embed = llava_image_embed_make_with_filename(ctx_llava->ctx_clip, params->n_threads, params->image.c_str()); |
| 198 | if (!embed) { |
| 199 | fprintf(stderr, "%s: is %s really an image file?\n", __func__, params->image.c_str()); |
| 200 | return NULL; |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | return embed; |
| 205 | } |
| 206 | |
| 207 | static void process_prompt(struct llava_context * ctx_llava, struct llava_image_embed * image_embed, gpt_params * params, const std::string & prompt) { |
| 208 | int n_past = 0; |
no test coverage detected