File size: 1,157 Bytes
d3c9664 a9037ce 72664d1 a9037ce d3c9664 a9037ce 72664d1 a9037ce bda1407 aa80ce8 a9037ce fc26491 a9037ce 8660142 d3c9664 8660142 d3c9664 8660142 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
from transformers import AutoTokenizer, TFAutoModelForSequenceClassification
import streamlit as st
import os
import tensorflow as tf
from absl import logging
# Hugging Face ๋ชจ๋ธ ์ค์
tokenizer = AutoTokenizer.from_pretrained("snunlp/KR-FinBert-SC")
model = TFAutoModelForSequenceClassification.from_pretrained("snunlp/KR-FinBert-SC")
# ํ๊ฒฝ ๋ณ์ ์ค์
os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0' # oneDNN ์ต์ ํ ๋นํ์ฑํ
# ๋ก๊ทธ ์ด๊ธฐํ
logging.set_verbosity(logging.INFO)
logging.use_absl_handler()
# TensorFlow ์ ๋ณด ์ถ๋ ฅ
print("TensorFlow ๋ฒ์ :", tf.__version__)
print("์ฌ์ฉ ๊ฐ๋ฅํ ์ฅ์น:", tf.config.list_physical_devices())
# Streamlit ์ฑ ์ธํฐํ์ด์ค
st.title("Hello, Streamlit!")
st.write("This is a sample Streamlit app.")
# ์
๋ ฅ ํ๋ ์ถ๊ฐ
input_text = st.text_input("Enter some text:")
if st.button("Analyze"):
try:
inputs = tokenizer(input_text, return_tensors="tf") # TensorFlow์ ๊ฒฝ์ฐ 'tf'๋ฅผ ๋ช
์
outputs = model(**inputs)
st.write("Model Output:", outputs.logits.numpy().tolist())
except Exception as e:
st.error(f"Error during model inference: {e}")
|