Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -14,27 +14,20 @@ import uuid
|
|
14 |
import uuid
|
15 |
from ultralytics import YOLO
|
16 |
import gradio as gr
|
17 |
-
import subprocess
|
18 |
-
import sys
|
19 |
-
try:
|
20 |
-
# Run the pip command
|
21 |
-
subprocess.check_call([sys.executable, "-m", "pip", "install", "flash-attn", "--no-build-isolation"])
|
22 |
-
print("flash-attn installed successfully.")
|
23 |
-
except subprocess.CalledProcessError as e:
|
24 |
-
print(f"An error occurred while installing flash-attn: {e}")
|
25 |
-
# # default: Load the model on the available device(s)
|
26 |
-
# model = Qwen2VLForConditionalGeneration.from_pretrained(
|
27 |
-
# "Qwen/Qwen2-VL-7B-Instruct", torch_dtype="auto", device_map="auto"
|
28 |
-
# )
|
29 |
|
30 |
-
#
|
31 |
model = Qwen2VLForConditionalGeneration.from_pretrained(
|
32 |
-
"Qwen/Qwen2-VL-7B-Instruct",
|
33 |
-
torch_dtype=torch.bfloat16,
|
34 |
-
attn_implementation="flash_attention_2",
|
35 |
-
device_map="auto",
|
36 |
)
|
37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
# default processer
|
39 |
processor = AutoProcessor.from_pretrained("Qwen/Qwen2-VL-7B-Instruct")
|
40 |
|
|
|
14 |
import uuid
|
15 |
from ultralytics import YOLO
|
16 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
+
# # default: Load the model on the available device(s)
|
19 |
model = Qwen2VLForConditionalGeneration.from_pretrained(
|
20 |
+
"Qwen/Qwen2-VL-7B-Instruct", torch_dtype="auto", device_map="auto"
|
|
|
|
|
|
|
21 |
)
|
22 |
|
23 |
+
# We recommend enabling flash_attention_2 for better acceleration and memory saving, especially in multi-image and video scenarios.
|
24 |
+
# model = Qwen2VLForConditionalGeneration.from_pretrained(
|
25 |
+
# "Qwen/Qwen2-VL-7B-Instruct",
|
26 |
+
# torch_dtype=torch.bfloat16,
|
27 |
+
# attn_implementation="flash_attention_2",
|
28 |
+
# device_map="auto",
|
29 |
+
# )
|
30 |
+
|
31 |
# default processer
|
32 |
processor = AutoProcessor.from_pretrained("Qwen/Qwen2-VL-7B-Instruct")
|
33 |
|