Spaces:
Runtime error
Runtime error
File size: 750 Bytes
3735196 f88cd0f 3735196 f88cd0f 3735196 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
import gradio as gr
from transformers import pipeline
import torch
pipe = pipeline(
"image-text-to-text",
model="google/gemma-3-4b-it",
device="cuda",
torch_dtype=torch.bfloat16
)
def greet(name):
messages = [
{
"role": "system",
"content": [{"type": "text", "text": "You are a helpful assistant."}]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"},
{"type": "text", "text": name}
]
}
]
output = pipe(text=messages, max_new_tokens=200)
return output
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
demo.launch()
|