trying ZeroGPU again with flash-attn
Browse fileshttps://huggingface.co/spaces/zero-gpu-explorers/README/discussions/75
app.py
CHANGED
@@ -7,9 +7,16 @@ import gradio as gr
|
|
7 |
import cv2
|
8 |
import tempfile
|
9 |
from ultralytics import YOLO
|
10 |
-
|
11 |
|
12 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
def yolov12_inference(image, video, model_id, image_size, conf_threshold):
|
14 |
model = YOLO(model_id)
|
15 |
if image:
|
|
|
7 |
import cv2
|
8 |
import tempfile
|
9 |
from ultralytics import YOLO
|
10 |
+
import spaces, subprocess
|
11 |
|
12 |
+
# Install flash attention, skipping CUDA build if necessary
|
13 |
+
subprocess.run(
|
14 |
+
"pip install flash-attn --no-build-isolation",
|
15 |
+
env={"FLASH_ATTENTION_SKIP_CUDA_BUILD": "TRUE"},
|
16 |
+
shell=True,
|
17 |
+
)
|
18 |
+
|
19 |
+
@spaces.GPU
|
20 |
def yolov12_inference(image, video, model_id, image_size, conf_threshold):
|
21 |
model = YOLO(model_id)
|
22 |
if image:
|