rydlrKE commited on
Commit
1ceeba7
·
1 Parent(s): 4ced200

Space: restore minimal @spaces.GPU hook for ZeroGPU with native-direct UI

Browse files
Files changed (1) hide show
  1. app.py +19 -0
app.py CHANGED
@@ -5,6 +5,19 @@ import os
5
  import traceback
6
  import time
7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  PORT = int(os.environ.get("PORT", "7860"))
9
  os.environ.setdefault("SERVER_NAME", "0.0.0.0")
10
  os.environ["SERVER_PORT"] = str(PORT)
@@ -14,6 +27,12 @@ os.environ.setdefault("TEXT_ENCODER_MODE", "api")
14
  # Prefer CPU on ZeroGPU to avoid low-level CUDA init crashes during model load.
15
  os.environ.setdefault("KIMODO_DEVICE", "cpu")
16
 
 
 
 
 
 
 
17
  def main() -> None:
18
  try:
19
  import kimodo
 
5
  import traceback
6
  import time
7
 
8
+ try:
9
+ import spaces # type: ignore
10
+ except Exception:
11
+ class _SpacesFallback:
12
+ @staticmethod
13
+ def GPU(*args, **kwargs):
14
+ def _decorator(fn):
15
+ return fn
16
+
17
+ return _decorator
18
+
19
+ spaces = _SpacesFallback()
20
+
21
  PORT = int(os.environ.get("PORT", "7860"))
22
  os.environ.setdefault("SERVER_NAME", "0.0.0.0")
23
  os.environ["SERVER_PORT"] = str(PORT)
 
27
  # Prefer CPU on ZeroGPU to avoid low-level CUDA init crashes during model load.
28
  os.environ.setdefault("KIMODO_DEVICE", "cpu")
29
 
30
+
31
+ @spaces.GPU(duration=60)
32
+ def _gpu_healthcheck() -> str:
33
+ # Required by ZeroGPU startup policy; native demo does not invoke this.
34
+ return "ok"
35
+
36
  def main() -> None:
37
  try:
38
  import kimodo