Vaidhav commited on
Commit
da0df22
·
1 Parent(s): 20cf55e

fix: add @spaces.GPU and spaces dependency for ZeroGPU compatibility

Browse files
Files changed (2) hide show
  1. app.py +13 -0
  2. requirements.txt +1 -0
app.py CHANGED
@@ -18,6 +18,18 @@ import onnx
18
  from onnx import TensorProto, numpy_helper
19
  import onnxruntime as ort
20
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  # ==============================================================================
22
  # 1. Constants & Preprocessing
23
  # ==============================================================================
@@ -211,6 +223,7 @@ def make_bar_html(top3, top_class, top_conf, latency_ms, cfg):
211
  return f'<div style="padding:8px;background:#0f172a;border-radius:8px;">{bars}{info}</div>'
212
 
213
 
 
214
  def predict_all_models(input_img):
215
  if input_img is None:
216
  placeholder = '<div style="color:#64748b;padding:8px;">Upload an image and click Compare.</div>'
 
18
  from onnx import TensorProto, numpy_helper
19
  import onnxruntime as ort
20
 
21
+ try:
22
+ import spaces
23
+ except ImportError:
24
+ class spaces:
25
+ @staticmethod
26
+ def GPU(func=None, **kwargs):
27
+ if func is not None:
28
+ return func
29
+ def decorator(f):
30
+ return f
31
+ return decorator
32
+
33
  # ==============================================================================
34
  # 1. Constants & Preprocessing
35
  # ==============================================================================
 
223
  return f'<div style="padding:8px;background:#0f172a;border-radius:8px;">{bars}{info}</div>'
224
 
225
 
226
+ @spaces.GPU
227
  def predict_all_models(input_img):
228
  if input_img is None:
229
  placeholder = '<div style="color:#64748b;padding:8px;">Upload an image and click Compare.</div>'
requirements.txt CHANGED
@@ -9,3 +9,4 @@ onnxscript>=0.1.0
9
  gradio==4.44.0
10
  huggingface_hub<0.25.0
11
  pillow>=9.0.0
 
 
9
  gradio==4.44.0
10
  huggingface_hub<0.25.0
11
  pillow>=9.0.0
12
+ spaces