Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
import torch
|
2 |
-
from transformers import
|
3 |
from PIL import Image
|
4 |
import numpy as np
|
5 |
import os
|
@@ -8,18 +8,16 @@ import gradio as gr
|
|
8 |
# Load the model and tokenizer
|
9 |
model_path = "ByteDance/Sa2VA-4B"
|
10 |
|
11 |
-
model =
|
12 |
model_path,
|
13 |
-
torch_dtype
|
14 |
-
|
15 |
-
|
16 |
-
trust_remote_code = True
|
17 |
).eval().cuda()
|
18 |
|
19 |
tokenizer = AutoTokenizer.from_pretrained(
|
20 |
model_path,
|
21 |
trust_remote_code = True,
|
22 |
-
use_fast = False
|
23 |
)
|
24 |
|
25 |
def image_vision(image_input_path, prompt):
|
|
|
1 |
import torch
|
2 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
3 |
from PIL import Image
|
4 |
import numpy as np
|
5 |
import os
|
|
|
8 |
# Load the model and tokenizer
|
9 |
model_path = "ByteDance/Sa2VA-4B"
|
10 |
|
11 |
+
model = AutoModelForCausalLM.from_pretrained(
|
12 |
model_path,
|
13 |
+
torch_dtype="auto",
|
14 |
+
device_map="auto",
|
15 |
+
trust_remote_code=True,
|
|
|
16 |
).eval().cuda()
|
17 |
|
18 |
tokenizer = AutoTokenizer.from_pretrained(
|
19 |
model_path,
|
20 |
trust_remote_code = True,
|
|
|
21 |
)
|
22 |
|
23 |
def image_vision(image_input_path, prompt):
|