Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,9 +1,19 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
-
|
| 5 |
-
text = st.text_area("Enter some text")
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
if text:
|
| 8 |
-
|
| 9 |
-
st.
|
|
|
|
| 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})")
|