From 5191dae7fb086047489372fdc5c6a1cb6603155b Mon Sep 17 00:00:00 2001 From: marcsello Date: Mon, 14 Jun 2021 03:14:58 +0200 Subject: [PATCH] Added classification time measurement --- cnn_classification_service/magic_doer.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cnn_classification_service/magic_doer.py b/cnn_classification_service/magic_doer.py index de61036..2f225b5 100644 --- a/cnn_classification_service/magic_doer.py +++ b/cnn_classification_service/magic_doer.py @@ -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: