Last active
March 17, 2025 04:58
-
-
Save bigsnarfdude/8b075b84ff2830401da496ddcf82c6a2 to your computer and use it in GitHub Desktop.
gemma3onmac.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
from transformers import pipeline | |
pipe = pipeline( | |
"image-text-to-text", | |
device="mps", | |
model="google/gemma-3-12b-it" # "google/gemma-3-27b-it" | |
) | |
messages = [ | |
{ | |
"role": "user", | |
"content": [ | |
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, | |
{"type": "text", "text": "What animal is on the candy?"} | |
] | |
} | |
] | |
output = pipe(text=messages, max_new_tokens=200) | |
print(output[0]["generated_text"][-1]["content"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment