Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -4,6 +4,8 @@ import os
|
|
4 |
import sys
|
5 |
import threading
|
6 |
|
|
|
|
|
7 |
|
8 |
# Add pre-build setup for Hugging Face Spaces
|
9 |
def setup_environment():
|
@@ -22,6 +24,7 @@ def setup_environment():
|
|
22 |
|
23 |
# Run setup
|
24 |
setup_environment()
|
|
|
25 |
|
26 |
import gradio as gr
|
27 |
import numpy as np
|
@@ -80,6 +83,7 @@ def initialize_models(args):
|
|
80 |
return (gdino_model, processor, model)
|
81 |
|
82 |
|
|
|
83 |
def process_image_with_streaming(
|
84 |
image,
|
85 |
system_prompt,
|
@@ -199,6 +203,7 @@ def process_image_with_streaming(
|
|
199 |
return gdino_vis_result, ref_vis_result, output_text
|
200 |
|
201 |
|
|
|
202 |
def process_image_non_streaming(
|
203 |
image,
|
204 |
system_prompt,
|
@@ -225,6 +230,7 @@ def process_image_non_streaming(
|
|
225 |
)
|
226 |
|
227 |
|
|
|
228 |
def create_streaming_interface(models):
|
229 |
"""Create a streaming interface using a different approach"""
|
230 |
(
|
|
|
4 |
import sys
|
5 |
import threading
|
6 |
|
7 |
+
import spaces
|
8 |
+
|
9 |
|
10 |
# Add pre-build setup for Hugging Face Spaces
|
11 |
def setup_environment():
|
|
|
24 |
|
25 |
# Run setup
|
26 |
setup_environment()
|
27 |
+
os.system("pip install -r requirements_hf.txt")
|
28 |
|
29 |
import gradio as gr
|
30 |
import numpy as np
|
|
|
83 |
return (gdino_model, processor, model)
|
84 |
|
85 |
|
86 |
+
@spaces.GPU
|
87 |
def process_image_with_streaming(
|
88 |
image,
|
89 |
system_prompt,
|
|
|
203 |
return gdino_vis_result, ref_vis_result, output_text
|
204 |
|
205 |
|
206 |
+
@spaces.GPU
|
207 |
def process_image_non_streaming(
|
208 |
image,
|
209 |
system_prompt,
|
|
|
230 |
)
|
231 |
|
232 |
|
233 |
+
@spaces.GPU
|
234 |
def create_streaming_interface(models):
|
235 |
"""Create a streaming interface using a different approach"""
|
236 |
(
|