Update app.py
Browse files
app.py
CHANGED
|
@@ -1,14 +1,14 @@
|
|
| 1 |
import json, numpy as np, gradio as gr
|
| 2 |
from setfit import SetFitModel
|
| 3 |
-
from huggingface_hub import hf_hub_download
|
| 4 |
|
| 5 |
MODEL_ID = "DelaliScratchwerk/text-period-setfit"
|
| 6 |
|
| 7 |
-
#
|
| 8 |
try:
|
| 9 |
labels_path = hf_hub_download(MODEL_ID, "labels.json")
|
| 10 |
LABELS = json.load(open(labels_path))
|
| 11 |
-
except
|
| 12 |
LABELS = json.load(open("labels.json"))
|
| 13 |
|
| 14 |
model = SetFitModel.from_pretrained(MODEL_ID)
|
|
@@ -37,5 +37,6 @@ demo = gr.Interface(
|
|
| 37 |
cache_examples=False,
|
| 38 |
allow_flagging="never",
|
| 39 |
)
|
|
|
|
| 40 |
if __name__ == "__main__":
|
| 41 |
demo.launch()
|
|
|
|
| 1 |
import json, numpy as np, gradio as gr
|
| 2 |
from setfit import SetFitModel
|
| 3 |
+
from huggingface_hub import hf_hub_download
|
| 4 |
|
| 5 |
MODEL_ID = "DelaliScratchwerk/text-period-setfit"
|
| 6 |
|
| 7 |
+
# Try to load labels from the model repo; if missing, use local labels.json
|
| 8 |
try:
|
| 9 |
labels_path = hf_hub_download(MODEL_ID, "labels.json")
|
| 10 |
LABELS = json.load(open(labels_path))
|
| 11 |
+
except Exception:
|
| 12 |
LABELS = json.load(open("labels.json"))
|
| 13 |
|
| 14 |
model = SetFitModel.from_pretrained(MODEL_ID)
|
|
|
|
| 37 |
cache_examples=False,
|
| 38 |
allow_flagging="never",
|
| 39 |
)
|
| 40 |
+
|
| 41 |
if __name__ == "__main__":
|
| 42 |
demo.launch()
|