Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions tools/mtmd/mtmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,22 @@ int mtmd_get_audio_bitrate(mtmd_context * ctx) {
return 16000; // 16kHz
}

int mtmd_get_vision_image_size(mtmd_context * ctx) {
if (!ctx->ctx_v) {
return -1;
}

return clip_get_image_size(ctx->ctx_v);
}

int mtmd_get_vision_patch_size(mtmd_context * ctx) {
if (!ctx->ctx_v) {
return -1;
}

return clip_get_patch_size(ctx->ctx_v);
}

//
// public API functions
//
Expand Down
8 changes: 8 additions & 0 deletions tools/mtmd/mtmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@ MTMD_API bool mtmd_support_audio(mtmd_context * ctx);
// return -1 if audio is not supported
MTMD_API int mtmd_get_audio_bitrate(mtmd_context * ctx);

// get vision image size in pixels, for example 1024
// return -1 if vision is not supported
MTMD_API int mtmd_get_vision_image_size(mtmd_context * ctx);
Comment on lines +115 to +117
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a good idea to add this, as many models now support dynamic resolution and this won't give the correct size

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, some models are fixed res, some are naflex.

The presumption is that if you want to do your own pre-processing, you will need to be familiar with what the model you are using expects.


// get vision patch size, for example 14
// return -1 if vision is not supported
MTMD_API int mtmd_get_vision_patch_size(mtmd_context * ctx);

// mtmd_bitmap
//
// if bitmap is image:
Expand Down
Loading