Spaces:
Sleeping
Sleeping
Update emotion_predictor.py
Browse files- emotion_predictor.py +20 -1
emotion_predictor.py
CHANGED
@@ -10,6 +10,7 @@ from sklearn.linear_model import LinearRegression
|
|
10 |
from collections import defaultdict
|
11 |
import base64
|
12 |
from io import BytesIO
|
|
|
13 |
|
14 |
# ํฐํธ ์ค์
|
15 |
font_path = './NanumGothic.ttf'
|
@@ -136,4 +137,22 @@ def predict_and_plot(raw_text):
|
|
136 |
html_output += "<p>โ ๏ธ ์๊ฐํํ ์ ์๋ ๊ฐ์ ์ด ์์ต๋๋ค.</p><hr/>"
|
137 |
|
138 |
return html_output
|
139 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
from collections import defaultdict
|
11 |
import base64
|
12 |
from io import BytesIO
|
13 |
+
import streamlit as st
|
14 |
|
15 |
# ํฐํธ ์ค์
|
16 |
font_path = './NanumGothic.ttf'
|
|
|
137 |
html_output += "<p>โ ๏ธ ์๊ฐํํ ์ ์๋ ๊ฐ์ ์ด ์์ต๋๋ค.</p><hr/>"
|
138 |
|
139 |
return html_output
|
140 |
+
|
141 |
+
# ํ์ผ ์
๋ก๋ ์ฒ๋ฆฌ ํจ์
|
142 |
+
def upload_and_analyze():
|
143 |
+
uploaded_file = st.file_uploader("ํ
์คํธ ํ์ผ ์
๋ก๋", type=["txt"])
|
144 |
+
if uploaded_file is not None:
|
145 |
+
# ํ์ผ ๋ด์ฉ ์ฝ๊ธฐ
|
146 |
+
raw_text = uploaded_file.getvalue().decode("utf-8")
|
147 |
+
|
148 |
+
# ์์ธก ๋ฐ ์๊ฐํ
|
149 |
+
html_output = predict_and_plot(raw_text)
|
150 |
+
|
151 |
+
# ์ถ๋ ฅ ๊ฒฐ๊ณผ๋ฅผ HTML๋ก ๋ณด์ฌ์ฃผ๊ธฐ
|
152 |
+
st.markdown(html_output, unsafe_allow_html=True)
|
153 |
+
|
154 |
+
# Streamlit ์ฑ ์คํ
|
155 |
+
if __name__ == "__main__":
|
156 |
+
st.title("๊ฐ์ ๋ถ์๊ธฐ")
|
157 |
+
st.write("ํ
์คํธ ํ์ผ์ ์
๋ก๋ํ์ฌ ๊ฐ์ ๋ถ์์ ํด๋ณด์ธ์.")
|
158 |
+
upload_and_analyze()
|