Upload inference.py
Browse files- inference.py +5 -8
inference.py
CHANGED
|
@@ -92,7 +92,7 @@ def convert_intent_to_label(intent_logit):
|
|
| 92 |
return intent_labels[int(intent_logit)]
|
| 93 |
|
| 94 |
|
| 95 |
-
def main(
|
| 96 |
"""
|
| 97 |
Main function to perform inference using the pre-trained model.
|
| 98 |
"""
|
|
@@ -100,6 +100,7 @@ def main(input_data):
|
|
| 100 |
model_path = "pytorch_model.bin"
|
| 101 |
model = load_model(model_path)
|
| 102 |
|
|
|
|
| 103 |
# Preprocess the input text
|
| 104 |
input_ids, attention_mask, offset_mapping = preprocess_input(input_data)
|
| 105 |
|
|
@@ -113,13 +114,9 @@ def main(input_data):
|
|
| 113 |
ner_logits = align_ner_predictions_with_input(ner_logits, offset_mapping, input_data)
|
| 114 |
intent_label = convert_intent_to_label(intent_logits)
|
| 115 |
|
| 116 |
-
|
|
|
|
| 117 |
|
| 118 |
|
| 119 |
if __name__ == "__main__":
|
| 120 |
-
|
| 121 |
-
input_data = "I want to schedule a meeting for the 15th of this month at 2:30 PM."
|
| 122 |
-
ner_logits, intent_label = main(input_data)
|
| 123 |
-
|
| 124 |
-
print(f"Ner logits: {ner_logits}")
|
| 125 |
-
print(f"Intent logits: {intent_label}")
|
|
|
|
| 92 |
return intent_labels[int(intent_logit)]
|
| 93 |
|
| 94 |
|
| 95 |
+
def main():
|
| 96 |
"""
|
| 97 |
Main function to perform inference using the pre-trained model.
|
| 98 |
"""
|
|
|
|
| 100 |
model_path = "pytorch_model.bin"
|
| 101 |
model = load_model(model_path)
|
| 102 |
|
| 103 |
+
input_data = input("Enter the text to analyze: ")
|
| 104 |
# Preprocess the input text
|
| 105 |
input_ids, attention_mask, offset_mapping = preprocess_input(input_data)
|
| 106 |
|
|
|
|
| 114 |
ner_logits = align_ner_predictions_with_input(ner_logits, offset_mapping, input_data)
|
| 115 |
intent_label = convert_intent_to_label(intent_logits)
|
| 116 |
|
| 117 |
+
print(f"Ner logits: {ner_logits}")
|
| 118 |
+
print(f"Intent logits: {intent_label}")
|
| 119 |
|
| 120 |
|
| 121 |
if __name__ == "__main__":
|
| 122 |
+
main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|