iSpr commited on
Commit
528a1dd
·
1 Parent(s): 353bb67

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -23,6 +23,8 @@ def md_loading():
23
  ## cpu
24
  # device = torch.device('cpu')
25
 
 
 
26
  tokenizer = XLMRobertaTokenizer.from_pretrained('xlm-roberta-large')
27
  model = XLMRobertaForSequenceClassification.from_pretrained('xlm-roberta-large', num_labels=493)
28
 
@@ -30,14 +32,15 @@ def md_loading():
30
  project_path = './'
31
  output_model_file = os.path.join(project_path, model_checkpoint)
32
 
33
- model.load_state_dict(torch.load(output_model_file, map_location=torch.device('cpu')))
 
34
  # ckpt = torch.load(output_model_file, map_location=torch.device('cpu'))
35
  # model.load_state_dict(ckpt['model_state_dict'])
36
 
37
  # device = torch.device("cuda" if torch.cuda.is_available() and not False else "cpu")
38
  # device = torch.device("cpu")
39
 
40
- # model.to(device)
41
 
42
  label_tbl = np.load('./label_table.npy')
43
  loc_tbl = pd.read_csv('./kisc_table.csv', encoding='utf-8')
 
23
  ## cpu
24
  # device = torch.device('cpu')
25
 
26
+ device = torch.device("cpu")
27
+
28
  tokenizer = XLMRobertaTokenizer.from_pretrained('xlm-roberta-large')
29
  model = XLMRobertaForSequenceClassification.from_pretrained('xlm-roberta-large', num_labels=493)
30
 
 
32
  project_path = './'
33
  output_model_file = os.path.join(project_path, model_checkpoint)
34
 
35
+ model.load_state_dict(torch.load(output_model_file)
36
+ # model.load_state_dict(torch.load(output_model_file, map_location=torch.device('cpu')))
37
  # ckpt = torch.load(output_model_file, map_location=torch.device('cpu'))
38
  # model.load_state_dict(ckpt['model_state_dict'])
39
 
40
  # device = torch.device("cuda" if torch.cuda.is_available() and not False else "cpu")
41
  # device = torch.device("cpu")
42
 
43
+ model.to(device)
44
 
45
  label_tbl = np.load('./label_table.npy')
46
  loc_tbl = pd.read_csv('./kisc_table.csv', encoding='utf-8')