Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,28 +7,14 @@ import gradio as gr
|
|
| 7 |
|
| 8 |
# Load the model and tokenizer
|
| 9 |
model_path = "ByteDance/Sa2VA-4B"
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
from unittest.mock import patch
|
| 13 |
-
from transformers.dynamic_module_utils import get_imports
|
| 14 |
-
|
| 15 |
-
def fixed_get_imports(filename: str | os.PathLike) -> list[str]:
|
| 16 |
-
if not str(filename).endswith("modeling_sa2va_chat.py"):
|
| 17 |
-
return get_imports(filename)
|
| 18 |
-
imports = get_imports(filename)
|
| 19 |
-
imports.remove("flash_attn")
|
| 20 |
-
return imports
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
with patch("transformers.dynamic_module_utils.get_imports", fixed_get_imports):
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
|
| 33 |
tokenizer = AutoTokenizer.from_pretrained(
|
| 34 |
model_path,
|
|
|
|
| 7 |
|
| 8 |
# Load the model and tokenizer
|
| 9 |
model_path = "ByteDance/Sa2VA-4B"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
+
model = AutoModel.from_pretrained(
|
| 12 |
+
model_path,
|
| 13 |
+
torch_dtype = torch.bfloat16,
|
| 14 |
+
low_cpu_mem_usage = True,
|
| 15 |
+
use_flash_attn = True,
|
| 16 |
+
trust_remote_code = True
|
| 17 |
+
).eval().cuda()
|
| 18 |
|
| 19 |
tokenizer = AutoTokenizer.from_pretrained(
|
| 20 |
model_path,
|