Spaces:
Runtime error
Runtime error
| import subprocess | |
| # Install transformers package | |
| subprocess.run(['pip', 'install', 'transformers']) | |
| # Import transformers module | |
| from transformers import pipeline | |
| import streamlit as st | |
| # Summarization | |
| def summarization(text): | |
| text_model = pipeline("text-generation", model="ainize/bart-base-cnn") | |
| summary = text_model(text, max_length=100, temperature=1.0)[0]["generated_text"] | |
| return summary | |
| # Sentiment Classification | |
| def sentiment_classification(summary): | |
| sentiment_model = pipeline("text-classification", model="wxrrrrrrr/finetunde_sentiment_analysis") | |
| result = sentiment_model(summary, max_length=100, truncation=True)[0]['label'] | |
| if result != 'negative': | |
| result = 'positive' | |
| 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: | |
| # Stage 1: Summarization | |
| st.text('Processing text...') | |
| summary = summarization(text_input) | |
| # st.write(summary) | |
| # Stage 2: Sentiment Classification | |
| st.text('Analyzing sentiment...') | |
| sentiment = sentiment_classification(summary) | |
| st.write(sentiment) | |
| # Display the classification result | |
| st.write("Sentiment:", sentiment) | |
| if __name__ == '__main__': | |
| main() |