turicreate.object_detector.create

turicreate.object_detector.create(dataset, annotations=None, feature=None, model='darknet-yolo', classes=None, batch_size=0, max_iterations=0, verbose=True, grid_shape=[13, 13], **kwargs)

Create a ObjectDetector model.

Parameters:
dataset : SFrame

Input data. The columns named by the feature and annotations parameters will be extracted for training the detector.

annotations : string

Name of the column containing the object detection annotations. This column should be a list of dictionaries (or a single dictionary), with each dictionary representing a bounding box of an object instance. Here is an example of the annotations for a single image with two object instances:

[{'label': 'dog',
  'type': 'rectangle',
  'coordinates': {'x': 223, 'y': 198,
                  'width': 130, 'height': 230}},
 {'label': 'cat',
  'type': 'rectangle',
  'coordinates': {'x': 40, 'y': 73,
                  'width': 80, 'height': 123}}]

The value for x is the horizontal center of the box paired with width and y is the vertical center of the box paired with height. ‘None’ (the default) indicates the only list column in dataset should be used for the annotations.

feature : string

Name of the column containing the input images. ‘None’ (the default) indicates the only image column in dataset should be used as the feature.

model : string optional

Object detection model to use:

  • “darknet-yolo” : Fast and medium-sized model
grid_shape : array optional

Shape of the grid used for object detection. Higher values increase precision for small objects, but at a higher computational cost

  • [13, 13] : Default grid value for a Fast and medium-sized model
classes : list optional

List of strings containing the names of the classes of objects. Inferred from the data if not provided.

batch_size: int

The number of images per training iteration. If 0, then it will be automatically determined based on resource availability.

max_iterations : int

The number of training iterations. If 0, then it will be automatically be determined based on the amount of data you provide.

verbose : bool, optional

If True, print progress updates and model details.

Returns:
out : ObjectDetector

A trained ObjectDetector model.

See also

ObjectDetector

Examples

# Train an object detector model
>>> model = turicreate.object_detector.create(data)

# Make predictions on the training set and as column to the SFrame
>>> data['predictions'] = model.predict(data)

# Visualize predictions by generating a new column of marked up images
>>> data['image_pred'] = turicreate.object_detector.util.draw_bounding_boxes(data['image'], data['predictions'])