Added classification time measurement
This commit is contained in:
parent
07689594b3
commit
5191dae7fb
@ -3,6 +3,7 @@ import os
|
|||||||
import logging
|
import logging
|
||||||
import tempfile
|
import tempfile
|
||||||
import requests
|
import requests
|
||||||
|
import time
|
||||||
|
|
||||||
from classifier_cache import ClassifierCache
|
from classifier_cache import ClassifierCache
|
||||||
|
|
||||||
@ -30,14 +31,17 @@ class MagicDoer:
|
|||||||
model_details, classifier = cls.classifier_cache.get_default_classifier()
|
model_details, classifier = cls.classifier_cache.get_default_classifier()
|
||||||
|
|
||||||
# do the majic
|
# do the majic
|
||||||
|
classification_start_time = time.time()
|
||||||
predicted_class_name, labeled_predictions = classifier.predict(sample_file_path)
|
predicted_class_name, labeled_predictions = classifier.predict(sample_file_path)
|
||||||
|
classification_duration = time.time() - classification_start_time
|
||||||
|
|
||||||
response = {
|
response = {
|
||||||
"tag": tag,
|
"tag": tag,
|
||||||
"probability": labeled_predictions[model_details['target_class_name']],
|
"probability": labeled_predictions[model_details['target_class_name']],
|
||||||
"all_predictions": labeled_predictions,
|
"all_predictions": labeled_predictions,
|
||||||
"class": predicted_class_name,
|
"class": predicted_class_name,
|
||||||
"model": model_details['id']
|
"model": model_details['id'],
|
||||||
|
"classification_duration": classification_duration
|
||||||
}
|
}
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
|
Loading…
Reference in New Issue
Block a user