PenguinMan commited on
Commit
36effc7
·
1 Parent(s): d7d1efc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -0
app.py CHANGED
@@ -2,6 +2,10 @@ import gradio as gr
2
  import transformers
3
  import torch
4
  from transformers import BertModel, BertTokenizer, AdamW, get_linear_schedule_with_warmup
 
 
 
 
5
 
6
  class_names = ['left', 'neutral', 'right']
7
  PRE_TRAINED_MODEL_NAME = 'bert-base-uncased'
@@ -27,6 +31,8 @@ class SentimentClassifier(nn.Module):
27
 
28
  model = SentimentClassifier(len(class_names))
29
 
 
 
30
  def result_final(new_article):
31
 
32
  encoded_review = tokenizer.encode_plus(
@@ -50,4 +56,5 @@ def result_final(new_article):
50
 
51
  iface = gr.Interface(fn = result_final, inputs = "text", outputs = ["text"], title = "News Bias Classifer")
52
  iface.launch()
 
53
 
 
2
  import transformers
3
  import torch
4
  from transformers import BertModel, BertTokenizer, AdamW, get_linear_schedule_with_warmup
5
+ from torch import nn, optim
6
+ from torch.utils.data import Dataset, DataLoader
7
+ import pickle
8
+
9
 
10
  class_names = ['left', 'neutral', 'right']
11
  PRE_TRAINED_MODEL_NAME = 'bert-base-uncased'
 
31
 
32
  model = SentimentClassifier(len(class_names))
33
 
34
+
35
+ model2 = pickle.load(open("model_BERT_2", "rb"))
36
  def result_final(new_article):
37
 
38
  encoded_review = tokenizer.encode_plus(
 
56
 
57
  iface = gr.Interface(fn = result_final, inputs = "text", outputs = ["text"], title = "News Bias Classifer")
58
  iface.launch()
59
+
60