jhonier23 commited on
Commit
ba1b5db
·
1 Parent(s): 5038d62
Files changed (2) hide show
  1. app.py +12 -0
  2. requirements.txt +1 -0
app.py CHANGED
@@ -2,6 +2,8 @@ import gradio as gr
2
  import subprocess
3
  import os
4
  is_spaces = True if os.environ.get('SPACE_ID') else False
 
 
5
  from gradio_client import Client, handle_file
6
  from huggingface_hub import snapshot_download, HfApi
7
  import uuid
@@ -32,6 +34,16 @@ mage_vl_client = None
32
  caption_cache = {}
33
 
34
 
 
 
 
 
 
 
 
 
 
 
35
  def ensure_file(url, destination):
36
  """Download a pinned helper only when it is actually needed."""
37
  destination = Path(destination)
 
2
  import subprocess
3
  import os
4
  is_spaces = True if os.environ.get('SPACE_ID') else False
5
+ if is_spaces:
6
+ import spaces
7
  from gradio_client import Client, handle_file
8
  from huggingface_hub import snapshot_download, HfApi
9
  import uuid
 
34
  caption_cache = {}
35
 
36
 
37
+ # A Space configured for ZeroGPU must register at least one GPU function during
38
+ # startup. Captioning itself runs in the separate Mage-VL Space, so this probe is
39
+ # intentionally not placed around run_captioning (which would waste local quota
40
+ # while waiting for remote API requests).
41
+ if is_spaces:
42
+ @spaces.GPU(duration=1)
43
+ def zero_gpu_probe():
44
+ return True
45
+
46
+
47
  def ensure_file(url, destination):
48
  """Download a pinned helper only when it is actually needed."""
49
  destination = Path(destination)
requirements.txt CHANGED
@@ -4,3 +4,4 @@ huggingface-hub==0.27.0
4
  python-slugify
5
  gradio>=4.37,<6
6
  gradio_client>=1.0
 
 
4
  python-slugify
5
  gradio>=4.37,<6
6
  gradio_client>=1.0
7
+ spaces