Spaces:
Runtime error
Runtime error
Commit
•
5e5600c
1
Parent(s):
813a9a0
add req, streamlit app
Browse files- app.py +12 -0
- requirements.txt +2 -0
app.py
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from transformers import pipeline
|
3 |
+
st.title("Hugging Face Demo")
|
4 |
+
text = st.text_input("Enter text to analyze")
|
5 |
+
st.cache_resource
|
6 |
+
def get_model():
|
7 |
+
return pipeline("sentiment-analysis")
|
8 |
+
model = get_model()
|
9 |
+
if text:
|
10 |
+
result = model(text)
|
11 |
+
st.write("Sentiment:", result[0]["label"])
|
12 |
+
st.write("Confidence:", result[0]["score"])
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
streamlit==1.24.1
|
2 |
+
transformers==4.32.1
|