@@ -171,7 +171,7 @@ struct clip_hparams {
171171 int32_t n_head;
172172 int32_t n_layer;
173173 // idefics3
174- int32_t preproc_image_size = 0 ;
174+ int32_t preproc_image_size = 0 ; // aka max_dimension
175175 int32_t proj_scale_factor = 0 ;
176176
177177 float image_mean[3 ];
@@ -3221,8 +3221,8 @@ struct image_manipulation {
32213221 return {0 , 0 };
32223222 }
32233223
3224- float scale = std::min (1 . 0f , std::min ( static_cast <float >(max_dimension) / inp_size.width ,
3225- static_cast <float >(max_dimension) / inp_size.height ) );
3224+ float scale = std::min (static_cast <float >(max_dimension) / inp_size.width ,
3225+ static_cast <float >(max_dimension) / inp_size.height );
32263226
32273227 float target_width_f = static_cast <float >(inp_size.width ) * scale;
32283228 float target_height_f = static_cast <float >(inp_size.height ) * scale;
@@ -3385,7 +3385,7 @@ struct llava_uhd {
33853385
33863386 // resize to overview size
33873387 clip_image_u8_ptr resized_img (clip_image_u8_init ());
3388- image_manipulation::bicubic_resize (*img, *resized_img, inst.overview_size . width , inst. overview_size . height );
3388+ image_manipulation::resize_and_pad_image (*img, *resized_img, inst.overview_size );
33893389 output.push_back (std::move (resized_img));
33903390 if (inst.slices .empty ()) {
33913391 // no slices, just return the resized image
@@ -3587,6 +3587,9 @@ bool clip_image_preprocess(struct clip_ctx * ctx, const clip_image_u8 * img, str
35873587 // CITE: https://github.com/huggingface/transformers/blob/main/src/transformers/models/idefics3/image_processing_idefics3.py#L737
35883588 const clip_image_size refined_size = image_manipulation::calc_size_preserved_ratio (
35893589 original_size, params.image_size , params.preproc_image_size );
3590+ // LOG_INF("%s: original size: %d x %d, refined size: %d x %d\n",
3591+ // __func__, original_size.width, original_size.height,
3592+ // refined_size.width, refined_size.height);
35903593
35913594 llava_uhd::slice_instructions instructions;
35923595 instructions.overview_size = clip_image_size{params.image_size , params.image_size };
@@ -3597,6 +3600,7 @@ bool clip_image_preprocess(struct clip_ctx * ctx, const clip_image_u8 * img, str
35973600 };
35983601 for (int y = 0 ; y < refined_size.height ; y += params.image_size ) {
35993602 for (int x = 0 ; x < refined_size.width ; x += params.image_size ) {
3603+ // LOG_INF("%s: adding slice at x=%d, y=%d\n", __func__, x, y);
36003604 instructions.slices .push_back (llava_uhd::slice_coordinates{
36013605 /* x */ x,
36023606 /* y */ y,
0 commit comments