[GH-ISSUE #9767] How to input image to gemma3 #52897

Closed
opened 2026-04-29 01:18:19 -05:00 by GiteaMirror · 6 comments
Owner

Originally created by @wrx33 on GitHub (Mar 14, 2025).
Original GitHub issue: https://github.com/ollama/ollama/issues/9767

I have run gemma3 by "ollama run gemma3", and it can generate output when I input text.
I run it in the command line. How to input image to gemma3?

Originally created by @wrx33 on GitHub (Mar 14, 2025). Original GitHub issue: https://github.com/ollama/ollama/issues/9767 I have run gemma3 by "ollama run gemma3", and it can generate output when I input text. I run it in the command line. How to input image to gemma3?
Author
Owner

@rick-github commented on GitHub (Mar 14, 2025):

Add the path to the image.

$ ollama run gemma3
>>> describe this image: ./puppy.jpg
Added image './puppy.jpg'
Here’s a description of the image:

**Overall Impression:**

The image shows a very cute, fluffy, white puppy sitting on a stone step. It’s a heartwarming and adorable photo.
<!-- gh-comment-id:2724542775 --> @rick-github commented on GitHub (Mar 14, 2025): Add the path to the image. ```console $ ollama run gemma3 >>> describe this image: ./puppy.jpg Added image './puppy.jpg' Here’s a description of the image: **Overall Impression:** The image shows a very cute, fluffy, white puppy sitting on a stone step. It’s a heartwarming and adorable photo. ```
Author
Owner

@MichaelCombs28 commented on GitHub (Mar 14, 2025):

I've run into issues as well where the server responds with a 500.

Turns out the issue for me was GPU memory, I'm using gemma3:27b.

ggml_backend_cuda_buffer_type_alloc_buffer: allocating 53273.01 MiB on device 0: cudaMalloc failed: out of memory
Mar 14 09:42:36 my-pc ollama[482610]: ggml_gallocr_reserve_n: failed to allocate CUDA0 buffer of size 55860802560
Mar 14 09:42:36 my-pc ollama[482610]: SIGSEGV: segmentation violation
Mar 14 09:42:36 my-pc ollama[482610]: PC=0x5e7acac62fd0 m=60 sigcode=1 addr=0x58
Mar 14 09:42:36 my-pc ollama[482610]: signal arrived during cgo execution

I fetched these logs with journalctl -u ollama

It might be ideal to return the actual error message, I'll open a PR when I have time later today.

<!-- gh-comment-id:2725222728 --> @MichaelCombs28 commented on GitHub (Mar 14, 2025): I've run into issues as well where the server responds with a 500. Turns out the issue for me was GPU memory, I'm using `gemma3:27b`. ``` ggml_backend_cuda_buffer_type_alloc_buffer: allocating 53273.01 MiB on device 0: cudaMalloc failed: out of memory Mar 14 09:42:36 my-pc ollama[482610]: ggml_gallocr_reserve_n: failed to allocate CUDA0 buffer of size 55860802560 Mar 14 09:42:36 my-pc ollama[482610]: SIGSEGV: segmentation violation Mar 14 09:42:36 my-pc ollama[482610]: PC=0x5e7acac62fd0 m=60 sigcode=1 addr=0x58 Mar 14 09:42:36 my-pc ollama[482610]: signal arrived during cgo execution ``` I fetched these logs with `journalctl -u ollama` It might be ideal to return the actual error message, I'll open a PR when I have time later today.
Author
Owner

@pdevine commented on GitHub (Mar 14, 2025):

I'm going to go ahead and close this as answered (thanks @rick-github !).

@MichaelCombs28 0.6.1 is just about to come out which has some memory fixes (gemma3:27b should work better).

<!-- gh-comment-id:2725564539 --> @pdevine commented on GitHub (Mar 14, 2025): I'm going to go ahead and close this as answered (thanks @rick-github !). @MichaelCombs28 `0.6.1` is just about to come out which has some memory fixes (gemma3:27b should work better).
Author
Owner

@wrx33 commented on GitHub (Mar 17, 2025):

Add the path to the image.

$ ollama run gemma3

describe this image: ./puppy.jpg
Added image './puppy.jpg'
Here’s a description of the image:

Overall Impression:

The image shows a very cute, fluffy, white puppy sitting on a stone step. It’s a heartwarming and adorable photo.

Thanks for helping. But when I input the image path, I got the response: "I can not access the local file system, so I can not read the image".

<!-- gh-comment-id:2727968668 --> @wrx33 commented on GitHub (Mar 17, 2025): > Add the path to the image. > > $ ollama run gemma3 > >>> describe this image: ./puppy.jpg > Added image './puppy.jpg' > Here’s a description of the image: > > **Overall Impression:** > > The image shows a very cute, fluffy, white puppy sitting on a stone step. It’s a heartwarming and adorable photo. Thanks for helping. But when I input the image path, I got the response: "I can not access the local file system, so I can not read the image".
Author
Owner

@pdevine commented on GitHub (Mar 17, 2025):

@wangrx33 can you cut and paste the prompt? Also, what OS are you using?

<!-- gh-comment-id:2728104511 --> @pdevine commented on GitHub (Mar 17, 2025): @wangrx33 can you cut and paste the prompt? Also, what OS are you using?
Author
Owner

@user202729 commented on GitHub (May 5, 2025):

This is described in the blog.

https://ollama.com/blog/vision-models

However, there's some magic to it. The user input is parsed against a certain regex to extract file names to be loaded.

7e5c8eee5c/cmd/interactive.go (L510-L538)

In particular:

  • The file extension must be .jpg, .png or .jpeg.
  • The file must exists. Otherwise it will fail silently without any error message.
  • If it's successful, you should see a line that is exactly Added image '<file path>' (with the <file path> replaced with your file path)
  • If the model does not accept image, it will again silently fail.

The model otherwise cannot access the local file system by itself. (I think.)

There's also report that jpg works better than png https://github.com/ollama/ollama/issues/7596 , although it's not clear why.

<!-- gh-comment-id:2851551204 --> @user202729 commented on GitHub (May 5, 2025): This is described in the blog. https://ollama.com/blog/vision-models However, there's some magic to it. The user input is parsed against a certain regex to extract file names to be loaded. https://github.com/ollama/ollama/blob/7e5c8eee5c65bcf7c0d46d5fe3b084fd70d36015/cmd/interactive.go#L510-L538 In particular: * The file extension must be `.jpg`, `.png` or `.jpeg`. * The file must exists. Otherwise it will fail silently without any error message. * If it's successful, you should see a line that is exactly `Added image '<file path>'` (with the `<file path>` replaced with your file path) * If the model does not accept image, it will again silently fail. The model otherwise cannot access the local file system by itself. (I think.) There's also report that jpg works better than png https://github.com/ollama/ollama/issues/7596 , although it's not clear why.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#52897