Spaces:
Runtime error
Runtime error
| import streamlit as st | |
| from transformers import pipeline | |
| pipe = pipeline('sentiment-analysis') | |
| # Set the title and add introductory text | |
| st.title("Sentiment Analysis App") | |
| st.write("This simple app analyzes the sentiment of your text.") | |
| # Use 'form' to group input elements together | |
| with st.form("sentiment_form"): | |
| # Input for text to analyze sentiment | |
| text = st.text_area("Enter text for sentiment analysis:") | |
| # Add a button with a label | |
| submit_button = st.form_submit_button("Analyze Sentiment") | |
| # Check if the form was submitted | |
| if text and submit_button: | |
| # Analyze sentiment | |
| out = pipe(text) | |
| result = out[0] # Assuming you want the first result if multiple are returned | |
| sentiment = result["label"] | |
| score = round(result["score"], 2) # Round the score to two decimal places | |
| # Display sentiment analysis results | |
| st.header("Sentiment Analysis Result") | |
| st.write(f"**Sentiment**: {sentiment}") | |
| st.write(f"**Sentiment Score**: {score}") | |
| # Add a section for instructions on how to use the app | |
| st.header("How to Use") | |
| st.write("1. Enter text in the text area above.") | |
| st.write("2. Click the 'Analyze Sentiment' button to analyze the sentiment.") | |
| st.write("3. The sentiment label and score will be displayed below.") | |
| # Add a section with information about the sentiment analysis model | |
| st.header("About the Model") | |
| st.write("The sentiment analysis is performed using the Hugging Face Transformers library.") | |
| st.write("The model used is 'nlptown/bert-base-multilingual-uncased-sentiment'.") | |
| # Footer with additional information or links | |
| st.markdown("For more information, visit the [Hugging Face Transformers website](https://huggingface.co/transformers/).") | |
| # Footer with a link to LinkedIn profile | |
| st.header("Connect with Me on LinkedIn") | |
| st.write("Feel free to reach out for any inquiries, collaborations, or just to connect.") | |
| st.write("Visit my LinkedIn profile:") | |
| linkedin_link = "https://www.linkedin.com/in/iam-manoj/" | |
| linkedin_logo = "https://content.linkedin.com/content/dam/me/business/en-us/amp/brand-site/v2/bg/LI-Logo.svg.original.svg" | |
| st.markdown(f'<a href="{linkedin_link}"><img src="{linkedin_logo}" alt="LinkedIn Logo" width="100"></a>', unsafe_allow_html=True) |