bytestream89 commited on
Commit
cf8afa8
·
verified ·
1 Parent(s): 496261a

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +9 -9
app.py CHANGED
@@ -11,6 +11,15 @@ All artifacts live in a system temp directory — nothing is written to the proj
11
 
12
  from __future__ import annotations
13
 
 
 
 
 
 
 
 
 
 
14
  import os
15
  os.environ.setdefault("PYTORCH_ENABLE_MPS_FALLBACK", "1")
16
 
@@ -34,15 +43,6 @@ from autolabel.export import build_coco
34
  from autolabel.segment import load_sam2, segment_with_boxes
35
  from autolabel.utils import save_json, setup_logging
36
 
37
- # HuggingFace ZeroGPU: GPU is only available inside @spaces.GPU-decorated
38
- # functions. Import gracefully so the app still runs locally without it.
39
- try:
40
- import spaces as _spaces # type: ignore
41
- _ZERO_GPU = True
42
- except ImportError:
43
- _spaces = None
44
- _ZERO_GPU = False
45
-
46
  setup_logging(logging.INFO)
47
  logger = logging.getLogger(__name__)
48
 
 
11
 
12
  from __future__ import annotations
13
 
14
+ # spaces MUST be imported before torch initialises CUDA (i.e. before any
15
+ # autolabel import). Do this first, before everything else.
16
+ try:
17
+ import spaces as _spaces # type: ignore
18
+ _ZERO_GPU = True
19
+ except (ImportError, RuntimeError):
20
+ _spaces = None
21
+ _ZERO_GPU = False
22
+
23
  import os
24
  os.environ.setdefault("PYTORCH_ENABLE_MPS_FALLBACK", "1")
25
 
 
43
  from autolabel.segment import load_sam2, segment_with_boxes
44
  from autolabel.utils import save_json, setup_logging
45
 
 
 
 
 
 
 
 
 
 
46
  setup_logging(logging.INFO)
47
  logger = logging.getLogger(__name__)
48