<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 18.0.0 -",
    "visionOS: 2.0.0 -",
    "watchOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Vision",
  "identifier" : "/documentation/Vision/CoreMLRequest",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Vision"
    ],
    "preciseIdentifier" : "s:6Vision13CoreMLRequestV"
  },
  "title" : "CoreMLRequest"
}
-->

# CoreMLRequest

An image-analysis request that uses a Core ML model to process images.

```
struct CoreMLRequest
```

## Overview

The results array of a <doc://com.apple.documentation/documentation/CoreML>-based image-analysis request contain a different observation type, depending on the kind of `MLModel` object you use:

- If the model predicts a single feature and the model’s <doc://com.apple.documentation/documentation/CoreML/MLModelDescription> object has a non-`nil` value for <doc://com.apple.documentation/documentation/CoreML/MLModelDescription/predictedFeatureName>, then Vision treats the model as a classifier. The results are [`ClassificationObservation`](/documentation/Vision/ClassificationObservation) objects.
- If the model’s outputs include at least one output with a feature type of <doc://com.apple.documentation/documentation/CoreML/MLFeatureType/image>, Vision treats that model as an image-to-image model. The results are [`PixelBufferObservation`](/documentation/Vision/PixelBufferObservation) objects.
- Otherwise, Vision treats the model as a general predictor model. The results are [`CoreMLFeatureValueObservation`](/documentation/Vision/CoreMLFeatureValueObservation) objects.

> Note:
> Vision forwards all confidence values from Core ML models as-is and doesn’t normalize them to [0, 1].

## Topics

### Creating a request

[`init(model: CoreMLModelContainer, CoreMLRequest.Revision?)`](/documentation/Vision/CoreMLRequest/init(model:_:))

Creates a Core ML request.

### Performing a request

[`func perform(on: URL, orientation: CGImagePropertyOrientation?) async throws -> Self.Result`](/documentation/Vision/ImageProcessingRequest/perform(on:orientation:)-80bya)

Performs the request on an image URL and produces observations.

[`func perform(on: Data, orientation: CGImagePropertyOrientation?) async throws -> Self.Result`](/documentation/Vision/ImageProcessingRequest/perform(on:orientation:)-3f3f1)

Performs the request on image data and produces observations.

[`func perform(on: CGImage, orientation: CGImagePropertyOrientation?) async throws -> Self.Result`](/documentation/Vision/ImageProcessingRequest/perform(on:orientation:)-qxxx)

Performs the request on a Core Graphics image and produces observations.

[`func perform(on: CVPixelBuffer, orientation: CGImagePropertyOrientation?) async throws -> Self.Result`](/documentation/Vision/ImageProcessingRequest/perform(on:orientation:)-xspx)

Performs the request on a pixel buffer and produces observations.

[`func perform(on: CMSampleBuffer, orientation: CGImagePropertyOrientation?) async throws -> Self.Result`](/documentation/Vision/ImageProcessingRequest/perform(on:orientation:)-3hddl)

Performs the request on a Core Media buffer and produces observations.

[`func perform(on: CIImage, orientation: CGImagePropertyOrientation?) async throws -> Self.Result`](/documentation/Vision/ImageProcessingRequest/perform(on:orientation:)-85ex1)

Performs the request on a Core Image image and produces observations.

### Understanding the result

[`struct PixelBufferObservation`](/documentation/Vision/PixelBufferObservation)

An object that represents an image that an image-analysis request produces.

[`struct ClassificationObservation`](/documentation/Vision/ClassificationObservation)

An object that represents classification information that an image-analysis request produces.

[`struct CoreMLFeatureValueObservation`](/documentation/Vision/CoreMLFeatureValueObservation)

An object that represents a collection of key-value information that a Core ML image-analysis request produces.

### Configuring a request

[`var supportedIdentifiers: [String]?`](/documentation/Vision/CoreMLRequest/supportedIdentifiers)

The classification identifiers supported by the request.

[`let modelContainer: CoreMLModelContainer`](/documentation/Vision/CoreMLRequest/modelContainer)

The model to base the image analysis request on.

[`struct CoreMLModelContainer`](/documentation/Vision/CoreMLModelContainer)

A model container to use with an image-analysis request.

[`enum ComputeStage`](/documentation/Vision/ComputeStage)

Types that represent the compute stage.

[`var cropAndScaleAction: ImageCropAndScaleAction`](/documentation/Vision/CoreMLRequest/cropAndScaleAction)

An optional setting that tells the Vision algorithm how to scale an input image.

[`enum ImageCropAndScaleAction`](/documentation/Vision/ImageCropAndScaleAction)

A scale to apply to an input image before performing a request.

### Getting the revision

[`let revision: CoreMLRequest.Revision`](/documentation/Vision/CoreMLRequest/revision-swift.property)

The algorithm or implementation the request uses.

[`static let supportedRevisions: [CoreMLRequest.Revision]`](/documentation/Vision/CoreMLRequest/supportedRevisions)

The collection of revisions the request supports.

[`enum Revision`](/documentation/Vision/CoreMLRequest/Revision-swift.enum)

A type that describes the algorithm or implementation that the request performs.

## Relationships

### Conforms To

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`ImageProcessingRequest`](/documentation/Vision/ImageProcessingRequest)

[`VisionRequest`](/documentation/Vision/VisionRequest)

[`Sendable`](/documentation/Swift/Sendable)

[`Equatable`](/documentation/Swift/Equatable)

[`Hashable`](/documentation/Swift/Hashable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)