GF-John commited on
Commit
acdc36a
·
verified ·
1 Parent(s): 475241e

trying ZeroGPU again with flash-attn

Browse files

https://huggingface.co/spaces/zero-gpu-explorers/README/discussions/75

Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -7,9 +7,16 @@ import gradio as gr
7
  import cv2
8
  import tempfile
9
  from ultralytics import YOLO
10
- # import spaces
11
 
12
- # @spaces.GPU
 
 
 
 
 
 
 
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: