esun-choi commited on
Commit
90881fe
1 Parent(s): 4cfe9f7

Update ner.py

Browse files
Files changed (1) hide show
  1. ner.py +2 -1
ner.py CHANGED
@@ -2,7 +2,8 @@ from transformers import AutoTokenizer, AutoModelForTokenClassification
2
  from transformers import pipeline
3
  from collections import defaultdict
4
  import torch
5
- device = torch.device("cuda")
 
6
  tokenizer = AutoTokenizer.from_pretrained("Leo97/KoELECTRA-small-v3-modu-ner")
7
  model = AutoModelForTokenClassification.from_pretrained("Leo97/KoELECTRA-small-v3-modu-ner")
8
  model.to(device)
 
2
  from transformers import pipeline
3
  from collections import defaultdict
4
  import torch
5
+ # device = torch.device("cuda")
6
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
7
  tokenizer = AutoTokenizer.from_pretrained("Leo97/KoELECTRA-small-v3-modu-ner")
8
  model = AutoModelForTokenClassification.from_pretrained("Leo97/KoELECTRA-small-v3-modu-ner")
9
  model.to(device)