jonnyzhong commited on
Commit
4bac13a
·
1 Parent(s): eb7ab16

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ from transformers import pipeline
4
+
5
+ st.title("Hugging Face Demo")
6
+
7
+ text = st.text_input("Enter text to analyze")
8
+
9
+ st.cache_resource
10
+
11
+ def get_model():
12
+
13
+ return pipeline("sentiment-analysis")
14
+
15
+ model = get_model()
16
+
17
+ if text:
18
+
19
+ result = model(text)
20
+
21
+ st.write("Sentiment:", result[0]["label"])
22
+
23
+ st.write("Confidence:", result[0]["score"])