Spaces:
Runtime error
Runtime error
MJ
commited on
Commit
·
ee41f8a
1
Parent(s):
f154ee6
Potential fix for button callback running on load
Browse files
app.py
CHANGED
@@ -2,12 +2,13 @@ import streamlit as st
|
|
2 |
from transformers import pipeline
|
3 |
|
4 |
|
5 |
-
def run_model():
|
6 |
classifier = pipeline(task="sentiment-analysis",
|
7 |
-
model=
|
8 |
-
analysis = classifier(
|
9 |
for output in analysis:
|
10 |
-
to_output = "Sentiment: ", output["label"], " Score: ",
|
|
|
11 |
st.markdown(to_output)
|
12 |
|
13 |
|
@@ -21,4 +22,5 @@ text_input = st.text_area(
|
|
21 |
model_picked = st.selectbox(
|
22 |
"Choose a model to run on", options=models_available.keys())
|
23 |
|
24 |
-
st.button("Submit", on_click=run_model(
|
|
|
|
2 |
from transformers import pipeline
|
3 |
|
4 |
|
5 |
+
def run_model(text_in, model_in):
|
6 |
classifier = pipeline(task="sentiment-analysis",
|
7 |
+
model=model_in)
|
8 |
+
analysis = classifier(text_in)
|
9 |
for output in analysis:
|
10 |
+
to_output = "Sentiment: ", output["label"], " Confidence Score: ", "{0:.2g}".format(
|
11 |
+
output["score"] * 100)
|
12 |
st.markdown(to_output)
|
13 |
|
14 |
|
|
|
22 |
model_picked = st.selectbox(
|
23 |
"Choose a model to run on", options=models_available.keys())
|
24 |
|
25 |
+
st.button("Submit", on_click=run_model, args=(
|
26 |
+
text_input, models_available[model_picked]))
|