Spaces:
Sleeping
Sleeping
Commit
·
670a773
1
Parent(s):
2541baf
Update utils.py
Browse files
utils.py
CHANGED
@@ -454,7 +454,7 @@ NER Interface : We Use this interface to infer sentence Time-Date tags.
|
|
454 |
|
455 |
class NER(object):
|
456 |
|
457 |
-
def __init__(self, model_path,
|
458 |
|
459 |
self.tags = tags
|
460 |
self.device = "cuda" if torch.cuda.is_available() else "cpu"
|
@@ -462,7 +462,7 @@ class NER(object):
|
|
462 |
roberta_path = "xlm-roberta-base"
|
463 |
self.model = NERModel(n_labels=len(self.tags), roberta_path=roberta_path).to(self.device)
|
464 |
# Load Fine-Tuned model
|
465 |
-
state_dict = torch.load(
|
466 |
self.model.load_state_dict(state_dict, strict=False)
|
467 |
# Enable Evaluation mode
|
468 |
self.model.eval()
|
|
|
454 |
|
455 |
class NER(object):
|
456 |
|
457 |
+
def __init__(self, model_path, tags):
|
458 |
|
459 |
self.tags = tags
|
460 |
self.device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
|
462 |
roberta_path = "xlm-roberta-base"
|
463 |
self.model = NERModel(n_labels=len(self.tags), roberta_path=roberta_path).to(self.device)
|
464 |
# Load Fine-Tuned model
|
465 |
+
state_dict = torch.load(model_path)
|
466 |
self.model.load_state_dict(state_dict, strict=False)
|
467 |
# Enable Evaluation mode
|
468 |
self.model.eval()
|