Spaces:
Runtime error
Runtime error
kootaeng2
commited on
Commit
ยท
c1b9543
1
Parent(s):
96b3478
Chore: Improve and update code comments
Browse files- scripts/save_complete_model.py +2 -0
- scripts/upload_model.py +1 -0
- src/emotion_engine.py +1 -4
scripts/save_complete_model.py
CHANGED
|
@@ -1,4 +1,6 @@
|
|
| 1 |
# save_complete_model.py
|
|
|
|
|
|
|
| 2 |
from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
| 3 |
|
| 4 |
# ๊ธฐ์กด ํ๋ จ ๊ฒฐ๊ณผ๋ฌผ์ด ์ ์ฅ๋ ๊ฒฝ๋ก
|
|
|
|
| 1 |
# save_complete_model.py
|
| 2 |
+
# ํ๋ จ๋ ๋ชจ๋ธ์ ๋ฐฐํฌ์ฉ์ผ๋ก ๋ณํ
|
| 3 |
+
|
| 4 |
from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
| 5 |
|
| 6 |
# ๊ธฐ์กด ํ๋ จ ๊ฒฐ๊ณผ๋ฌผ์ด ์ ์ฅ๋ ๊ฒฝ๋ก
|
scripts/upload_model.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
# upload_model.py
|
|
|
|
| 2 |
|
| 3 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 4 |
|
|
|
|
| 1 |
# upload_model.py
|
| 2 |
+
# ๋ฐฐํฌ์ฉ ๋ชจ๋ธ์ Hugging Face Hub์ ์
๋ก๋
|
| 3 |
|
| 4 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 5 |
|
src/emotion_engine.py
CHANGED
|
@@ -1,5 +1,4 @@
|
|
| 1 |
-
# emotion_engine.py
|
| 2 |
-
|
| 3 |
import torch
|
| 4 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline
|
| 5 |
import os
|
|
@@ -9,7 +8,6 @@ from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipe
|
|
| 9 |
import os
|
| 10 |
|
| 11 |
def load_emotion_classifier():
|
| 12 |
-
# --- ์ด ๋ถ๋ถ์ ์์ ํฉ๋๋ค ---
|
| 13 |
# ๋ก์ปฌ ๊ฒฝ๋ก ๋์ , Hugging Face Hub์ ๋ชจ๋ธ ID๋ฅผ ์ฌ์ฉํฉ๋๋ค.
|
| 14 |
MODEL_PATH = "koons/korean-emotion-classifier-final" # "์ฌ์ฉ์์ด๋ฆ/๋ชจ๋ธ์ด๋ฆ" ํ์
|
| 15 |
|
|
@@ -30,7 +28,6 @@ def load_emotion_classifier():
|
|
| 30 |
|
| 31 |
return emotion_classifier
|
| 32 |
|
| 33 |
-
# predict_emotion ํจ์๋ ๊ทธ๋๋ก ๋ก๋๋ค.
|
| 34 |
def predict_emotion(classifier, text):
|
| 35 |
if not text or not text.strip(): return "๋ด์ฉ ์์"
|
| 36 |
if classifier is None: return "์ค๋ฅ: ๊ฐ์ ๋ถ์ ์์ง ์ค๋น ์๋จ."
|
|
|
|
| 1 |
+
# emotion_engine.py
|
|
|
|
| 2 |
import torch
|
| 3 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline
|
| 4 |
import os
|
|
|
|
| 8 |
import os
|
| 9 |
|
| 10 |
def load_emotion_classifier():
|
|
|
|
| 11 |
# ๋ก์ปฌ ๊ฒฝ๋ก ๋์ , Hugging Face Hub์ ๋ชจ๋ธ ID๋ฅผ ์ฌ์ฉํฉ๋๋ค.
|
| 12 |
MODEL_PATH = "koons/korean-emotion-classifier-final" # "์ฌ์ฉ์์ด๋ฆ/๋ชจ๋ธ์ด๋ฆ" ํ์
|
| 13 |
|
|
|
|
| 28 |
|
| 29 |
return emotion_classifier
|
| 30 |
|
|
|
|
| 31 |
def predict_emotion(classifier, text):
|
| 32 |
if not text or not text.strip(): return "๋ด์ฉ ์์"
|
| 33 |
if classifier is None: return "์ค๋ฅ: ๊ฐ์ ๋ถ์ ์์ง ์ค๋น ์๋จ."
|