Skip to content

VectorToImageTransform conversion to estimator/transformer #2580

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 21, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Microsoft.ML.ImageAnalytics/EntryPoints/ImageAnalytics.cs
Original file line number Diff line number Diff line change
@@ -63,12 +63,12 @@ public static CommonOutputs.TransformOutput ImageGrayscale(IHostEnvironment env,
};
}

[TlcModule.EntryPoint(Name = "Transforms.VectorToImage", Desc = VectorToImageTransform.Summary,
UserName = VectorToImageTransform.UserName, ShortName = VectorToImageTransform.LoaderSignature)]
public static CommonOutputs.TransformOutput VectorToImage(IHostEnvironment env, VectorToImageTransform.Arguments input)
[TlcModule.EntryPoint(Name = "Transforms.VectorToImage", Desc = VectorToImageConvertingTransformer.Summary,
UserName = VectorToImageConvertingTransformer.UserName, ShortName = VectorToImageConvertingTransformer.LoaderSignature)]
public static CommonOutputs.TransformOutput VectorToImage(IHostEnvironment env, VectorToImageConvertingTransformer.Options input)
{
var h = EntryPointUtils.CheckArgsAndCreateHost(env, "VectorToImageTransform", input);
var xf = new VectorToImageTransform(h, input, input.Data);
var xf = VectorToImageConvertingTransformer.Create(h, input, input.Data);
return new CommonOutputs.TransformOutput()
{
Model = new TransformModelImpl(h, xf, input.Data),
30 changes: 29 additions & 1 deletion src/Microsoft.ML.ImageAnalytics/ExtensionsCatalog.cs
Original file line number Diff line number Diff line change
@@ -72,7 +72,7 @@ public static ImagePixelExtractingEstimator ExtractPixels(this TransformsCatalog

/// <include file='doc.xml' path='doc/members/member[@name="ImagePixelExtractingEstimator"]/*' />
/// <param name="catalog">The transform's catalog.</param>
/// <param name="columns">The name of the columns containing the image paths, and per-column configurations.</param>
/// <param name="columns">The name of the columns containing the images, and per-column configurations.</param>
public static ImagePixelExtractingEstimator ExtractPixels(this TransformsCatalog catalog, params ImagePixelExtractingEstimator.ColumnInfo[] columns)
=> new ImagePixelExtractingEstimator(CatalogUtils.GetEnvironment(catalog), columns);

@@ -133,5 +133,33 @@ public static ImageResizingEstimator ResizeImages(this TransformsCatalog catalog
/// </example>
public static ImageResizingEstimator ResizeImages(this TransformsCatalog catalog, params ImageResizingEstimator.ColumnInfo[] columns)
=> new ImageResizingEstimator(CatalogUtils.GetEnvironment(catalog), columns);

/// <summary>
/// Converts vectors of pixels into <see cref="ImageType"/> representation.
/// </summary>
/// <param name="catalog">The transform's catalog.</param>
/// <param name="columns">The name of the columns containing the pixels, and per-column configurations.</param>
public static VectorToImageConvertingEstimator ConvertToImage(this TransformsCatalog catalog, params VectorToImageConvertingEstimator.ColumnInfo[] columns)
=> new VectorToImageConvertingEstimator(CatalogUtils.GetEnvironment(catalog), columns);

/// <summary>
/// Converts vectors of pixels into <see cref="ImageType"/> representation.
/// </summary>
/// <param name="catalog">The transforms' catalog.</param>
/// <param name="height">The height of the output images.</param>
/// <param name="width">The width of the output images.</param>
/// <param name="outputColumnName"> Name of the column resulting from the transformation of <paramref name="inputColumnName"/>.</param>
/// <param name="inputColumnName"> Name of column to transform. If set to <see langword="null"/>, the value of the <paramref name="outputColumnName"/> will be used as source.</param>
/// <param name="colors"> Specifies which <see cref="ImagePixelExtractingEstimator.ColorBits"/> are in the input pixel vectors. The order of colors is: Alpha, Red, Green Blue.</param>
/// <param name="interleave">Whether the pixels are interleaved, meaning whether they are in `ARGB ARGB` order, or separated in the planar form, where the colors are specified one by one
/// alpha, red, green, blue for all the pixels of the image. </param>
/// <param name="scale">The values are scaled by this value before being converted to pixels.</param>
/// <param name="offset">The offset is subtracted (before scaling) before converting the values to pixels.</param>
public static VectorToImageConvertingEstimator ConvertToImage(this TransformsCatalog catalog, int height, int width, string outputColumnName, string inputColumnName = null,
ImagePixelExtractingEstimator.ColorBits colors = VectorToImageConvertingTransformer.Defaults.Colors,
bool interleave = VectorToImageConvertingTransformer.Defaults.InterleaveArgb,
float scale = VectorToImageConvertingTransformer.Defaults.Scale,
float offset = VectorToImageConvertingTransformer.Defaults.Offset)
=> new VectorToImageConvertingEstimator(CatalogUtils.GetEnvironment(catalog), height, width, outputColumnName, inputColumnName, colors, interleave, scale, offset);
}
}
Loading