ClassifyDescriptor

Classify a given descriptor based on the label of its k-nearest neighbors for a given DescriptorSet.

A blob must be provided in the array of blobs, which contains the query descriptor’s values. The blob is an binary array of 32-bit floating point values. The size of the blob, in bytes, must be dimensions*4.

Parameters

  • set: Name of the set.

  • k_neighbors: Specifies the number of nearest neighbors that will be used to assign a label to the given descriptor

  • [optional] engine: Specifies the engine used for indexing and computing distances. If not specified, the default engine will be used.

  • [optional] metric: Specifies the metric used to compute distances. If not specified, the default metric will be used.

Details

This command will “classify” a descriptor, i.e. assign a “label” to it, based on its k_neighbors nearest neighbors, and using the specified label when the descriptors were inserted. Check AddDescriptor for more details on how a “label” is assigned to a descriptor.

Examples

Classify a given descriptor using the labels of its 10 nearest neighbors:

[ {
    {
        "ClassifyDescriptor": {
            "set": "party_faces",
            "k_neighbors": 10,
        }
    }
}]

# A blob must be passed together with the JSON Query.
# The blobs is an array of 32-bit floating point values.

Classify a given descriptor using the labels of its 5 nearest neighbors, using the aproximated index “FaissIVFFlat” and inner-product as the distance metric:

[ {
    {
        "ClassifyDescriptor": {
            "set": "party_faces",
            "k_neighbors": 5,
            "metric": "IP",
            "engine": "FaissIVFFlat"
        }
    }
}]

# A blob must be passed together with the JSON Query.
# The blobs is an array of 32-bit floating point values.