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}")
|