Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -28,8 +28,8 @@ def load_cnn():
|
|
28 |
model.eval()
|
29 |
|
30 |
return model
|
31 |
-
def predict_sentiment(text, model, vocab, tokenizer):
|
32 |
-
if
|
33 |
processor.transform(text)
|
34 |
tokens = tokenizer(text)
|
35 |
encoded = [vocab[token] for token in tokens]
|
@@ -75,7 +75,7 @@ with st.expander("Model 2: CNN Sentiment analysis"):
|
|
75 |
user_input = st.text_area("Enter text here...", key='model2_input')
|
76 |
if st.button('Analyze', key='model2_button'):
|
77 |
# Displaying output
|
78 |
-
result = predict_sentiment(user_input, model_2,
|
79 |
if result >= 0.5:
|
80 |
st.write('The sentiment is: Positive π', key='model2_poswrite')
|
81 |
else:
|
|
|
28 |
model.eval()
|
29 |
|
30 |
return model
|
31 |
+
def predict_sentiment(text, model, vocab, tokenizer, torch_text = False):
|
32 |
+
if torch_text == True:
|
33 |
processor.transform(text)
|
34 |
tokens = tokenizer(text)
|
35 |
encoded = [vocab[token] for token in tokens]
|
|
|
75 |
user_input = st.text_area("Enter text here...", key='model2_input')
|
76 |
if st.button('Analyze', key='model2_button'):
|
77 |
# Displaying output
|
78 |
+
result = predict_sentiment(user_input, model_2, torch_text=True)
|
79 |
if result >= 0.5:
|
80 |
st.write('The sentiment is: Positive π', key='model2_poswrite')
|
81 |
else:
|