Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -33,10 +33,20 @@ def predict(image, text):
|
|
33 |
inputs = processor(image, input_text, return_tensors="pt").to(model.device)
|
34 |
outputs = model.generate(**inputs, max_new_tokens=250)
|
35 |
response = processor.decode(outputs[0], skip_special_tokens=True)
|
36 |
-
# Split the response at the first occurrence of "assistant" and return only the part after it
|
37 |
response = response.split("assistant", 1)[1].strip()
|
38 |
return f"\n{response}"
|
39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
# Gradio
|
41 |
interface = gr.Interface(
|
42 |
fn=predict,
|
@@ -46,7 +56,8 @@ interface = gr.Interface(
|
|
46 |
],
|
47 |
outputs=gr.Textbox(label="Output"),
|
48 |
title="Llama 3.2 11B Vision Instruct Chat",
|
49 |
-
description="Image + text chat."
|
|
|
50 |
)
|
51 |
|
52 |
interface.launch()
|
|
|
33 |
inputs = processor(image, input_text, return_tensors="pt").to(model.device)
|
34 |
outputs = model.generate(**inputs, max_new_tokens=250)
|
35 |
response = processor.decode(outputs[0], skip_special_tokens=True)
|
36 |
+
# Split the response at the first occurrence of "assistant" and return only the part after it
|
37 |
response = response.split("assistant", 1)[1].strip()
|
38 |
return f"\n{response}"
|
39 |
|
40 |
+
# Example photos and prompts
|
41 |
+
examples = [
|
42 |
+
{"image": "Cowboy Hat.jpg", "text": "Describe the photo"},
|
43 |
+
{"image": "Kynda Coffee.jpg", "text": "Search for the business name on his t-shirt to get a description of where the person is."},
|
44 |
+
{"image": "Norway.jpg", "text": "Where is this person?"}
|
45 |
+
]
|
46 |
+
|
47 |
+
# Load example images
|
48 |
+
example_images = [Image.open(example["image"]) for example in examples]
|
49 |
+
|
50 |
# Gradio
|
51 |
interface = gr.Interface(
|
52 |
fn=predict,
|
|
|
56 |
],
|
57 |
outputs=gr.Textbox(label="Output"),
|
58 |
title="Llama 3.2 11B Vision Instruct Chat",
|
59 |
+
description="Image + text chat.",
|
60 |
+
examples=[{"image": image, "text": example["text"]} for image, example in zip(example_images, examples)]
|
61 |
)
|
62 |
|
63 |
interface.launch()
|