turicreate.object_detector.ObjectDetector.export_coreml

ObjectDetector.export_coreml(filename, include_non_maximum_suppression=True, iou_threshold=None, confidence_threshold=None)

Save the model in Core ML format. The Core ML model takes an image of fixed size as input and produces two output arrays: confidence and coordinates.

The first one, confidence is an N-by-C array, where N is the number of instances predicted and C is the number of classes. The number N is fixed and will include many low-confidence predictions. The instances are not sorted by confidence, so the first one will generally not have the highest confidence (unlike in predict). Also unlike the predict function, the instances have not undergone what is called non-maximum suppression, which means there could be several instances close in location and size that have all discovered the same object instance. Confidences do not need to sum to 1 over the classes; any remaining probability is implied as confidence there is no object instance present at all at the given coordinates. The classes appear in the array alphabetically sorted.

The second array coordinates is of size N-by-4, where the first dimension N again represents instances and corresponds to the confidence array. The second dimension represents x, y, width, height, in that order. The values are represented in relative coordinates, so (0.5, 0.5) represents the center of the image and (1, 1) the bottom right corner. You will need to multiply the relative values with the original image size before you resized it to the fixed input size to get pixel-value coordinates similar to predict.

Parameters:
filename : string

The path of the file where we want to save the Core ML model.

include_non_maximum_suppression : bool

Non-maximum suppression is only available in iOS 12+. A boolean parameter to indicate whether the Core ML model should be saved with built-in non-maximum suppression or not. This parameter is set to True by default.

iou_threshold : float

Threshold value for non-maximum suppression. Non-maximum suppression prevents multiple bounding boxes appearing over a single object. This threshold, set between 0 and 1, controls how aggressive this suppression is. A value of 1 means no maximum suppression will occur, while a value of 0 will maximally suppress neighboring boxes around a prediction.

confidence_threshold : float

Only return predictions above this level of confidence. The threshold can range from 0 to 1.

See also

save

Examples

>>> model.export_coreml('detector.mlmodel')