s2337a commited on
Commit
d3c9664
โ€ข
1 Parent(s): 8660142

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -1,4 +1,4 @@
1
- from transformers import AutoTokenizer, AutoModelForSequenceClassification
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 = AutoModelForSequenceClassification.from_pretrained("snunlp/KR-FinBert-SC")
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="pt")
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}")