DelaliScratchwerk commited on
Commit
f327d31
·
verified ·
1 Parent(s): 65ba28a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -1,9 +1,15 @@
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
- LABELS = json.load(open(hf_hub_download(MODEL_ID, "labels.json"))) # pulls from model repo
 
 
 
 
 
 
7
 
8
  model = SetFitModel.from_pretrained(MODEL_ID)
9
 
 
1
  import json, numpy as np, gradio as gr
2
  from setfit import SetFitModel
3
+ from huggingface_hub import hf_hub_download, HfHubHTTPError, EntryNotFoundError
4
 
5
  MODEL_ID = "DelaliScratchwerk/text-period-setfit"
6
+
7
+ # ---- load labels (Hub -> local fallback)
8
+ try:
9
+ labels_path = hf_hub_download(MODEL_ID, "labels.json")
10
+ LABELS = json.load(open(labels_path))
11
+ except (HfHubHTTPError, EntryNotFoundError, FileNotFoundError):
12
+ LABELS = json.load(open("labels.json"))
13
 
14
  model = SetFitModel.from_pretrained(MODEL_ID)
15