s2337a commited on
Commit
9177d9d
·
verified ·
1 Parent(s): cff2ebd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -3
app.py CHANGED
@@ -1,5 +1,21 @@
1
- pip install transformers
2
- from transformers import pipeline
3
 
4
- sentiment_classification = pipeline("text-classification", "SamLowe/roberta-base-go_emotions")
 
 
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}")