Spaces:
Sleeping
Sleeping
Commit ·
10dae35
1
Parent(s): a395ade
cleanup: remove spaces import and @spaces.GPU decorators (hardware changed to cpu-basic)
Browse files
app.py
CHANGED
|
@@ -19,19 +19,6 @@ from pathlib import Path
|
|
| 19 |
|
| 20 |
import gradio as gr
|
| 21 |
|
| 22 |
-
# `spaces` is injected automatically by HuggingFace Spaces; fall back to a
|
| 23 |
-
# no-op decorator so the app also runs locally without it installed.
|
| 24 |
-
try:
|
| 25 |
-
import spaces
|
| 26 |
-
except ImportError:
|
| 27 |
-
class spaces: # type: ignore[no-redef]
|
| 28 |
-
@staticmethod
|
| 29 |
-
def GPU(fn=None, *, duration=60):
|
| 30 |
-
# No-op decorator — spaces not installed (local dev)
|
| 31 |
-
def decorator(f):
|
| 32 |
-
return f
|
| 33 |
-
return decorator(fn) if fn is not None else decorator
|
| 34 |
-
|
| 35 |
# ---------------------------------------------------------------------------
|
| 36 |
# Config (mirrors webservice/main.py — keep in sync if you change models)
|
| 37 |
# ---------------------------------------------------------------------------
|
|
@@ -92,7 +79,6 @@ def _make_call_fn(model: str, timeout: int = 120):
|
|
| 92 |
# ---------------------------------------------------------------------------
|
| 93 |
|
| 94 |
|
| 95 |
-
@spaces.GPU(duration=300)
|
| 96 |
def do_annotate(text: str, model: str):
|
| 97 |
if not _HF_TOKEN:
|
| 98 |
return "", "HF_TOKEN is not set. Add it as a Space secret."
|
|
@@ -131,7 +117,6 @@ def do_load_samples(n: int):
|
|
| 131 |
return "\n\n".join(extract_spans(el)[0] for el in samples)
|
| 132 |
|
| 133 |
|
| 134 |
-
@spaces.GPU(duration=300)
|
| 135 |
def do_evaluate(model: str, n: int):
|
| 136 |
if not _HF_TOKEN:
|
| 137 |
return None, "HF_TOKEN is not set. Add it as a Space secret."
|
|
|
|
| 19 |
|
| 20 |
import gradio as gr
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
# ---------------------------------------------------------------------------
|
| 23 |
# Config (mirrors webservice/main.py — keep in sync if you change models)
|
| 24 |
# ---------------------------------------------------------------------------
|
|
|
|
| 79 |
# ---------------------------------------------------------------------------
|
| 80 |
|
| 81 |
|
|
|
|
| 82 |
def do_annotate(text: str, model: str):
|
| 83 |
if not _HF_TOKEN:
|
| 84 |
return "", "HF_TOKEN is not set. Add it as a Space secret."
|
|
|
|
| 117 |
return "\n\n".join(extract_spans(el)[0] for el in samples)
|
| 118 |
|
| 119 |
|
|
|
|
| 120 |
def do_evaluate(model: str, n: int):
|
| 121 |
if not _HF_TOKEN:
|
| 122 |
return None, "HF_TOKEN is not set. Add it as a Space secret."
|