Added classification time measurement

This commit is contained in:
Pünkösd Marcell 2021-06-14 03:14:58 +02:00
parent 07689594b3
commit 5191dae7fb

View File

@ -3,6 +3,7 @@ import os
import logging
import tempfile
import requests
import time
from classifier_cache import ClassifierCache
@ -30,14 +31,17 @@ class MagicDoer:
model_details, classifier = cls.classifier_cache.get_default_classifier()
# do the majic
classification_start_time = time.time()
predicted_class_name, labeled_predictions = classifier.predict(sample_file_path)
classification_duration = time.time() - classification_start_time
response = {
"tag": tag,
"probability": labeled_predictions[model_details['target_class_name']],
"all_predictions": labeled_predictions,
"class": predicted_class_name,
"model": model_details['id']
"model": model_details['id'],
"classification_duration": classification_duration
}
finally: