OneOf<T, TData>

Models & Types · AiDotNet.Augmentation

Randomly selects and applies exactly one augmentation from a set.

Implements: ISpatialAugmentation<T, TData>

For Beginners

Think of this like flipping a coin to decide which transformation to apply. You might flip the image OR rotate it, but not both at the same time.

How It Works

OneOf randomly chooses one augmentation from the provided set and applies it. This is useful when you want variety but don’t want to apply multiple similar augmentations that might compound their effects too strongly.

Example usage:

Constructors

Constructor Summary
OneOf(IAugmentation<T, TData>[] augmentations) Creates a new OneOf with uniform weights.
OneOf(IEnumerable<IAugmentation<T, TData>> augmentations, double probability) Creates a new OneOf with specified weights.
OneOf(IEnumerable<ValueTuple<IAugmentation<T, TData>, double>> augmentationsWithWeights, double probability) Creates a new OneOf with specified weights.

Properties

Property Summary
IReadOnlyList<IAugmentation<T, TData>> Augmentations { get; } Gets the list of augmentations to choose from.
bool IsEnabled { get; set; }
bool IsTrainingOnly { get; set; }
bool SupportsBoundingBoxes { get; }
bool SupportsKeypoints { get; }
bool SupportsMasks { get; }
double Probability { get; }
string Name { get; }

Methods

Method Summary
AugmentedSample<T, TData> ApplyWithTargets(AugmentedSample<T, TData> sample, AugmentationContext<T> context)
IDictionary<string, object> GetParameters()
TData Apply(TData data, AugmentationContext<T> context)