mtmd: fix longest_edge ignoring min/max pixels (#26638)

* mtmd: fix longest_edge ignoring min/max pixels

* nits
This commit is contained in:
Xuan-Son Nguyen
2026-08-07 18:05:15 +02:00
committed by GitHub
parent 4cf5cab65d
commit 4cb22cd537
3 changed files with 65 additions and 47 deletions
+11
View File
@@ -170,6 +170,17 @@ struct clip_hparams {
warmup_image_size = static_cast<int>(std::sqrt(image_max_pixels));
}
// used by longest_edge preprocessor (no model-specific value for min/max tokens)
void set_limit_image_tokens() {
const int patch_area = patch_size * patch_size * n_merge * n_merge;
if (custom_image_min_tokens > 0) {
image_min_pixels = custom_image_min_tokens * patch_area;
}
if (custom_image_max_tokens > 0) {
image_max_pixels = custom_image_max_tokens * patch_area;
}
}
void set_warmup_n_tokens(int n_tokens) {
int n_tok_per_side = static_cast<int>(std::sqrt(n_tokens));
GGML_ASSERT(n_tok_per_side * n_tok_per_side == n_tokens && "n_tokens must be n*n");