Update app.py
Browse files
app.py
CHANGED
|
@@ -3,24 +3,33 @@ import warnings
|
|
| 3 |
|
| 4 |
warnings.filterwarnings("ignore", category=DeprecationWarning)
|
| 5 |
|
| 6 |
-
import streamlit as st
|
| 7 |
-
import ner4opt
|
| 8 |
-
from ner4opt.utils import preprocess, spacy_tokenize_sentence
|
| 9 |
from huggingface_hub import snapshot_download
|
| 10 |
-
from spacy import displacy
|
| 11 |
-
|
| 12 |
-
HTML_WRAPPER = """<div style="overflow-x: auto; border: 1px solid #e6e9ef; border-radius: 0.25rem; padding: 1rem; margin-bottom: 2.5rem">{}</div>"""
|
| 13 |
|
| 14 |
# Force Download: Due to issues from huggingface spaces
|
| 15 |
try:
|
| 16 |
model_name_one = "skadio/ner4opt-roberta-v1"
|
| 17 |
-
snapshot_download(repo_id=model_name_one
|
|
|
|
|
|
|
|
|
|
| 18 |
model_name_two = "skadio/ner4opt-roberta-v2"
|
| 19 |
-
snapshot_download(repo_id=model_name_two
|
|
|
|
|
|
|
|
|
|
| 20 |
except Exception as e:
|
| 21 |
print(f"Download failed: {e}")
|
| 22 |
|
| 23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
@st.cache_resource
|
| 25 |
def load_models():
|
| 26 |
"""Load and cache NER4OPT models."""
|
|
|
|
| 3 |
|
| 4 |
warnings.filterwarnings("ignore", category=DeprecationWarning)
|
| 5 |
|
|
|
|
|
|
|
|
|
|
| 6 |
from huggingface_hub import snapshot_download
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
# Force Download: Due to issues from huggingface spaces
|
| 9 |
try:
|
| 10 |
model_name_one = "skadio/ner4opt-roberta-v1"
|
| 11 |
+
snapshot_download(repo_id=model_name_one,
|
| 12 |
+
resume_download=True, # Resume if interrupted
|
| 13 |
+
local_files_only=False # Allow download if not cached
|
| 14 |
+
)
|
| 15 |
model_name_two = "skadio/ner4opt-roberta-v2"
|
| 16 |
+
snapshot_download(repo_id=model_name_two,
|
| 17 |
+
resume_download=True, # Resume if interrupted
|
| 18 |
+
local_files_only=False # Allow download if not cached
|
| 19 |
+
)
|
| 20 |
except Exception as e:
|
| 21 |
print(f"Download failed: {e}")
|
| 22 |
|
| 23 |
|
| 24 |
+
import streamlit as st
|
| 25 |
+
import ner4opt
|
| 26 |
+
from ner4opt.utils import preprocess, spacy_tokenize_sentence
|
| 27 |
+
|
| 28 |
+
from spacy import displacy
|
| 29 |
+
|
| 30 |
+
HTML_WRAPPER = """<div style="overflow-x: auto; border: 1px solid #e6e9ef; border-radius: 0.25rem; padding: 1rem; margin-bottom: 2.5rem">{}</div>"""
|
| 31 |
+
|
| 32 |
+
|
| 33 |
@st.cache_resource
|
| 34 |
def load_models():
|
| 35 |
"""Load and cache NER4OPT models."""
|