Spaces:
Runtime error
Runtime error
ashish rai
commited on
Commit
·
42d40cd
1
Parent(s):
0ca767f
updated the UI for sentiment
Browse files
app.py
CHANGED
|
@@ -2,7 +2,9 @@ import pandas as pd
|
|
| 2 |
import streamlit as st
|
| 3 |
from streamlit_text_rating.st_text_rater import st_text_rater
|
| 4 |
from sentiment import classify_sentiment
|
|
|
|
| 5 |
from zeroshot_clf import zero_shot_classification
|
|
|
|
| 6 |
|
| 7 |
st.set_page_config( # Alternate names: setup_page, page, layout
|
| 8 |
layout="wide", # Can be "centered" or "wide". In the future also "dashboard", etc.
|
|
@@ -63,15 +65,41 @@ st.title("NLP use cases")
|
|
| 63 |
with st.sidebar:
|
| 64 |
st.title("NLP tasks")
|
| 65 |
select_task=st.selectbox(label="Select task from drop down menu",
|
| 66 |
-
options=['
|
|
|
|
| 67 |
|
|
|
|
|
|
|
| 68 |
|
| 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 |
-
|
| 74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
for i,t in enumerate(input_texts.split(',')):
|
| 76 |
if sentiments[i]=='Positive':
|
| 77 |
response=st_text_rater(t + f"--> This statement is {sentiments[i]}",
|
|
|
|
| 2 |
import streamlit as st
|
| 3 |
from streamlit_text_rating.st_text_rater import st_text_rater
|
| 4 |
from sentiment import classify_sentiment
|
| 5 |
+
from sentiment_onnx_classify import classify_sentiment_onnx, classify_sentiment_onnx_quant
|
| 6 |
from zeroshot_clf import zero_shot_classification
|
| 7 |
+
import time
|
| 8 |
|
| 9 |
st.set_page_config( # Alternate names: setup_page, page, layout
|
| 10 |
layout="wide", # Can be "centered" or "wide". In the future also "dashboard", etc.
|
|
|
|
| 65 |
with st.sidebar:
|
| 66 |
st.title("NLP tasks")
|
| 67 |
select_task=st.selectbox(label="Select task from drop down menu",
|
| 68 |
+
options=['README',
|
| 69 |
+
'Detect Sentiment','Zero Shot Classification'])
|
| 70 |
|
| 71 |
+
if select_task=='README':
|
| 72 |
+
st.header("NLP Summary")
|
| 73 |
|
| 74 |
if select_task=='Detect Sentiment':
|
| 75 |
st.header("You are now performing Sentiment Analysis")
|
| 76 |
input_texts = st.text_input(label="Input texts separated by comma")
|
| 77 |
+
c1,c2,c3=st.columns(3)
|
| 78 |
+
|
| 79 |
+
with c1:
|
| 80 |
+
response1=st.button("Normal runtime")
|
| 81 |
+
with c2:
|
| 82 |
+
response2=st.button("ONNX runtime")
|
| 83 |
+
with c3:
|
| 84 |
+
response3=st.button("ONNX runtime with Quantization")
|
| 85 |
+
if any([response1,response2,response3]):
|
| 86 |
+
if response1:
|
| 87 |
+
start=time.time()
|
| 88 |
+
sentiments = classify_sentiment(input_texts)
|
| 89 |
+
end=time.time()
|
| 90 |
+
st.write(f"Time taken for computation {(end-start)*1000:.1f} ms")
|
| 91 |
+
elif response2:
|
| 92 |
+
start = time.time()
|
| 93 |
+
sentiments=classify_sentiment_onnx(input_texts)
|
| 94 |
+
end = time.time()
|
| 95 |
+
st.write(f"Time taken for computation {(end - start) * 1000:.1f} ms")
|
| 96 |
+
elif response3:
|
| 97 |
+
start = time.time()
|
| 98 |
+
sentiments=classify_sentiment_onnx_quant(input_texts)
|
| 99 |
+
end = time.time()
|
| 100 |
+
st.write(f"Time taken for computation {(end - start) * 1000:.1f} ms")
|
| 101 |
+
else:
|
| 102 |
+
pass
|
| 103 |
for i,t in enumerate(input_texts.split(',')):
|
| 104 |
if sentiments[i]=='Positive':
|
| 105 |
response=st_text_rater(t + f"--> This statement is {sentiments[i]}",
|