keethu commited on
Commit
581957e
·
verified ·
1 Parent(s): e0c4792

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -4
app.py CHANGED
@@ -3,12 +3,10 @@ import torch.nn as nn
3
  from transformers import BertTokenizer, BertModel
4
  import gradio as gr
5
 
6
- # Load tokenizer and base BERT model
7
- model_name = "keerthikapujari25/bert-emotion-classifier" # Replace with your HF username/repo
8
  tokenizer = BertTokenizer.from_pretrained(model_name)
9
  bert_model = BertModel.from_pretrained(model_name)
10
 
11
- # Define your classifier architecture (same as training)
12
  class BERTClassifier(nn.Module):
13
  def __init__(self, bert_model, num_labels=5, dropout=0.3):
14
  super(BERTClassifier, self).__init__()
@@ -23,7 +21,6 @@ class BERTClassifier(nn.Module):
23
  logits = self.classifier(pooled_output)
24
  return logits
25
 
26
- # Load model
27
  model = BERTClassifier(bert_model, num_labels=5, dropout=0.3)
28
  model.load_state_dict(torch.load(f"{model_name}/pytorch_model.bin", map_location='cpu'))
29
  model.eval()
 
3
  from transformers import BertTokenizer, BertModel
4
  import gradio as gr
5
 
6
+ model_name = "keethu/bert-emotion-classifier"
 
7
  tokenizer = BertTokenizer.from_pretrained(model_name)
8
  bert_model = BertModel.from_pretrained(model_name)
9
 
 
10
  class BERTClassifier(nn.Module):
11
  def __init__(self, bert_model, num_labels=5, dropout=0.3):
12
  super(BERTClassifier, self).__init__()
 
21
  logits = self.classifier(pooled_output)
22
  return logits
23
 
 
24
  model = BERTClassifier(bert_model, num_labels=5, dropout=0.3)
25
  model.load_state_dict(torch.load(f"{model_name}/pytorch_model.bin", map_location='cpu'))
26
  model.eval()