Spaces:
Runtime error
Runtime error
ashish rai
commited on
Commit
·
0ca767f
1
Parent(s):
0f80297
updated zero shot fig
Browse files- app.py +6 -5
- zeroshot_clf.py +8 -5
app.py
CHANGED
|
@@ -69,8 +69,8 @@ with st.sidebar:
|
|
| 69 |
if select_task=='Detect Sentiment':
|
| 70 |
st.header("You are now performing Sentiment Analysis")
|
| 71 |
input_texts = st.text_input(label="Input texts separated by comma")
|
| 72 |
-
|
| 73 |
-
if
|
| 74 |
sentiments = classify_sentiment(input_texts)
|
| 75 |
for i,t in enumerate(input_texts.split(',')):
|
| 76 |
if sentiments[i]=='Positive':
|
|
@@ -84,7 +84,8 @@ if select_task=='Zero Shot Classification':
|
|
| 84 |
st.header("You are now performing Zero Shot Classification")
|
| 85 |
input_texts = st.text_input(label="Input text to classify into topics")
|
| 86 |
input_lables = st.text_input(label="Enter labels separated by commas")
|
| 87 |
-
|
| 88 |
-
if
|
| 89 |
output=zero_shot_classification(input_texts, input_lables)
|
| 90 |
-
|
|
|
|
|
|
| 69 |
if select_task=='Detect Sentiment':
|
| 70 |
st.header("You are now performing Sentiment Analysis")
|
| 71 |
input_texts = st.text_input(label="Input texts separated by comma")
|
| 72 |
+
response=st.button("Calculate")
|
| 73 |
+
if response:
|
| 74 |
sentiments = classify_sentiment(input_texts)
|
| 75 |
for i,t in enumerate(input_texts.split(',')):
|
| 76 |
if sentiments[i]=='Positive':
|
|
|
|
| 84 |
st.header("You are now performing Zero Shot Classification")
|
| 85 |
input_texts = st.text_input(label="Input text to classify into topics")
|
| 86 |
input_lables = st.text_input(label="Enter labels separated by commas")
|
| 87 |
+
response = st.button("Calculate")
|
| 88 |
+
if response:
|
| 89 |
output=zero_shot_classification(input_texts, input_lables)
|
| 90 |
+
config = {'displayModeBar': False}
|
| 91 |
+
st.plotly_chart(output,config=config)
|
zeroshot_clf.py
CHANGED
|
@@ -34,11 +34,14 @@ def zero_shot_classification(premise:str,labels:str,model=model,tokenizer=tokeni
|
|
| 34 |
|
| 35 |
df=pd.DataFrame({'labels':labels,
|
| 36 |
'Probability':labels_prob_norm})
|
| 37 |
-
fig=px.bar(x=
|
| 38 |
-
y=
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
| 42 |
# labels='science, sports, museum')
|
| 43 |
|
| 44 |
|
|
|
|
| 34 |
|
| 35 |
df=pd.DataFrame({'labels':labels,
|
| 36 |
'Probability':labels_prob_norm})
|
| 37 |
+
fig=px.bar(x='Probability',
|
| 38 |
+
y='labels',
|
| 39 |
+
text='Probability',
|
| 40 |
+
data_frame=df,
|
| 41 |
+
title='Zero Shot Normalized Probabilities')
|
| 42 |
+
return fig
|
| 43 |
+
|
| 44 |
+
# zero_shot_classification(premise='Tiny worms and breath analyzers could screen for \disease while it’s early and treatable',
|
| 45 |
# labels='science, sports, museum')
|
| 46 |
|
| 47 |
|