Spaces:
Running on Zero
Running on Zero
AI Bot commited on
Commit ·
ff46d92
1
Parent(s): 65bd6bc
fix(zerogpu): place spaces import before torch and enable demo.queue()
Browse files- .gitignore +3 -0
- app.py +15 -14
.gitignore
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
__pycache__/
|
| 2 |
+
*.pyc
|
| 3 |
+
.env
|
app.py
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import os
|
| 2 |
import io
|
| 3 |
import time
|
|
@@ -19,20 +33,6 @@ from fastapi.responses import JSONResponse
|
|
| 19 |
from pydantic import BaseModel, Field
|
| 20 |
import gradio as gr
|
| 21 |
|
| 22 |
-
# ZeroGPU Spaces compatibility
|
| 23 |
-
try:
|
| 24 |
-
import spaces
|
| 25 |
-
HAS_SPACES = True
|
| 26 |
-
except Exception:
|
| 27 |
-
class DummySpaces:
|
| 28 |
-
@staticmethod
|
| 29 |
-
def GPU(duration=60):
|
| 30 |
-
def decorator(fn):
|
| 31 |
-
return fn
|
| 32 |
-
return decorator
|
| 33 |
-
spaces = DummySpaces()
|
| 34 |
-
HAS_SPACES = False
|
| 35 |
-
|
| 36 |
# Import official Kronos architecture from local package
|
| 37 |
try:
|
| 38 |
from model import Kronos, KronosTokenizer, KronosPredictor
|
|
@@ -672,6 +672,7 @@ with gr.Blocks(title="Kronos + Laya Portfolio & Trade Analysis Engine") as demo:
|
|
| 672 |
gr.Markdown("### Sub-50ms Non-Autoregressive Risk Gate")
|
| 673 |
gr.JSON(value={"status": "online", "engine": "Laya ModernBERT", "latency_ms": 33.0})
|
| 674 |
|
|
|
|
| 675 |
app = gr.mount_gradio_app(fastapi_app, demo, path="/")
|
| 676 |
|
| 677 |
if __name__ == "__main__":
|
|
|
|
| 1 |
+
# ZeroGPU Spaces compatibility (Must be imported before torch)
|
| 2 |
+
try:
|
| 3 |
+
import spaces
|
| 4 |
+
HAS_SPACES = True
|
| 5 |
+
except Exception:
|
| 6 |
+
class DummySpaces:
|
| 7 |
+
@staticmethod
|
| 8 |
+
def GPU(duration=60):
|
| 9 |
+
def decorator(fn):
|
| 10 |
+
return fn
|
| 11 |
+
return decorator
|
| 12 |
+
spaces = DummySpaces()
|
| 13 |
+
HAS_SPACES = False
|
| 14 |
+
|
| 15 |
import os
|
| 16 |
import io
|
| 17 |
import time
|
|
|
|
| 33 |
from pydantic import BaseModel, Field
|
| 34 |
import gradio as gr
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
# Import official Kronos architecture from local package
|
| 37 |
try:
|
| 38 |
from model import Kronos, KronosTokenizer, KronosPredictor
|
|
|
|
| 672 |
gr.Markdown("### Sub-50ms Non-Autoregressive Risk Gate")
|
| 673 |
gr.JSON(value={"status": "online", "engine": "Laya ModernBERT", "latency_ms": 33.0})
|
| 674 |
|
| 675 |
+
demo.queue()
|
| 676 |
app = gr.mount_gradio_app(fastapi_app, demo, path="/")
|
| 677 |
|
| 678 |
if __name__ == "__main__":
|