|
import streamlit as st |
|
from transformers import pipeline |
|
|
|
|
|
def summarization(text): |
|
text_model = pipeline("text-generation", model="ainize/bart-base-cnn") |
|
summary = text_model(text, max_length=100, do_sample=False)[0]["generated_text"] |
|
return summary |
|
|
|
|
|
def sentiment_classification(summary): |
|
sentiment_model = pipeline("text-classification", model="wxrrrrrrr/finetuned_sentiment_analysis") |
|
result = sentiment_model(summary, max_length=100, do_sample=False)[0]['label'] |
|
return result |
|
|
|
def main(): |
|
st.set_page_config(page_title="Your Text Analysis", page_icon="π¦") |
|
st.header("Tell me your comments!") |
|
text_input = st.text_input("Enter your text here:") |
|
|
|
if text_input: |
|
|
|
st.text('Processing text...') |
|
summary = summarization(text_input) |
|
|
|
|
|
|
|
st.text('Analyzing sentiment...') |
|
sentiment = sentiment_classification(summary) |
|
st.write(sentiment) |
|
|
|
|
|
st.write("Sentiment:", sentiment) |
|
|
|
if __name__ == '__main__': |
|
main() |