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

Function llava_image_embed_make_with_bytes

examples/llava/llava.cpp:88–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

86}
87
88LLAVA_API struct llava_image_embed * llava_image_embed_make_with_bytes(struct clip_ctx * ctx_clip, int n_threads, const unsigned char * image_bytes, int image_bytes_length) {
89 clip_image_u8 * img = make_clip_image_u8();
90 if (!clip_image_load_from_bytes(image_bytes, image_bytes_length, img)) {
91 clip_image_u8_free(img);
92 fprintf(stderr, "%s: can't load image from bytes, is it a valid image?", __func__);
93 return NULL;
94 }
95
96 float* image_embed = NULL;
97 int n_image_pos = 0;
98 bool image_embed_result = llava_image_embed_make_with_clip_img(ctx_clip, n_threads, img, &image_embed, &n_image_pos);
99 if (!image_embed_result) {
100 clip_image_u8_free(img);
101 fprintf(stderr, "%s: coulnd't embed the image\n", __func__);
102 return NULL;
103 }
104
105 clip_image_u8_free(img);
106 auto result = (llava_image_embed*)malloc(sizeof(llava_image_embed));
107 result->embed = image_embed;
108 result->n_image_pos = n_image_pos;
109 return result;
110}
111
112static bool load_file_to_bytes(const char* path, unsigned char** bytesOut, long *sizeOut) {
113 auto file = fopen(path, "rb");

Calls 5

make_clip_image_u8Function · 0.85
fprintfFunction · 0.85
clip_image_u8_freeFunction · 0.70

Tested by

no test coverage detected