CWM-Coder724 commited on
Commit ·
6153e75
1
Parent(s): 65672dd
Add ZeroGPU spaces decorator to app.py
Browse files- app.py +12 -0
- requirements.txt +2 -0
app.py
CHANGED
|
@@ -6,6 +6,18 @@ backend_dir = os.path.join(os.path.dirname(__file__), "backend")
|
|
| 6 |
if backend_dir not in sys.path:
|
| 7 |
sys.path.insert(0, backend_dir)
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
from main import app
|
| 10 |
import uvicorn
|
| 11 |
|
|
|
|
| 6 |
if backend_dir not in sys.path:
|
| 7 |
sys.path.insert(0, backend_dir)
|
| 8 |
|
| 9 |
+
# Hugging Face ZeroGPU requirement: at least one @spaces.GPU function during startup
|
| 10 |
+
try:
|
| 11 |
+
import spaces
|
| 12 |
+
@spaces.GPU(duration=120)
|
| 13 |
+
def _zerogpu_init():
|
| 14 |
+
"""Satisfies Hugging Face ZeroGPU startup check."""
|
| 15 |
+
print("[ZeroGPU] Initialized successfully.")
|
| 16 |
+
return True
|
| 17 |
+
_zerogpu_init()
|
| 18 |
+
except Exception as e:
|
| 19 |
+
print("[ZeroGPU] Notice:", e)
|
| 20 |
+
|
| 21 |
from main import app
|
| 22 |
import uvicorn
|
| 23 |
|
requirements.txt
CHANGED
|
@@ -29,3 +29,5 @@ aiosqlite
|
|
| 29 |
# Utilities
|
| 30 |
python-dotenv
|
| 31 |
gradio
|
|
|
|
|
|
|
|
|
| 29 |
# Utilities
|
| 30 |
python-dotenv
|
| 31 |
gradio
|
| 32 |
+
|
| 33 |
+
spaces
|