|
|
import streamlit as st |
|
|
from transformers import pipeline, AutoTokenizer, AutoModelForSequenceClassification |
|
|
|
|
|
|
|
|
model_demo = "CKBot3/Workshop1_Demo" |
|
|
tokenizer = AutoTokenizer.from_pretrained(model_demo) |
|
|
model = AutoModelForSequenceClassification.from_pretrained(model_demo, num_labels=2) |
|
|
|
|
|
|
|
|
sentiment_analyzer = pipeline('sentiment-analysis', model=model, tokenizer=tokenizer) |
|
|
|
|
|
|
|
|
label_map = {"LABEL_0": "NEGATIVE", "LABEL_1": "POSITIVE"} |
|
|
|
|
|
st.title('Sentiment Analysis App') |
|
|
|
|
|
text = st.text_area('Enter text to analyze:') |
|
|
if st.button('Analyze'): |
|
|
result = sentiment_analyzer(text) |
|
|
for res in result: |
|
|
res['label'] = label_map[res['label']] |
|
|
st.write(result) |