rbbist commited on
Commit
873b7fb
·
verified ·
1 Parent(s): ac06346

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -4
app.py CHANGED
@@ -1,9 +1,19 @@
1
  import streamlit as st
2
  from transformers import pipeline
3
 
4
- pipe = pipeline("sentiment analysis")
5
- text = st.text_area("Enter some text")
6
 
 
 
 
 
 
 
 
 
 
 
 
7
  if text:
8
- out = pipe(text)
9
- st.json(out)
 
1
  import streamlit as st
2
  from transformers import pipeline
3
 
4
+ st.title("Sentiment Analysis")
 
5
 
6
+ # Load pipeline once
7
+ @st.cache_resource
8
+ def load_pipeline():
9
+ return pipeline("sentiment-analysis")
10
+
11
+ pipe = load_pipeline()
12
+
13
+ # User input
14
+ text = st.text_area("Enter some text to analyze")
15
+
16
+ # Show result
17
  if text:
18
+ result = pipe(text)
19
+ st.write("**Result:**", result[0]["label"], f"({result[0]['score']:.2f})")