turicreate.image_similarity.create

turicreate.image_similarity.create(dataset, label=None, feature=None, model='resnet-50', verbose=True, batch_size=64)

Create a ImageSimilarityModel model.

Parameters:
dataset : SFrame

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

label : string

Name of the SFrame column with row labels to be used as uuid’s to identify the data. If ‘label’ is set to None, row numbers are used to identify reference dataset rows when the model is queried.

feature : string

Name of the column containing the input images. ‘None’ (the default) indicates that the SFrame has only one column of Image type and that will be used for similarity.

model: string, optional

Uses a pretrained model to bootstrap an image similarity model

  • “resnet-50” : Uses a pretrained resnet model.
  • “squeezenet_v1.1” : Uses a pretrained squeezenet model.
  • “VisionFeaturePrint_Scene”: Uses an OS internal feature extractor.
    Only on available on iOS 12.0+, macOS 10.14+ and tvOS 12.0+.

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

verbose : bool, optional

If True, print progress updates and model details.

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 : ImageSimilarityModel

A trained ImageSimilarityModel model.

Examples

# Train an image similarity model
>>> model = turicreate.image_similarity.create(data)

# Query the model for similar images
>>> similar_images = model.query(data)
+-------------+-----------------+-------------------+------+
| query_label | reference_label |      distance     | rank |
+-------------+-----------------+-------------------+------+
|      0      |        0        |        0.0        |  1   |
|      0      |       519       |   12.5319706301   |  2   |
|      0      |       1619      |   12.5563764596   |  3   |
|      0      |       186       |   12.6132604915   |  4   |
|      0      |       1809      |   12.9180964745   |  5   |
|      1      |        1        | 2.02304872852e-06 |  1   |
|      1      |       1579      |   11.4288186151   |  2   |
|      1      |       1237      |   12.3764325949   |  3   |
|      1      |        80       |   12.7264363676   |  4   |
|      1      |        58       |   12.7675058558   |  5   |
+-------------+-----------------+-------------------+------+
[500 rows x 4 columns]