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