Thiru1122 commited on
Commit
02acebb
·
verified ·
1 Parent(s): d57cc01

Import spaces at top of app.py for ZeroGPU compatibility

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -1,3 +1,10 @@
 
 
 
 
 
 
 
1
  import os
2
  import sys
3
  import time
@@ -24,13 +31,6 @@ if UFD_DIR not in sys.path:
24
 
25
  from models import get_model
26
 
27
- # Check if Hugging Face spaces module is available (for ZeroGPU environments)
28
- try:
29
- import spaces
30
- SPACES_AVAILABLE = True
31
- except ImportError:
32
- SPACES_AVAILABLE = False
33
-
34
  # Global model cache (loaded once at startup)
35
  MODEL = None
36
  DEVICE = None
 
1
+ # Hugging Face ZeroGPU requires spaces to be imported before any CUDA/torch modules
2
+ try:
3
+ import spaces
4
+ SPACES_AVAILABLE = True
5
+ except ImportError:
6
+ SPACES_AVAILABLE = False
7
+
8
  import os
9
  import sys
10
  import time
 
31
 
32
  from models import get_model
33
 
 
 
 
 
 
 
 
34
  # Global model cache (loaded once at startup)
35
  MODEL = None
36
  DEVICE = None