turicreate.image_classifier.create

turicreate.image_classifier.create(dataset, target, feature=None, model='resnet-50', validation_set='auto', max_iterations=10, verbose=True, seed=None, batch_size=64)

Create a ImageClassifier model.

Parameters:
dataset : SFrame

Input data. The column named by the ‘feature’ parameter will be extracted for modeling.

target : string, or int

Name of the column containing the target variable. The values in this column must be of string or integer type. String target variables are automatically mapped to integers in the order in which they are provided. For example, a target variable with ‘cat’ and ‘dog’ as possible values is mapped to 0 and 1 respectively with 0 being the base class and 1 being the reference class. Use model.classes to retrieve the order in which the classes are mapped.

feature : string, optional

indicates that the SFrame has only column of Image type and that will 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

Uses a pretrained model to bootstrap an image classifier:

  • “resnet-50” : Uses a pretrained resnet model.
    Exported Core ML model will be ~90M.
  • “squeezenet_v1.1” : Uses a pretrained squeezenet model.
    Exported Core ML model will be ~4.7M.
  • “VisionFeaturePrint_Screen”: Uses an OS internal feature extractor.
    Only on available on iOS 12.0+, macOS 10.14+ and tvOS 12.0+. Exported Core ML model will be ~41K.

Models are downloaded from the internet if not available locally. Once downloaded, the models are cached for future use.

validation_set : SFrame, optional

A dataset for monitoring the model’s generalization performance. The format of this SFrame must be the same as the training set. By default this argument is set to ‘auto’ and a validation set is automatically sampled and used for progress printing. If validation_set is set to None, then no additional metrics are computed. The default value is ‘auto’.

max_iterations : float, optional

The maximum number of allowed passes through the data. More passes over the data can result in a more accurately trained model. Consider increasing this (the default value is 10) if the training accuracy is low and the Grad-Norm in the display is large.

verbose : bool, optional

If True, prints progress updates and model details.

seed : int, optional

Seed for random number generation. Set this value to ensure that the same model is created every time.

batch_size : int, optional

If you are getting memory errors, try decreasing this value. If you have a powerful computer, increasing this value may improve performance.

Returns:
out : ImageClassifier

A trained ImageClassifier model.

See also

ImageClassifier

Examples

>>> model = turicreate.image_classifier.create(data, target='is_expensive')

# Make predictions (in various forms)
>>> predictions = model.predict(data)      # predictions
>>> predictions = model.classify(data)     # predictions with confidence
>>> predictions = model.predict_topk(data) # Top-5 predictions (multiclass)

# Evaluate the model with ground truth data
>>> results = model.evaluate(data)