Update app.py
Browse files
app.py
CHANGED
|
@@ -4,33 +4,6 @@ import warnings
|
|
| 4 |
|
| 5 |
warnings.filterwarnings("ignore", category=DeprecationWarning)
|
| 6 |
|
| 7 |
-
from huggingface_hub import snapshot_download
|
| 8 |
-
|
| 9 |
-
# Set custom cache directory BEFORE importing anything
|
| 10 |
-
custom_cache = "./my_hf_cache"
|
| 11 |
-
os.environ["HF_HOME"] = custom_cache
|
| 12 |
-
os.environ["TRANSFORMERS_CACHE"] = custom_cache
|
| 13 |
-
|
| 14 |
-
# 1. 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 |
-
resume_download=True, # Resume if interrupted
|
| 19 |
-
local_files_only=False # Allow download if not cached
|
| 20 |
-
)
|
| 21 |
-
model_name_two = "skadio/ner4opt-roberta-v2"
|
| 22 |
-
snapshot_download(repo_id=model_name_two,
|
| 23 |
-
resume_download=True, # Resume if interrupted
|
| 24 |
-
local_files_only=False # Allow download if not cached
|
| 25 |
-
)
|
| 26 |
-
except Exception as e:
|
| 27 |
-
print(f"Download failed: {e}")
|
| 28 |
-
|
| 29 |
-
# Step 2: Set environment variables to force offline mode GLOBALLY
|
| 30 |
-
os.environ["HF_HUB_OFFLINE"] = "1"
|
| 31 |
-
os.environ["TRANSFORMERS_OFFLINE"] = "1"
|
| 32 |
-
os.environ["HF_DATASETS_OFFLINE"] = "1"
|
| 33 |
-
|
| 34 |
import streamlit as st
|
| 35 |
import ner4opt
|
| 36 |
from ner4opt.utils import preprocess, spacy_tokenize_sentence
|
|
|
|
| 4 |
|
| 5 |
warnings.filterwarnings("ignore", category=DeprecationWarning)
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
import streamlit as st
|
| 8 |
import ner4opt
|
| 9 |
from ner4opt.utils import preprocess, spacy_tokenize_sentence
|