Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,21 @@
|
|
1 |
-
|
2 |
-
|
3 |
|
4 |
-
|
|
|
|
|
5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import AutoTokenizer, TFAutoModelForSequenceClassification
|
2 |
+
import streamlit as st
|
3 |
|
4 |
+
# Hugging Face 모델 로드
|
5 |
+
tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased") # 모델 이름 변경
|
6 |
+
model = TFAutoModelForSequenceClassification.from_pretrained("bert-base-uncased")
|
7 |
|
8 |
+
# Streamlit 앱
|
9 |
+
st.title("Text Analysis with Hugging Face Model")
|
10 |
+
st.write("Enter text below to analyze it using the selected Hugging Face model.")
|
11 |
+
|
12 |
+
# 입력 필드
|
13 |
+
input_text = st.text_input("Enter text here:")
|
14 |
+
if st.button("Analyze"):
|
15 |
+
try:
|
16 |
+
inputs = tokenizer(input_text, return_tensors="tf")
|
17 |
+
outputs = model(**inputs)
|
18 |
+
logits = outputs.logits.numpy().tolist()
|
19 |
+
st.write("Model Output (logits):", logits)
|
20 |
+
except Exception as e:
|
21 |
+
st.error(f"Error during model inference: {e}")
|