junhyun01 commited on
Commit
8854d9d
·
1 Parent(s): e7a7598

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -7,7 +7,7 @@ import re
7
 
8
  def paragraph_leveling(text):
9
  model_name = "./trained_model/fine_tunning_encoder_v2"
10
- model = AutoModel.from_pretrained(model_name)
11
  tokenizer = AutoTokenizer.from_pretrained('zzxslp/RadBERT-RoBERTa-4m')
12
 
13
  class MLP(nn.Module):
@@ -23,6 +23,7 @@ def paragraph_leveling(text):
23
 
24
  classifier = MLP(target_size=3, input_size=768)
25
  classifier.load_state_dict(torch.load('./trained_model/fine_tunning_classifier'))
 
26
  classifier.eval()
27
 
28
  output_list = []
@@ -44,7 +45,7 @@ def paragraph_leveling(text):
44
  padding='max_length',
45
  truncation=True,
46
  max_length=120)
47
- output = model(**train_encoding)
48
  output = classifier(output[1])
49
  output = output[0]
50
 
 
7
 
8
  def paragraph_leveling(text):
9
  model_name = "./trained_model/fine_tunning_encoder_v2"
10
+ model = AutoModel.from_pretrained(model_name).to('cpu')
11
  tokenizer = AutoTokenizer.from_pretrained('zzxslp/RadBERT-RoBERTa-4m')
12
 
13
  class MLP(nn.Module):
 
23
 
24
  classifier = MLP(target_size=3, input_size=768)
25
  classifier.load_state_dict(torch.load('./trained_model/fine_tunning_classifier'))
26
+ classifier.to('cpu')
27
  classifier.eval()
28
 
29
  output_list = []
 
45
  padding='max_length',
46
  truncation=True,
47
  max_length=120)
48
+ output = model(**train_encoding.to('cpu'))
49
  output = classifier(output[1])
50
  output = output[0]
51