Added more stuff to results
This commit is contained in:
@@ -14,6 +14,7 @@ class MagicDoer:
|
||||
def run_everything(cls, parameters: dict) -> dict:
|
||||
tag = parameters['tag']
|
||||
sample_file_handle, sample_file_path = tempfile.mkstemp(prefix=f"{tag}_", suffix=".wav")
|
||||
response = None
|
||||
try:
|
||||
|
||||
# Download Sample
|
||||
@@ -29,7 +30,15 @@ class MagicDoer:
|
||||
model_details, classifier = cls.classifier_cache.get_default_classifier()
|
||||
|
||||
# do the majic
|
||||
results = classifier.predict(sample_file_path)
|
||||
predicted_class_name, labeled_predictions = classifier.predict(sample_file_path)
|
||||
|
||||
response = {
|
||||
"tag": tag,
|
||||
"probability": labeled_predictions[model_details['target_class_name']],
|
||||
"all_predictions": labeled_predictions,
|
||||
"class": predicted_class_name,
|
||||
"model": model_details['id']
|
||||
}
|
||||
|
||||
finally:
|
||||
try:
|
||||
@@ -37,13 +46,10 @@ class MagicDoer:
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
|
||||
response = {
|
||||
"tag": tag,
|
||||
"probability": 1.0 if results[0] == model_details['target_class_name'] else 0.0,
|
||||
"model": model_details['id']
|
||||
}
|
||||
|
||||
logging.info(f"Classification done!")
|
||||
logging.debug(f"Results: {response}")
|
||||
if not response:
|
||||
logging.error("Something went wrong during classification!")
|
||||
else:
|
||||
logging.info(f"Classification done!")
|
||||
logging.debug(f"Results: {response}")
|
||||
|
||||
return response
|
||||
|
||||
Reference in New Issue
Block a user