adarshcod30 commited on
Commit
d87e594
·
verified ·
1 Parent(s): b379113

Import spaces package for ZeroGPU registration (fixes runtime error)

Browse files
Files changed (2) hide show
  1. app.py +16 -0
  2. requirements.txt +1 -0
app.py CHANGED
@@ -8,6 +8,17 @@ fetches the checkpoint from the separate model repo
8
  MODEL_CARD.md there) via `hf_hub_download` instead of bundling a 46MB weight
9
  file into this Space's own repo. `hf_hub_download` caches the file locally
10
  after the first fetch, so a Space restart does not re-download it.
 
 
 
 
 
 
 
 
 
 
 
11
  """
12
 
13
  from __future__ import annotations
@@ -15,6 +26,11 @@ from __future__ import annotations
15
  import sys
16
  from pathlib import Path
17
 
 
 
 
 
 
18
  sys.path.insert(0, str(Path(__file__).resolve().parent / "src"))
19
 
20
  MODEL_REPO = "adarshcod30/drdetect-dr-screening"
 
8
  MODEL_CARD.md there) via `hf_hub_download` instead of bundling a 46MB weight
9
  file into this Space's own repo. `hf_hub_download` caches the file locally
10
  after the first fetch, so a Space restart does not re-download it.
11
+
12
+ This project's model is CPU-only by design (no `@spaces.GPU`-decorated
13
+ function anywhere -- see `drdetect.serve.pipeline.load_grader`'s own
14
+ docstring), but the Space is hosted on HF's free ZeroGPU hardware tier
15
+ (free accounts can no longer create free CPU-basic Gradio Spaces). Importing
16
+ `spaces` early, even unused otherwise, is HF's own documented requirement for
17
+ a Space to register correctly with the ZeroGPU scheduler -- without it the
18
+ platform's supervisor stops the app shortly after a clean startup, which is
19
+ exactly what happened before this import was added. Wrapped in a try/except
20
+ so this file still runs unmodified outside a Space (`spaces` is not, and
21
+ should not be, a dependency of the main `drdetect` package).
22
  """
23
 
24
  from __future__ import annotations
 
26
  import sys
27
  from pathlib import Path
28
 
29
+ try:
30
+ import spaces # noqa: F401
31
+ except ImportError:
32
+ pass
33
+
34
  sys.path.insert(0, str(Path(__file__).resolve().parent / "src"))
35
 
36
  MODEL_REPO = "adarshcod30/drdetect-dr-screening"
requirements.txt CHANGED
@@ -31,3 +31,4 @@ seaborn>=0.13
31
  tqdm>=4.66
32
  kaggle>=1.6
33
  python-dotenv>=1.0
 
 
31
  tqdm>=4.66
32
  kaggle>=1.6
33
  python-dotenv>=1.0
34
+ spaces