Spaces:
Runtime error
Runtime error
Update model.py
Browse files
model.py
CHANGED
@@ -9,7 +9,10 @@ device = "cuda"
|
|
9 |
|
10 |
# Load the model and tokenizer
|
11 |
model = AutoModel.from_pretrained(
|
12 |
-
"openbmb/MiniCPM-V-2_6",
|
|
|
|
|
|
|
13 |
)
|
14 |
model = model.to(device=device)
|
15 |
tokenizer = AutoTokenizer.from_pretrained(
|
@@ -22,11 +25,10 @@ model.eval()
|
|
22 |
def answer_question(image, question):
|
23 |
"""
|
24 |
Generates an answer to a given question based on the provided image and question.
|
25 |
-
|
26 |
Args:
|
27 |
- image (str): The path to the image file.
|
28 |
- question (str): The question text.
|
29 |
-
|
30 |
Returns:
|
31 |
str: The generated answer to the question.
|
32 |
"""
|
|
|
9 |
|
10 |
# Load the model and tokenizer
|
11 |
model = AutoModel.from_pretrained(
|
12 |
+
"openbmb/MiniCPM-V-2_6",
|
13 |
+
trust_remote_code=True,
|
14 |
+
attn_implementation="sdpa",
|
15 |
+
torch_dtype=torch.bfloat16,
|
16 |
)
|
17 |
model = model.to(device=device)
|
18 |
tokenizer = AutoTokenizer.from_pretrained(
|
|
|
25 |
def answer_question(image, question):
|
26 |
"""
|
27 |
Generates an answer to a given question based on the provided image and question.
|
28 |
+
|
29 |
Args:
|
30 |
- image (str): The path to the image file.
|
31 |
- question (str): The question text.
|
|
|
32 |
Returns:
|
33 |
str: The generated answer to the question.
|
34 |
"""
|