shivapaka commited on
Commit
2fcc45c
·
verified ·
1 Parent(s): 36f8437

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -5
app.py CHANGED
@@ -1,9 +1,26 @@
 
1
  from transformers import pipeline
2
 
3
- # Create a text classification pipeline
4
- classifier = pipeline("sentiment-analysis", model="roberta-base-openai-detector")
5
 
6
- # Use the pipeline to classify some text
7
- result = classifier("I love using Hugging Face Transformers!")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
 
9
- print(result)
 
1
+ import streamlit as st
2
  from transformers import pipeline
3
 
4
+ # Load the sentiment analysis pipeline
5
+ sentiment_pipeline = pipeline("sentiment-analysis")
6
 
7
+ # Streamlit interface
8
+ st.title("Sentiment Analysis with Hugging Face Transformers")
9
+
10
+ # Input text box
11
+ user_input = st.text_area("Enter text to analyze sentiment:", "I love using Hugging Face transformers!")
12
+
13
+ # Analyze sentiment button
14
+ if st.button("Analyze Sentiment"):
15
+ # Perform sentiment analysis
16
+ result = sentiment_pipeline(user_input)
17
+
18
+ # Display the result
19
+ sentiment = result[0]['label']
20
+ confidence = result[0]['score']
21
+ st.write(f"Sentiment: **{sentiment}**")
22
+ st.write(f"Confidence: **{confidence:.4f}**")
23
+
24
+ # To run the Streamlit app, use the command:
25
+ # streamlit run your_script_name.py
26