File size: 1,342 Bytes
a9037ce 164e64f a9037ce 72664d1 a9037ce 72664d1 a9037ce bda1407 aa80ce8 a9037ce fc26491 a9037ce |
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 36 37 38 39 40 41 42 43 |
# Hugging Face ๋ชจ๋ธ ๋ก๋
from transformers import AutoTokenizer, AutoModelForSequenceClassification
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 = AutoModelForSequenceClassification.from_pretrained("snunlp/KR-FinBert-SC")
# ํ๊ฒฝ ๋ณ์ ์ค์
os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0' # oneDNN ์ต์ ํ ๋นํ์ฑํ
# ๋ก๊ทธ ์ด๊ธฐํ
logging.set_verbosity(logging.INFO)
logging.use_absl_handler()
# GPU ์ค์
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}")
# 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"):
inputs = tokenizer(input_text, return_tensors="pt")
outputs = model(**inputs)
st.write("Model Output:", outputs.logits.tolist())
|