efeperro commited on
Commit
2453d6e
β€’
1 Parent(s): 56f8481

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
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 torch == True:
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, torch=True)
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: