Spaces:
Sleeping
Sleeping
Update streamlit_app.py
Browse files- streamlit_app.py +13 -7
streamlit_app.py
CHANGED
@@ -14,17 +14,23 @@ from datetime import datetime
|
|
14 |
|
15 |
# ํ๊ฒฝ ์ค์ (๊ถํ ๋ฌธ์ ํด๊ฒฐ)
|
16 |
os.environ['STREAMLIT_BROWSER_GATHER_USAGE_STATS'] = 'false'
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
21 |
|
22 |
os.environ['TRANSFORMERS_CACHE'] = TRANSFORMERS_CACHE_DIR
|
23 |
os.environ['SENTENCE_TRANSFORMERS_HOME'] = SENTENCE_TRANSFORMERS_HOME_DIR
|
24 |
|
25 |
-
# ์บ์ ๋๋ ํ ๋ฆฌ ์์ฑ (์กด์ฌํ์ง ์์ผ๋ฉด)
|
26 |
-
|
27 |
-
os.makedirs(
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
|
30 |
# ํ์ด์ง ์ค์
|
|
|
14 |
|
15 |
# ํ๊ฒฝ ์ค์ (๊ถํ ๋ฌธ์ ํด๊ฒฐ)
|
16 |
os.environ['STREAMLIT_BROWSER_GATHER_USAGE_STATS'] = 'false'
|
17 |
+
|
18 |
+
# ์บ์ ๊ฒฝ๋ก๋ฅผ /tmp ๋ก ์ค์ (Hugging Face Spaces์์ ๊ถ์ฅ๋๋ ์ฐ๊ธฐ ๊ฐ๋ฅ ๊ฒฝ๋ก)
|
19 |
+
TMP_DIR = "/tmp"
|
20 |
+
TRANSFORMERS_CACHE_DIR = os.path.join(TMP_DIR, '.cache', 'transformers')
|
21 |
+
SENTENCE_TRANSFORMERS_HOME_DIR = os.path.join(TMP_DIR, '.cache', 'sentence_transformers')
|
22 |
|
23 |
os.environ['TRANSFORMERS_CACHE'] = TRANSFORMERS_CACHE_DIR
|
24 |
os.environ['SENTENCE_TRANSFORMERS_HOME'] = SENTENCE_TRANSFORMERS_HOME_DIR
|
25 |
|
26 |
+
# ์บ์ ๋๋ ํ ๋ฆฌ ์์ฑ (์กด์ฌํ์ง ์์ผ๋ฉด) - /tmp ์๋๋ ์ผ๋ฐ์ ์ผ๋ก ์์ฑ ๊ฐ๋ฅ
|
27 |
+
try:
|
28 |
+
os.makedirs(TRANSFORMERS_CACHE_DIR, exist_ok=True)
|
29 |
+
os.makedirs(SENTENCE_TRANSFORMERS_HOME_DIR, exist_ok=True)
|
30 |
+
except PermissionError:
|
31 |
+
st.warning(f"โ ๏ธ ์บ์ ๋๋ ํ ๋ฆฌ ์์ฑ ๊ถํ ์์: {TRANSFORMERS_CACHE_DIR} ๋๋ {SENTENCE_TRANSFORMERS_HOME_DIR}. ๋ชจ๋ธ ๋ค์ด๋ก๋๊ฐ ๋๋ฆด ์ ์์ต๋๋ค.")
|
32 |
+
except Exception as e_mkdir:
|
33 |
+
st.warning(f"โ ๏ธ ์บ์ ๋๋ ํ ๋ฆฌ ์์ฑ ์ค ์ค๋ฅ: {e_mkdir}")
|
34 |
|
35 |
|
36 |
# ํ์ด์ง ์ค์
|