Spaces:
Running
on
Zero
Running
on
Zero
Update vlm.py
Browse files
vlm.py
CHANGED
|
@@ -5,7 +5,8 @@ Author: Didier Guillevic
|
|
| 5 |
Date: 2025-05-08
|
| 6 |
"""
|
| 7 |
|
| 8 |
-
from transformers import AutoProcessor
|
|
|
|
| 9 |
import torch
|
| 10 |
|
| 11 |
#
|
|
@@ -14,11 +15,11 @@ import torch
|
|
| 14 |
model_id = "OPEA/Mistral-Small-3.1-24B-Instruct-2503-int4-AutoRound-awq-sym"
|
| 15 |
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
| 16 |
processor = AutoProcessor.from_pretrained(model_id)
|
| 17 |
-
model =
|
| 18 |
model_id,
|
| 19 |
_attn_implementation="flash_attention_2",
|
| 20 |
torch_dtype=torch.bfloat16
|
| 21 |
-
).to(device)
|
| 22 |
|
| 23 |
#
|
| 24 |
# Encode images as base64
|
|
|
|
| 5 |
Date: 2025-05-08
|
| 6 |
"""
|
| 7 |
|
| 8 |
+
from transformers import AutoProcessor
|
| 9 |
+
from transformers import Mistral3ForConditionalGeneration
|
| 10 |
import torch
|
| 11 |
|
| 12 |
#
|
|
|
|
| 15 |
model_id = "OPEA/Mistral-Small-3.1-24B-Instruct-2503-int4-AutoRound-awq-sym"
|
| 16 |
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
| 17 |
processor = AutoProcessor.from_pretrained(model_id)
|
| 18 |
+
model = Mistral3ForConditionalGeneration.from_pretrained(
|
| 19 |
model_id,
|
| 20 |
_attn_implementation="flash_attention_2",
|
| 21 |
torch_dtype=torch.bfloat16
|
| 22 |
+
).eval().to(device)
|
| 23 |
|
| 24 |
#
|
| 25 |
# Encode images as base64
|