yureeets123 commited on
Commit
fb253cd
·
verified ·
1 Parent(s): 12458f9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -6
app.py CHANGED
@@ -1,13 +1,18 @@
1
  import streamlit as st
2
  from transformers import pipeline
3
 
4
- # Load the sentiment analysis pipeline
5
- sentiment_pipeline = pipeline(
6
- "text-classification",
7
- model="tabularisai/multilingual-sentiment-analysis"
8
- )
9
-
10
  st.title("Sentiment Analysis App")
 
 
 
 
 
 
 
 
 
 
 
11
  user_input = st.text_area("Enter text:")
12
 
13
  if user_input:
 
1
  import streamlit as st
2
  from transformers import pipeline
3
 
 
 
 
 
 
 
4
  st.title("Sentiment Analysis App")
5
+
6
+ @st.cache_resource # cache the pipeline so it's only loaded once
7
+ def load_sentiment_pipeline():
8
+ return pipeline(
9
+ "text-classification",
10
+ model="tabularisai/multilingual-sentiment-analysis",
11
+ device=-1 # ensure CPU; remove or change if you have a GPU
12
+ )
13
+
14
+ sentiment_pipeline = load_sentiment_pipeline()
15
+
16
  user_input = st.text_area("Enter text:")
17
 
18
  if user_input: