MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / load_image

Function load_image

examples/llava/llava-cli.cpp:181–205  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

179}
180
181static 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
207static 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;

Callers 1

mainFunction · 0.85

Calls 8

prompt_contains_imageFunction · 0.85
printfFunction · 0.85
fprintfFunction · 0.85
remove_image_from_promptFunction · 0.85
emptyMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected