Skip to content

mtmd-cli : fix out_of_range when input image path is empty #13244

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
May 2, 2025

Conversation

ahmedshakill
Copy link
Contributor

Taking substring for the input case
"/image"
results in out_of_range exception.
Screenshot from 2025-05-02 01-57-57

This PR adds a check so that doesn't happen. This maintains the continuation of the loop.

Screenshot from 2025-05-02 02-00-07

@@ -308,7 +308,7 @@ int main(int argc, char ** argv) {
}
g_is_generating = true;
if (line.find("/image") == 0) {
std::string image = line.substr(7);
std::string image = (line.size()>=7) ? line.substr(7) : "";
Copy link
Collaborator

Choose a reason for hiding this comment

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

hmm this logic looks a bit hacky, I will replace it with something cleaner

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, please. Thanks for checking out.

Co-authored-by: Sigbjørn Skjæret <[email protected]>
@ahmedshakill ahmedshakill requested review from CISC and ngxson May 1, 2025 20:30
@ngxson
Copy link
Collaborator

ngxson commented May 1, 2025

@CISC what I want to do is to load the image right away if possible, will push a commit for it

@ngxson
Copy link
Collaborator

ngxson commented May 1, 2025

The CLI will try to load image right away, so it can now detect if the image is not exist:

> /image 
ERR: Missing image filename

> /image abcdef
clip_image_load_from_file: failed to load image 'abcdef'
Unable to load image abcdef

@ngxson ngxson changed the title [llama-mtmd-cli] fix out_of_range error to keep the chat loop running mtmd-cli : fix out_of_range when input image path is empty May 1, 2025
Co-authored-by: Sigbjørn Skjæret <[email protected]>
@ngxson ngxson merged commit e84773a into ggml-org:master May 2, 2025
50 of 51 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants