ivyblossom commited on
Commit
5395bd1
·
1 Parent(s): 5b3f1eb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -2,11 +2,6 @@ import streamlit as st
2
  from transformers import AutoModelForSequenceClassification, AutoTokenizer
3
  import torch
4
 
5
- # Load the pretrained model and tokenizer
6
- model_name = "distilbert-base-uncased-finetuned-sst-2-english" # Example model
7
- model = AutoModelForSequenceClassification.from_pretrained(model_name)
8
- tokenizer = AutoTokenizer.from_pretrained(model_name)
9
-
10
  # Set up the device (GPU or CPU)
11
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
12
 
@@ -34,6 +29,11 @@ def main():
34
 
35
  selected_model = st.selectbox("Select a pretrained model", list(model_options.keys()))
36
 
 
 
 
 
 
37
  if st.button("Analyze"):
38
  sentiment_label, probabilities = perform_sentiment_analysis(text)
39
  st.write(f"Sentiment: {sentiment_label}")
 
2
  from transformers import AutoModelForSequenceClassification, AutoTokenizer
3
  import torch
4
 
 
 
 
 
 
5
  # Set up the device (GPU or CPU)
6
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
7
 
 
29
 
30
  selected_model = st.selectbox("Select a pretrained model", list(model_options.keys()))
31
 
32
+ # Load the pretrained model and tokenizer
33
+ model_name = selected_model
34
+ model = AutoModelForSequenceClassification.from_pretrained(model_name)
35
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
36
+
37
  if st.button("Analyze"):
38
  sentiment_label, probabilities = perform_sentiment_analysis(text)
39
  st.write(f"Sentiment: {sentiment_label}")