|
|
|
from transformers import AutoTokenizer, AutoModelForSequenceClassification |
|
import streamlit as st |
|
import os |
|
import tensorflow as tf |
|
from absl import logging |
|
|
|
|
|
tokenizer = AutoTokenizer.from_pretrained("snunlp/KR-FinBert-SC") |
|
model = AutoModelForSequenceClassification.from_pretrained("snunlp/KR-FinBert-SC") |
|
|
|
|
|
os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0' |
|
|
|
|
|
logging.set_verbosity(logging.INFO) |
|
logging.use_absl_handler() |
|
|
|
|
|
gpus = tf.config.experimental.list_physical_devices('GPU') |
|
if gpus: |
|
try: |
|
for gpu in gpus: |
|
tf.config.experimental.set_memory_growth(gpu, True) |
|
print("GPU ๋ฉ๋ชจ๋ฆฌ ์ฆ๊ฐ ํ์ฉ ์ค์ ์๋ฃ") |
|
except RuntimeError as e: |
|
print(f"GPU ์ค์ ์ค๋ฅ: {e}") |
|
|
|
|
|
print("TensorFlow ๋ฒ์ :", tf.__version__) |
|
print("์ฌ์ฉ ๊ฐ๋ฅํ ์ฅ์น:", tf.config.list_physical_devices()) |
|
|
|
|
|
st.title("Hello, Streamlit!") |
|
st.write("This is a sample Streamlit app.") |
|
|
|
|
|
input_text = st.text_input("Enter some text:") |
|
if st.button("Analyze"): |
|
inputs = tokenizer(input_text, return_tensors="pt") |
|
outputs = model(**inputs) |
|
st.write("Model Output:", outputs.logits.tolist()) |
|
|