Skip to content

Instantly share code, notes, and snippets.

@bigsnarfdude
Last active March 17, 2025 04:58
Show Gist options
  • Save bigsnarfdude/8b075b84ff2830401da496ddcf82c6a2 to your computer and use it in GitHub Desktop.
Save bigsnarfdude/8b075b84ff2830401da496ddcf82c6a2 to your computer and use it in GitHub Desktop.
gemma3onmac.py
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