Spaces:
Sleeping
Sleeping
wenbemi
commited on
Update chat_a.py
Browse files
chat_a.py
CHANGED
|
@@ -12,9 +12,10 @@ from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
|
| 12 |
from css import log_and_render
|
| 13 |
|
| 14 |
# ──────────────────────────────── 캐시/데이터셋 설정 ────────────────────────────────
|
| 15 |
-
|
| 16 |
|
| 17 |
-
|
|
|
|
| 18 |
os.makedirs(CACHE_DIR, exist_ok=True)
|
| 19 |
|
| 20 |
HF_DATASET_REPO = os.getenv("HF_DATASET_REPO", "emisdfde/moai-travel-data")
|
|
@@ -109,7 +110,9 @@ def load_tokenizer():
|
|
| 109 |
@st.cache_resource(show_spinner=False)
|
| 110 |
def load_sentiment_model():
|
| 111 |
tok = AutoTokenizer.from_pretrained("hun3359/klue-bert-base-sentiment", cache_dir=CACHE_DIR)
|
| 112 |
-
model = AutoModelForSequenceClassification.from_pretrained(
|
|
|
|
|
|
|
| 113 |
model.eval()
|
| 114 |
return tok, model
|
| 115 |
|
|
|
|
| 12 |
from css import log_and_render
|
| 13 |
|
| 14 |
# ──────────────────────────────── 캐시/데이터셋 설정 ────────────────────────────────
|
| 15 |
+
HOME = pathlib.Path.home()
|
| 16 |
|
| 17 |
+
# ✅ ENV가 있으면 따르고, 없으면 홈 밑 .cache/hf-cache 사용
|
| 18 |
+
CACHE_DIR = os.getenv("TRANSFORMERS_CACHE") or str(HOME / ".cache" / "hf-cache")
|
| 19 |
os.makedirs(CACHE_DIR, exist_ok=True)
|
| 20 |
|
| 21 |
HF_DATASET_REPO = os.getenv("HF_DATASET_REPO", "emisdfde/moai-travel-data")
|
|
|
|
| 110 |
@st.cache_resource(show_spinner=False)
|
| 111 |
def load_sentiment_model():
|
| 112 |
tok = AutoTokenizer.from_pretrained("hun3359/klue-bert-base-sentiment", cache_dir=CACHE_DIR)
|
| 113 |
+
model = AutoModelForSequenceClassification.from_pretrained(
|
| 114 |
+
"hun3359/klue-bert-base-sentiment", cache_dir=CACHE_DIR
|
| 115 |
+
)
|
| 116 |
model.eval()
|
| 117 |
return tok, model
|
| 118 |
|