dashasabirova commited on
Commit
d93b6b1
1 Parent(s): 5b69d1c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -20
app.py CHANGED
@@ -9,28 +9,31 @@ labels_articles = {1: 'Computer Science', 2: 'Economics', 3: "Electrical Enginee
9
  4: "Mathematics", 5: "Physics", 6: "Quantitative Biology", 7: "Quantitative Finance",
10
  8: "Statistics"
11
  }
12
-
13
- class Net(nn.Module):
14
- def __init__(self):
15
- super(Net,self).__init__()
16
- self.layer = nn.Sequential(
17
- nn.Linear(768, 256),
18
- nn.ReLU(),
19
- nn.Linear(256, 128),
20
- nn.ReLU(),
21
- nn.Linear(128, 8),
22
- )
23
-
24
- def forward(self,x):
25
- return self.layer(x)
 
 
 
 
26
 
27
- model_second = Net()
28
- model_second.load_state_dict(torch.load('model.txt'))
29
- model_second.eval()
 
30
 
31
- model_name = 'bert-base-uncased'
32
- tokenizer = AutoTokenizer.from_pretrained(model_name)
33
- model_first = AutoModel.from_pretrained(model_name)
34
 
35
  title = st.text_area("Write the title of your article, please")
36
  abstract = st.text_area("Write the abstract")
 
9
  4: "Mathematics", 5: "Physics", 6: "Quantitative Biology", 7: "Quantitative Finance",
10
  8: "Statistics"
11
  }
12
+ def models():
13
+ class Net(nn.Module):
14
+ def __init__(self):
15
+ super(Net,self).__init__()
16
+ self.layer = nn.Sequential(
17
+ nn.Linear(768, 256),
18
+ nn.ReLU(),
19
+ nn.Linear(256, 128),
20
+ nn.ReLU(),
21
+ nn.Linear(128, 8),
22
+ )
23
+
24
+ def forward(self,x):
25
+ return self.layer(x)
26
+
27
+ model_second = Net()
28
+ model_second.load_state_dict(torch.load('model.txt'))
29
+ model_second.eval()
30
 
31
+ model_name = 'bert-base-uncased'
32
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
33
+ model_first = AutoModel.from_pretrained(model_name)
34
+ return (model_first, model_second, tokenizer)
35
 
36
+ model_first, model_second, tokenizer = models()
 
 
37
 
38
  title = st.text_area("Write the title of your article, please")
39
  abstract = st.text_area("Write the abstract")