Structure

MLImageClassifier.ImageAugmentationOptions

The variations that the training process can use to generate more training data from the training data you provide.

Declaration

struct MLImageClassifier.ImageAugmentationOptions

Overview

Augmentation generates new images from the training data you supply to increase the amount of training data available to the model. The number of augmented images per original depends on the specific option you choose. For example, if you use rotation, you get four new images with a random rotation angle for each original. If you use flip, you get three new images: one that is flipped horizontally, one flipped vertically, and one flipped along both axes.

Augmentation options combine multiplicatively to produce potentially very large data sets. If you use both of the options described above, you get 4 × 3 = 12 images: each of four rotated images is flipped three ways. Adding more options further multiplies the data set size by the number of variants for that option.

To keep the training time manageable, the image classifier restricts the total number of augmentation combinations to 100. The classifier applies the augmentation options you specify until applying more would cause the total count to exceed that threshold. The classifier then restricts the number of augmented variants for any further options. For example, if the first three options you use have four variants each, resulting in 4 × 4 × 4 = 64 combinations, any further options are limited to one variant to avoid exceeding 100 total combinations.

To optimize performance in the face of this restriction, when you use more than one option, the classifier applies them in the order of greatest to least training effectiveness. Specifially, it uses this ordering: crop, rotation, blur, exposure, noise, flip.

See Improving Your Model’s Accuracy for a discussion about when to use augmentation.

Topics

Selecting Augmentation Options

static let crop: MLImageClassifier.ImageAugmentationOptions

An option for augmenting training data by creating cropped versions of each image.

static let rotation: MLImageClassifier.ImageAugmentationOptions

An option for augmenting training data by rotating each image.

static let blur: MLImageClassifier.ImageAugmentationOptions

An option for augmenting training data by blurring each image.

static let exposure: MLImageClassifier.ImageAugmentationOptions

An option for augmenting training data by lightening or darkening each image.

static let noise: MLImageClassifier.ImageAugmentationOptions

An option for augmenting training data by adding random amounts of noise to each image.

static let flip: MLImageClassifier.ImageAugmentationOptions

An option for augmenting training data by flipping each image along the horizontal and vertical axes.

Creating Augmentation Options

init()

Creates an empty option set.

init(arrayLiteral: MLImageClassifier.ImageAugmentationOptions...)

Creates a set containing the elements of the given array literal.

init<S>(S)

Creates a new set from a finite sequence of items.

init(rawValue: Int)

Creates an augmentation set with the given raw value.

let rawValue: Int

The underlying integer of the augmentation option.

Testing for Membership in a Set

var isEmpty: Bool

A Boolean value that indicates whether the set has no elements.

func contains(MLImageClassifier.ImageAugmentationOptions) -> Bool

Returns a Boolean value that indicates whether a given element is a member of the option set.

Combining Sets

func union(MLImageClassifier.ImageAugmentationOptions) -> MLImageClassifier.ImageAugmentationOptions

Returns a new option set of the elements contained in this set, in the given set, or in both.

func formUnion(MLImageClassifier.ImageAugmentationOptions)

Inserts the elements of another set into this option set.

func intersection(MLImageClassifier.ImageAugmentationOptions) -> MLImageClassifier.ImageAugmentationOptions

Returns a new option set with only the elements contained in both this set and the given set.

func formIntersection(MLImageClassifier.ImageAugmentationOptions)

Removes all elements of this option set that are not also present in the given set.

func symmetricDifference(MLImageClassifier.ImageAugmentationOptions) -> MLImageClassifier.ImageAugmentationOptions

Returns a new option set with the elements contained in this set or in the given set, but not in both.

func formSymmetricDifference(MLImageClassifier.ImageAugmentationOptions)

Replaces this set with a new set containing all elements contained in either this set or the given set, but not in both.

func subtract(MLImageClassifier.ImageAugmentationOptions)

Removes the elements of the given set from this set.

func subtracting(MLImageClassifier.ImageAugmentationOptions) -> MLImageClassifier.ImageAugmentationOptions

Returns a new set containing the elements of this set that do not occur in the given set.

Comparing Sets

func isStrictSubset(of: MLImageClassifier.ImageAugmentationOptions) -> Bool

Returns a Boolean value that indicates whether this set is a strict subset of the given set.

func isSubset(of: MLImageClassifier.ImageAugmentationOptions) -> Bool

Returns a Boolean value that indicates whether the set is a subset of another set.

func isStrictSuperset(of: MLImageClassifier.ImageAugmentationOptions) -> Bool

Returns a Boolean value that indicates whether this set is a strict superset of the given set.

func isSuperset(of: MLImageClassifier.ImageAugmentationOptions) -> Bool

Returns a Boolean value that indicates whether the set is a superset of the given set.

func isDisjoint(with: MLImageClassifier.ImageAugmentationOptions) -> Bool

Returns a Boolean value that indicates whether the set has no members in common with the given set.

Testing for Equality

Relationships

Conforms To

See Also

Adding Augmentation

var augmentationOptions: MLImageClassifier.ImageAugmentationOptions

The variations that the training process applies to your training data to generate more training data.