Spaces:
Running
on
Zero
Running
on
Zero
changes for zerogpu
Browse files- app.py +4 -0
- requirements.txt +2 -1
app.py
CHANGED
@@ -11,6 +11,7 @@ import traceback
|
|
11 |
import matplotlib.pyplot as plt
|
12 |
import ffmpeg
|
13 |
from utils import load_model_without_flash_attn
|
|
|
14 |
|
15 |
|
16 |
# CUDA optimizations
|
@@ -63,6 +64,7 @@ def apply_color_mask(frame, mask, obj_id):
|
|
63 |
colored_mask = mask * color
|
64 |
return frame * (1 - mask) + colored_mask * 255
|
65 |
|
|
|
66 |
@torch.inference_mode()
|
67 |
@torch.autocast(device_type="cuda", dtype=torch.bfloat16)
|
68 |
def run_florence(image, text_input):
|
@@ -99,6 +101,7 @@ def remove_directory_contents(directory):
|
|
99 |
for name in dirs:
|
100 |
os.rmdir(os.path.join(root, name))
|
101 |
|
|
|
102 |
@torch.inference_mode()
|
103 |
@torch.autocast(device_type="cuda", dtype=torch.bfloat16)
|
104 |
def process_video(video_path, prompt):
|
@@ -216,6 +219,7 @@ def process_video(video_path, prompt):
|
|
216 |
print(traceback.format_exc()) # This will print the full stack trace
|
217 |
return None
|
218 |
|
|
|
219 |
def segment_video(video_file, prompt):
|
220 |
if video_file is None:
|
221 |
return None
|
|
|
11 |
import matplotlib.pyplot as plt
|
12 |
import ffmpeg
|
13 |
from utils import load_model_without_flash_attn
|
14 |
+
import spaces
|
15 |
|
16 |
|
17 |
# CUDA optimizations
|
|
|
64 |
colored_mask = mask * color
|
65 |
return frame * (1 - mask) + colored_mask * 255
|
66 |
|
67 |
+
@spaces.GPU
|
68 |
@torch.inference_mode()
|
69 |
@torch.autocast(device_type="cuda", dtype=torch.bfloat16)
|
70 |
def run_florence(image, text_input):
|
|
|
101 |
for name in dirs:
|
102 |
os.rmdir(os.path.join(root, name))
|
103 |
|
104 |
+
@spaces.GPU
|
105 |
@torch.inference_mode()
|
106 |
@torch.autocast(device_type="cuda", dtype=torch.bfloat16)
|
107 |
def process_video(video_path, prompt):
|
|
|
219 |
print(traceback.format_exc()) # This will print the full stack trace
|
220 |
return None
|
221 |
|
222 |
+
@spaces.GPU(duration=1200)
|
223 |
def segment_video(video_file, prompt):
|
224 |
if video_file is None:
|
225 |
return None
|
requirements.txt
CHANGED
@@ -9,4 +9,5 @@ matplotlib
|
|
9 |
einops
|
10 |
timm
|
11 |
pytest
|
12 |
-
ffmpeg-python
|
|
|
|
9 |
einops
|
10 |
timm
|
11 |
pytest
|
12 |
+
ffmpeg-python
|
13 |
+
spaces
|