Spaces:
Sleeping
Sleeping
Update model_utils.py
Browse files- model_utils.py +0 -17
model_utils.py
CHANGED
@@ -63,23 +63,6 @@ class BiLSTMForTokenClassification(nn.Module):
|
|
63 |
|
64 |
return {'loss': loss, 'logits': logits}
|
65 |
|
66 |
-
# Load custom BiLSTM and pre-trained BERT
|
67 |
-
def load_models():
|
68 |
-
"""
|
69 |
-
Loads the pre-trained BERT model from Hugging Face Hub.
|
70 |
-
|
71 |
-
Returns:
|
72 |
-
bert_model: The loaded BERT model.
|
73 |
-
"""
|
74 |
-
bert_model = AutoModelForTokenClassification.from_pretrained(".models/bert-model")
|
75 |
-
bert_model.eval()
|
76 |
-
|
77 |
-
with open('models/bilstm-model.pkl', 'rb') as f:
|
78 |
-
bilstm_model = pickle.load(f)
|
79 |
-
bilstm_model.eval()
|
80 |
-
|
81 |
-
return bert_model, bilstm_model
|
82 |
-
|
83 |
def load_custom_model(model_dir, tokenizer_dir, id2label):
|
84 |
config = AutoConfig.from_pretrained(model_dir, local_files_only=True)
|
85 |
config.id2label = id2label
|
|
|
63 |
|
64 |
return {'loss': loss, 'logits': logits}
|
65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
def load_custom_model(model_dir, tokenizer_dir, id2label):
|
67 |
config = AutoConfig.from_pretrained(model_dir, local_files_only=True)
|
68 |
config.id2label = id2label
|