abdulmatinomotoso commited on
Commit
2ba4fe2
·
1 Parent(s): a5e9ce3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -4,14 +4,14 @@ import torch
4
  import gradio as gr
5
  labels = ['sadness', 'joy','love', 'anger','fear', 'surprise']
6
 
7
- device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
8
  model_name = "abdulmatinomotoso/emotion_detection_finetuned_distilbert"
9
- model = AutoModelForSequenceClassification.from_pretrained(model_name).to(device)
10
  tokenizer = AutoTokenizer.from_pretrained(model_name)
11
 
12
 
13
  def get_emotion(text):
14
- input_tensor = tokenizer.encode(text, return_tensors="pt").to("cuda")
15
  logits = model(input_tensor).logits
16
 
17
  softmax = torch.nn.Softmax(dim=1)
 
4
  import gradio as gr
5
  labels = ['sadness', 'joy','love', 'anger','fear', 'surprise']
6
 
7
+ #device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
8
  model_name = "abdulmatinomotoso/emotion_detection_finetuned_distilbert"
9
+ model = AutoModelForSequenceClassification.from_pretrained(model_name)
10
  tokenizer = AutoTokenizer.from_pretrained(model_name)
11
 
12
 
13
  def get_emotion(text):
14
+ input_tensor = tokenizer.encode(text, return_tensors="pt")
15
  logits = model(input_tensor).logits
16
 
17
  softmax = torch.nn.Softmax(dim=1)