Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
-
from transformers import MllamaForConditionalGeneration, AutoProcessor,
|
2 |
from PIL import Image
|
3 |
-
import os
|
4 |
import requests
|
5 |
import torch
|
6 |
from threading import Thread
|
@@ -8,16 +7,15 @@ import gradio as gr
|
|
8 |
from gradio import FileData
|
9 |
import time
|
10 |
import spaces
|
11 |
-
from src.search import perform_search
|
12 |
|
13 |
hf_token = os.environ.get("HF_KEY")
|
14 |
|
15 |
ckpt = "meta-llama/Llama-3.2-11B-Vision-Instruct"
|
16 |
|
17 |
model = MllamaForConditionalGeneration.from_pretrained(ckpt,
|
18 |
-
torch_dtype=torch.bfloat16
|
19 |
-
|
20 |
-
|
21 |
|
22 |
|
23 |
@spaces.GPU
|
@@ -80,9 +78,7 @@ def bot_streaming(message, history, max_new_tokens=250):
|
|
80 |
demo = gr.ChatInterface(fn=bot_streaming, title="Multimodal Llama", examples=[
|
81 |
[{"text": "Which era does this piece belong to? Give details about the era.", "files":["./examples/rococo.jpg"]},
|
82 |
200],
|
83 |
-
|
84 |
-
250],
|
85 |
-
[{"text": "Where to find this monument? Can you give me other recommendations around the area?", "files":["./examples/wat_arun.jpg"]},
|
86 |
250],
|
87 |
],
|
88 |
textbox=gr.MultimodalTextbox(),
|
|
|
1 |
+
from transformers import MllamaForConditionalGeneration, AutoProcessor, TextIteratorStreamer
|
2 |
from PIL import Image
|
|
|
3 |
import requests
|
4 |
import torch
|
5 |
from threading import Thread
|
|
|
7 |
from gradio import FileData
|
8 |
import time
|
9 |
import spaces
|
|
|
10 |
|
11 |
hf_token = os.environ.get("HF_KEY")
|
12 |
|
13 |
ckpt = "meta-llama/Llama-3.2-11B-Vision-Instruct"
|
14 |
|
15 |
model = MllamaForConditionalGeneration.from_pretrained(ckpt,
|
16 |
+
torch_dtype=torch.bfloat16,
|
17 |
+
token=hf_token).to("cuda")
|
18 |
+
processor = AutoProcessor.from_pretrained(ckpt, token=hf_token)
|
19 |
|
20 |
|
21 |
@spaces.GPU
|
|
|
78 |
demo = gr.ChatInterface(fn=bot_streaming, title="Multimodal Llama", examples=[
|
79 |
[{"text": "Which era does this piece belong to? Give details about the era.", "files":["./examples/rococo.jpg"]},
|
80 |
200],
|
81 |
+
[{"text": "Where do the droughts happen according to this diagram?", "files":["./examples/weather_events.png"]},
|
|
|
|
|
82 |
250],
|
83 |
],
|
84 |
textbox=gr.MultimodalTextbox(),
|