Update app.py
Browse files
app.py
CHANGED
|
@@ -1,10 +1,16 @@
|
|
| 1 |
"""Demo for NER4OPT."""
|
|
|
|
| 2 |
import warnings
|
| 3 |
|
| 4 |
warnings.filterwarnings("ignore", category=DeprecationWarning)
|
| 5 |
|
| 6 |
from huggingface_hub import snapshot_download
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
# 1. Force Download: Due to issues from huggingface spaces
|
| 9 |
try:
|
| 10 |
model_name_one = "skadio/ner4opt-roberta-v1"
|
|
@@ -20,7 +26,6 @@ try:
|
|
| 20 |
except Exception as e:
|
| 21 |
print(f"Download failed: {e}")
|
| 22 |
|
| 23 |
-
import os
|
| 24 |
# Step 2: Set environment variables to force offline mode GLOBALLY
|
| 25 |
os.environ["HF_HUB_OFFLINE"] = "1"
|
| 26 |
os.environ["TRANSFORMERS_OFFLINE"] = "1"
|
|
|
|
| 1 |
"""Demo for NER4OPT."""
|
| 2 |
+
import os
|
| 3 |
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"
|
|
|
|
| 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"
|