@@ -173,7 +173,7 @@ static int generate_response(mtmd_cli_context & ctx, common_sampler * smpl, int
173173}
174174
175175static int eval_message (mtmd_cli_context & ctx, common_chat_msg & msg, std::vector<std::string> & images_fname, bool add_bos = false ) {
176- std::vector<mtmd_bitmap *> bitmaps;
176+ mtmd::bitmaps bitmaps;
177177
178178 common_chat_templates_inputs tmpl_inputs;
179179 tmpl_inputs.messages = {msg};
@@ -183,12 +183,12 @@ static int eval_message(mtmd_cli_context & ctx, common_chat_msg & msg, std::vect
183183 LOG_DBG (" formatted_chat.prompt: %s\n " , formatted_chat.prompt .c_str ());
184184
185185 for (auto & fname : images_fname) {
186- mtmd_bitmap * bitmap = mtmd_helper_bitmap_init_from_file (fname.c_str ());
187- if (!bitmap ) {
186+ mtmd:: bitmap bmp ( mtmd_helper_bitmap_init_from_file (fname.c_str () ));
187+ if (!bmp. ptr ) {
188188 LOG_ERR (" Unable to load image %s\n " , fname.c_str ());
189189 return 2 ; // image not found
190190 }
191- bitmaps.push_back (std::move (bitmap ));
191+ bitmaps.entries . push_back (std::move (bmp ));
192192 }
193193
194194 mtmd_input_text text;
@@ -199,11 +199,12 @@ static int eval_message(mtmd_cli_context & ctx, common_chat_msg & msg, std::vect
199199 if (g_is_interrupted) return 0 ;
200200
201201 mtmd::input_chunks chunks;
202+ auto bitmaps_c_ptr = bitmaps.c_ptr ();
202203 int32_t res = mtmd_tokenize (ctx.ctx_vision .get (),
203204 chunks.ptr .get (), // output
204205 &text, // text
205- bitmaps .data (), // bitmaps
206- bitmaps .size ());
206+ bitmaps_c_ptr .data (),
207+ bitmaps_c_ptr .size ());
207208 if (res != 0 ) {
208209 LOG_ERR (" Unable to tokenize prompt, res = %d\n " , res);
209210 return 1 ;
0 commit comments