Contents

ClassifyImageRequest

A request to classify an image.

Declaration

struct ClassifyImageRequest

Overview

This type of request produces a collection of ClassificationObservation objects that describe an image. Access the possible classifications through the supportedIdentifiers property.

if let imageURL = Bundle.main.url(forResource: "ClassificationImage",
                                      withExtension: "jpg") {
    do {
        let request = ClassifyImageRequest()
        let results = try await request.perform(on: imageURL)
        for classification in results {
            print("Classified \(classification.identifier)")
        }
    } catch {
        print("Encountered an error when performing the request: \(error.localizedDescription)")
    }
}

Topics

Creating a request

Performing a request

Understanding the result

Configuring a request

Getting the revision

See Also

Image classification and recognition