chrismay commited on
Commit
5a8c11f
·
1 Parent(s): 70330b3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -0
app.py CHANGED
@@ -1,11 +1,16 @@
1
  import streamlit as st
2
  from transformers import pipeline
3
 
 
 
 
 
4
  st.header("Sentiment-demo-app")
5
  st.subheader("Please be patient and wait up to a minute until the demo app is loaded.")
6
  st.caption("This is a very simple demo application for a zero-shot classification pipeline to classify positive, neutral, or negative sentiment for a short text. Enter your text in the box below and press CTRl+ENTER to run the model.")
7
 
8
  classifier = pipeline("zero-shot-classification", model='facebook/bart-large-mnli')
 
9
 
10
  text = st.text_area('Enter text here!')
11
  candidate_labels = ['Positive', 'Neutral', 'Negative']
 
1
  import streamlit as st
2
  from transformers import pipeline
3
 
4
+ import torch
5
+
6
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
7
+
8
  st.header("Sentiment-demo-app")
9
  st.subheader("Please be patient and wait up to a minute until the demo app is loaded.")
10
  st.caption("This is a very simple demo application for a zero-shot classification pipeline to classify positive, neutral, or negative sentiment for a short text. Enter your text in the box below and press CTRl+ENTER to run the model.")
11
 
12
  classifier = pipeline("zero-shot-classification", model='facebook/bart-large-mnli')
13
+ model.to(device)
14
 
15
  text = st.text_area('Enter text here!')
16
  candidate_labels = ['Positive', 'Neutral', 'Negative']