Spaces:
Runtime error
Runtime error
MJ
commited on
Commit
·
0e46a6f
1
Parent(s):
0dcbd95
Added code to app.py
Browse files- Hugging Face Files/app.py +23 -0
Hugging Face Files/app.py
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
def run_model():
|
| 6 |
+
classifier = pipeline(task="sentiment-analysis",
|
| 7 |
+
model=models_available[model_picked])
|
| 8 |
+
analysis = classifier(text_input)
|
| 9 |
+
st.markdown("Sentiment: ", analysis["label"], "Score: ", analysis["score"])
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
models_available = {"Roberta Large English": "siebert/sentiment-roberta-large-english",
|
| 13 |
+
"Generic": "Seethal/sentiment_analysis_generic_dataset",
|
| 14 |
+
"Twitter Roberta": "cardiffnlp/twitter-roberta-base-sentiment"}
|
| 15 |
+
|
| 16 |
+
st.title("Sentiment Analysis Web Application")
|
| 17 |
+
text_input = st.text_area("I love Pizza")
|
| 18 |
+
model_picked = st.selectbox(
|
| 19 |
+
"Choose a model to run on", options=models_available.keys())
|
| 20 |
+
|
| 21 |
+
st.button("Submit", run_model())
|
| 22 |
+
|
| 23 |
+
run_model()
|