Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
from transformers import AutoTokenizer,
|
2 |
import streamlit as st
|
3 |
import os
|
4 |
import tensorflow as tf
|
@@ -6,11 +6,10 @@ from absl import logging
|
|
6 |
|
7 |
# Hugging Face ๋ชจ๋ธ ์ค์
|
8 |
tokenizer = AutoTokenizer.from_pretrained("snunlp/KR-FinBert-SC")
|
9 |
-
model =
|
10 |
|
11 |
# ํ๊ฒฝ ๋ณ์ ์ค์
|
12 |
os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0' # oneDNN ์ต์ ํ ๋นํ์ฑํ
|
13 |
-
os.environ["CUDA_VISIBLE_DEVICES"] = "-1" # GPU ๋นํ์ฑํ (ํ์ ์)
|
14 |
|
15 |
# ๋ก๊ทธ ์ด๊ธฐํ
|
16 |
logging.set_verbosity(logging.INFO)
|
@@ -28,8 +27,8 @@ st.write("This is a sample Streamlit app.")
|
|
28 |
input_text = st.text_input("Enter some text:")
|
29 |
if st.button("Analyze"):
|
30 |
try:
|
31 |
-
inputs = tokenizer(input_text, return_tensors="
|
32 |
outputs = model(**inputs)
|
33 |
-
st.write("Model Output:", outputs.logits.tolist())
|
34 |
except Exception as e:
|
35 |
st.error(f"Error during model inference: {e}")
|
|
|
1 |
+
from transformers import AutoTokenizer, TFAutoModelForSequenceClassification
|
2 |
import streamlit as st
|
3 |
import os
|
4 |
import tensorflow as tf
|
|
|
6 |
|
7 |
# Hugging Face ๋ชจ๋ธ ์ค์
|
8 |
tokenizer = AutoTokenizer.from_pretrained("snunlp/KR-FinBert-SC")
|
9 |
+
model = TFAutoModelForSequenceClassification.from_pretrained("snunlp/KR-FinBert-SC")
|
10 |
|
11 |
# ํ๊ฒฝ ๋ณ์ ์ค์
|
12 |
os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0' # oneDNN ์ต์ ํ ๋นํ์ฑํ
|
|
|
13 |
|
14 |
# ๋ก๊ทธ ์ด๊ธฐํ
|
15 |
logging.set_verbosity(logging.INFO)
|
|
|
27 |
input_text = st.text_input("Enter some text:")
|
28 |
if st.button("Analyze"):
|
29 |
try:
|
30 |
+
inputs = tokenizer(input_text, return_tensors="tf") # TensorFlow์ ๊ฒฝ์ฐ 'tf'๋ฅผ ๋ช
์
|
31 |
outputs = model(**inputs)
|
32 |
+
st.write("Model Output:", outputs.logits.numpy().tolist())
|
33 |
except Exception as e:
|
34 |
st.error(f"Error during model inference: {e}")
|