Spaces:
Sleeping
Sleeping
Support ZeroGPU Space runtime
Browse files
app.py
CHANGED
|
@@ -9,6 +9,17 @@ import sys
|
|
| 9 |
import html
|
| 10 |
import gradio as gr
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
# Ensure src modules are resolvable
|
| 13 |
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
| 14 |
|
|
@@ -52,6 +63,7 @@ SAMPLE_EMAILS = {
|
|
| 52 |
}
|
| 53 |
|
| 54 |
|
|
|
|
| 55 |
def classify_email(subject: str, body: str):
|
| 56 |
"""
|
| 57 |
Primary Gradio callback function for classifying email threat levels.
|
|
|
|
| 9 |
import html
|
| 10 |
import gradio as gr
|
| 11 |
|
| 12 |
+
# ZeroGPU Spaces require at least one GPU-decorated callable at startup. The
|
| 13 |
+
# classifier itself is CPU-friendly, but the decorator lets this app run on
|
| 14 |
+
# the existing ZeroGPU Space configuration. Keep a local fallback so tests
|
| 15 |
+
# and ordinary CPU launches do not require the Spaces runtime package.
|
| 16 |
+
try:
|
| 17 |
+
import spaces
|
| 18 |
+
except ImportError:
|
| 19 |
+
class _LocalSpaces:
|
| 20 |
+
GPU = staticmethod(lambda function: function)
|
| 21 |
+
spaces = _LocalSpaces()
|
| 22 |
+
|
| 23 |
# Ensure src modules are resolvable
|
| 24 |
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
| 25 |
|
|
|
|
| 63 |
}
|
| 64 |
|
| 65 |
|
| 66 |
+
@spaces.GPU
|
| 67 |
def classify_email(subject: str, body: str):
|
| 68 |
"""
|
| 69 |
Primary Gradio callback function for classifying email threat levels.
|