Delete app.py
Browse files
app.py
DELETED
|
@@ -1,33 +0,0 @@
|
|
| 1 |
-
# Import necessary libraries
|
| 2 |
-
import streamlit as st
|
| 3 |
-
import transformers
|
| 4 |
-
import torch
|
| 5 |
-
from transformers import pipeline
|
| 6 |
-
|
| 7 |
-
# Set up the Streamlit app
|
| 8 |
-
st.title("Emotion Detection with Transformers")
|
| 9 |
-
|
| 10 |
-
# Create a text input widget
|
| 11 |
-
user_input = st.text_area("Enter your text:")
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
# Define a function for sentiment analysis using transformers
|
| 15 |
-
@st.cache_data
|
| 16 |
-
def load_model():
|
| 17 |
-
return pipeline("sentiment-analysis")
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
# Load the sentiment analysis model
|
| 21 |
-
sentiment_analyzer = load_model()
|
| 22 |
-
|
| 23 |
-
# Create a button to analyze the emotion
|
| 24 |
-
if st.button("Analyze Emotion"):
|
| 25 |
-
if user_input:
|
| 26 |
-
# Perform sentiment analysis on user input
|
| 27 |
-
result = sentiment_analyzer(user_input)
|
| 28 |
-
|
| 29 |
-
# Display the result
|
| 30 |
-
emotion = result[0]['label']
|
| 31 |
-
st.write(f"Emotion: {emotion}")
|
| 32 |
-
else:
|
| 33 |
-
st.warning("Please enter some text to analyze.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|