Spaces:
Build error
Build error
Download appV0.py from Dazzler007/SentimentDetector: direct link, hf CLI and curl.
- Browser
- Download file 1.42 kB
-
https://huggingface.co/spaces/Dazzler007/SentimentDetector/resolve/main/appV0.py
- Command line
-
hf download hf://spaces/Dazzler007/SentimentDetector/appV0.py
-
curl -L -o appV0.py https://huggingface.co/spaces/Dazzler007/SentimentDetector/resolve/main/appV0.py
1.42 kB
| import streamlit as st | |
| from transformers import pipeline, AutoConfig | |
| # Initialize the sentiment analysis pipeline | |
| pipe = pipeline('sentiment-analysis') | |
| # App Title | |
| st.title("AI in Marketing | AI Driven | Text to Sentiment Analysis App | by Darren Field") | |
| #st.text("Negative Sentiment - Example 1: The fish in the restaurant was not fresh.") | |
| #st.text("Positive Sentiment - Example 2: The fish in the restaurant was fresh.") | |
| #st.text("Positive Sentiments will reward you with ballons.") | |
| #st.text("You get the idea ...try your own!") | |
| st.text("To submit your text including your sentiment use (Ctrl + Enter) on your keyboard") | |
| # Get the model name | |
| model_name = pipe.model.name_or_path | |
| # Get more detailed information about the model | |
| config = AutoConfig.from_pretrained(model_name) | |
| # Display model information | |
| #st.write(f"Model Name: {model_name}") | |
| #st.write(f"Model Type: {config.model_type}") | |
| # Rest of your original code | |
| text = st.text_area('Enter text including your sentiment.') | |
| if text: | |
| out = pipe(text) | |
| st.json(out) | |
| # Check if sentiment is positive and display balloons | |
| if out[0]['label'] == 'POSITIVE': | |
| st.balloons() | |
| st.success("Positive sentiment detected! 🎉") | |
| else: | |
| st.info("Sentiment is not positive.") | |
| #st.text("If you enjoyed my app, please click on the like button located at the top of") | |
| #st.text("the page next to SentimentDector ...thank you!") | |