Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,18 +1,13 @@
|
|
1 |
-
import gradio as gr
|
2 |
import torch
|
3 |
-
|
|
|
|
|
4 |
|
5 |
# Model name
|
6 |
model_name = "MONAI/Llama3-VILA-M3-8B"
|
7 |
|
8 |
-
# Load
|
9 |
-
tokenizer =
|
10 |
-
model = AutoModelForCausalLM.from_pretrained(
|
11 |
-
model_name,
|
12 |
-
torch_dtype=torch.float16,
|
13 |
-
device_map="auto",
|
14 |
-
trust_remote_code=True
|
15 |
-
)
|
16 |
|
17 |
def generate_response(prompt):
|
18 |
inputs = tokenizer(prompt, return_tensors="pt").to("cuda" if torch.cuda.is_available() else "cpu")
|
@@ -25,8 +20,8 @@ iface = gr.Interface(
|
|
25 |
fn=generate_response,
|
26 |
inputs=gr.Textbox(lines=2, placeholder="Enter your prompt..."),
|
27 |
outputs="text",
|
28 |
-
title="
|
29 |
-
description="A chatbot powered by
|
30 |
)
|
31 |
|
32 |
iface.launch()
|
|
|
|
|
1 |
import torch
|
2 |
+
import gradio as gr
|
3 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
4 |
+
from llava.model.builder import load_pretrained_model # Import LLaVA model builder
|
5 |
|
6 |
# Model name
|
7 |
model_name = "MONAI/Llama3-VILA-M3-8B"
|
8 |
|
9 |
+
# Load LLaVA model
|
10 |
+
tokenizer, model, _ = load_pretrained_model(model_path=model_name, model_base=None, device="cuda" if torch.cuda.is_available() else "cpu")
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
def generate_response(prompt):
|
13 |
inputs = tokenizer(prompt, return_tensors="pt").to("cuda" if torch.cuda.is_available() else "cpu")
|
|
|
20 |
fn=generate_response,
|
21 |
inputs=gr.Textbox(lines=2, placeholder="Enter your prompt..."),
|
22 |
outputs="text",
|
23 |
+
title="LLaVA Llama3-VILA-M3-8B Chatbot",
|
24 |
+
description="A chatbot powered by LLaVA and Llama3-VILA-M3-8B",
|
25 |
)
|
26 |
|
27 |
iface.launch()
|