Spaces:
Running
Running
Fix startup: download only needed files, skip 1.35GB ONNX
Browse files
app.py
CHANGED
|
@@ -7,11 +7,17 @@ from html.parser import HTMLParser
|
|
| 7 |
import gradio as gr
|
| 8 |
from adaptive_classifier import AdaptiveClassifier
|
| 9 |
|
| 10 |
-
# Load model once at startup
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
print("Loading model...")
|
| 12 |
-
classifier = AdaptiveClassifier.
|
| 13 |
-
"adaptive-classifier/ai-detector", use_onnx=False
|
| 14 |
-
)
|
| 15 |
print("Model loaded!")
|
| 16 |
|
| 17 |
HEADERS = {
|
|
|
|
| 7 |
import gradio as gr
|
| 8 |
from adaptive_classifier import AdaptiveClassifier
|
| 9 |
|
| 10 |
+
# Load model once at startup — download only needed files (skip 1.35GB ONNX)
|
| 11 |
+
print("Downloading model...")
|
| 12 |
+
from huggingface_hub import hf_hub_download
|
| 13 |
+
import os, tempfile
|
| 14 |
+
|
| 15 |
+
_tmp = tempfile.mkdtemp()
|
| 16 |
+
for f in ["config.json", "examples.json", "model.safetensors"]:
|
| 17 |
+
hf_hub_download("adaptive-classifier/ai-detector", f, local_dir=_tmp)
|
| 18 |
+
|
| 19 |
print("Loading model...")
|
| 20 |
+
classifier = AdaptiveClassifier.load(_tmp, use_onnx=False)
|
|
|
|
|
|
|
| 21 |
print("Model loaded!")
|
| 22 |
|
| 23 |
HEADERS = {
|