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