How to do an inference

Do an inference

The name passed to the inference helper functions is the name you used in the specs.yaml

#Do a tagging inference
predictions = tagging("name_given_to_spec", image)

#Do a classification inference
predictions = classification("name_given_to_spec", image)

#Do a detection inference
predictions = detection("name_given_to_spec", image)

Helpers

Some helpers are available to help you extract from the predictions only the interesting concepts. For each of these helpers you can specify a threshold value that can be used to discard predictions with a score under that threshold.

Those methods return None if no predictions are found. Don't forget to handle that case !

# Get all the predictions above threshold
predictions.get_predictions(threshold=0.3) 

# Get the highest prediction
predictions.get_top_prediction(threshold=0.3)

# Get the highest prediction of a specific concept
# If a list is passed, it will return the first item with a concept in the list.
predictions.get_top_prediction_for_concept('concept_name', threshold=0.3)

# Get all the predictions of a specific concept
# If a list is passed, it will return the first item with a concept in the list.
predictions.get_predictions_for_concept('concept_name', threshold=0.3)

# Get the top prediction that have a concept name containing the given string
# If a list is passed, it will return the first item with a concept in the list.
predictions.get_top_prediction_for_similar_concepts ('compared_string', threshold=0)

# Get all the predictions that have a concept name containing the given string
# If a list is passed, it will return the first item with a concept in the list.
predictions.get_predictions_for_similar_concepts('compared_string', threshold=0)

# Get you a list of the different concepts that are predicted with a score above given threshold.
predictions.get_concept_list(threshold=0.3)