Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
15 changes: 15 additions & 0 deletions src/Microsoft.ML.Data/StaticPipe/PipelineColumn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,19 @@ protected VarKey(Reconciler reconciler, params PipelineColumn[] dependencies)

public override string ToString() => $"{nameof(VarKey<T>)}<{typeof(T).Name}>";
}

/// <summary>
/// For representing a custom <see cref="ColumnType"/>.
/// </summary>
/// <typeparam name="T"></typeparam>
Copy link
Contributor

@Zruty0 Zruty0 Sep 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[](start = 8, length = 32)

remove empty #Resolved

public abstract class Custom<T>: PipelineColumn
{
protected Custom(Reconciler reconciler, params PipelineColumn[] dependencies)
: base(reconciler, dependencies)
{
}

public override string ToString() => $"{nameof(Custom<T>)}<{typeof(T).Name}>";
}

}
10 changes: 5 additions & 5 deletions src/Microsoft.ML.ImageAnalytics/ImageGrayscaleTransform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,12 @@ private interface IColInput
PipelineColumn Input { get; }
}

internal sealed class OutPipelineColumn<T> : Scalar<T>, IColInput
internal sealed class OutPipelineColumn<T> : Custom<T>, IColInput
{
public PipelineColumn Input { get; }

public OutPipelineColumn(Scalar<T> input)
: base(Reconciler.Inst, input)
public OutPipelineColumn(Custom<T> input)
: base(Reconciler.Inst, input)
{
Contracts.AssertValue(input);
Contracts.Assert(typeof(T) == typeof(Bitmap) || typeof(T) == typeof(UnknownSizeBitmap));
Expand All @@ -257,8 +257,8 @@ public OutPipelineColumn(Scalar<T> input)
/// Reconciler to an <see cref="ImageGrayscaleEstimator"/> for the <see cref="PipelineColumn"/>.
/// </summary>
/// <remarks>Because we want to use the same reconciler for </remarks>
/// <see cref="ImageStaticPipe.AsGrayscale(Scalar{Bitmap})"/>
/// <see cref="ImageStaticPipe.AsGrayscale(Scalar{UnknownSizeBitmap})"/>
/// <see cref="ImageStaticPipe.AsGrayscale(Custom{Bitmap})"/>
/// <see cref="ImageStaticPipe.AsGrayscale(Custom{UnknownSizeBitmap})"/>
private sealed class Reconciler : EstimatorReconciler
{
public static Reconciler Inst = new Reconciler();
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.ML.ImageAnalytics/ImageLoaderTransform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ public override SchemaShape GetOutputSchema(SchemaShape inputSchema)
return new SchemaShape(result.Values);
}

internal sealed class OutPipelineColumn : Scalar<UnknownSizeBitmap>
internal sealed class OutPipelineColumn : Custom<UnknownSizeBitmap>
{
private readonly Scalar<string> _input;

Expand Down
10 changes: 5 additions & 5 deletions src/Microsoft.ML.ImageAnalytics/ImagePixelExtractorTransform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -669,18 +669,18 @@ public override SchemaShape GetOutputSchema(SchemaShape inputSchema)

private interface IColInput
{
Scalar<Bitmap> Input { get; }
Custom<Bitmap> Input { get; }

ImagePixelExtractorTransform.ColumnInfo MakeColumnInfo(string input, string output);
}

internal sealed class OutPipelineColumn<T> : Vector<T>, IColInput
{
public Scalar<Bitmap> Input { get; }
public Custom<Bitmap> Input { get; }
private static readonly ImagePixelExtractorTransform.Arguments _defaultArgs = new ImagePixelExtractorTransform.Arguments();
private readonly ImagePixelExtractorTransform.Column _colParam;

public OutPipelineColumn(Scalar<Bitmap> input, ImagePixelExtractorTransform.Column col)
public OutPipelineColumn(Custom<Bitmap> input, ImagePixelExtractorTransform.Column col)
: base(Reconciler.Inst, input)
{
Contracts.AssertValue(input);
Expand All @@ -705,8 +705,8 @@ public ImagePixelExtractorTransform.ColumnInfo MakeColumnInfo(string input, stri
/// Reconciler to an <see cref="ImagePixelExtractorEstimator"/> for the <see cref="PipelineColumn"/>.
/// </summary>
/// <remarks>Because we want to use the same reconciler for </remarks>
/// <see cref="ImageStaticPipe.ExtractPixels(Scalar{Bitmap}, bool, bool, bool, bool, bool, float, float)"/>
/// <see cref="ImageStaticPipe.ExtractPixelsAsBytes(Scalar{Bitmap}, bool, bool, bool, bool, bool)"/>
/// <see cref="ImageStaticPipe.ExtractPixels(Custom{Bitmap}, bool, bool, bool, bool, bool, float, float)"/>
/// <see cref="ImageStaticPipe.ExtractPixelsAsBytes(Custom{Bitmap}, bool, bool, bool, bool, bool)"/>
private sealed class Reconciler : EstimatorReconciler
{
/// <summary>
Expand Down
6 changes: 3 additions & 3 deletions src/Microsoft.ML.ImageAnalytics/ImageResizerTransform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ public override SchemaShape GetOutputSchema(SchemaShape inputSchema)
return new SchemaShape(result.Values);
}

internal sealed class OutPipelineColumn : Scalar<Bitmap>
internal sealed class OutPipelineColumn : Custom<Bitmap>
{
private readonly PipelineColumn _input;
private readonly int _width;
Expand All @@ -487,8 +487,8 @@ private ImageResizerTransform.ColumnInfo MakeColumnInfo(string input, string out
/// <summary>
/// Reconciler to an <see cref="ImageResizerTransform"/> for the <see cref="PipelineColumn"/>.
/// </summary>
/// <seealso cref="ImageStaticPipe.Resize(Scalar{Bitmap}, int, int, ImageResizerTransform.ResizingKind, ImageResizerTransform.Anchor)"/>
/// <seealso cref="ImageStaticPipe.Resize(Scalar{UnknownSizeBitmap}, int, int, ImageResizerTransform.ResizingKind, ImageResizerTransform.Anchor)"/>
/// <seealso cref="ImageStaticPipe.Resize(Custom{Bitmap}, int, int, ImageResizerTransform.ResizingKind, ImageResizerTransform.Anchor)"/>
/// <seealso cref="ImageStaticPipe.Resize(Custom{UnknownSizeBitmap}, int, int, ImageResizerTransform.ResizingKind, ImageResizerTransform.Anchor)"/>
private sealed class Reconciler : EstimatorReconciler
{
public static Reconciler Inst = new Reconciler();
Expand Down
14 changes: 7 additions & 7 deletions src/Microsoft.ML.ImageAnalytics/ImageStaticPipe.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static class ImageStaticPipe
/// safe for users to simply always make their input paths absolute.</param>
/// <returns>The loaded images</returns>
/// <seealso cref="ImageLoaderEstimator"/>
public static Scalar<UnknownSizeBitmap> LoadAsImage(this Scalar<string> path, string relativeTo = null)
public static Custom<UnknownSizeBitmap> LoadAsImage(this Scalar<string> path, string relativeTo = null)
{
Contracts.CheckValue(path, nameof(path));
Contracts.CheckValueOrNull(relativeTo);
Expand All @@ -42,7 +42,7 @@ public static Scalar<UnknownSizeBitmap> LoadAsImage(this Scalar<string> path, st
/// <param name="input">The image to convert</param>
/// <returns>The grayscale images</returns>
/// <seealso cref="ImageGrayscaleEstimator"/>
public static Scalar<UnknownSizeBitmap> AsGrayscale(this Scalar<UnknownSizeBitmap> input)
public static Custom<UnknownSizeBitmap> AsGrayscale(this Custom<UnknownSizeBitmap> input)
{
Contracts.CheckValue(input, nameof(input));
return new ImageGrayscaleEstimator.OutPipelineColumn<UnknownSizeBitmap>(input);
Expand All @@ -54,7 +54,7 @@ public static Scalar<UnknownSizeBitmap> AsGrayscale(this Scalar<UnknownSizeBitma
/// <param name="input">The image to convert</param>
/// <returns>The grayscale images</returns>
/// <seealso cref="ImageGrayscaleEstimator"/>
public static Scalar<Bitmap> AsGrayscale(this Scalar<Bitmap> input)
public static Custom<Bitmap> AsGrayscale(this Custom<Bitmap> input)
{
Contracts.CheckValue(input, nameof(input));
return new ImageGrayscaleEstimator.OutPipelineColumn<Bitmap>(input);
Expand All @@ -70,7 +70,7 @@ public static Scalar<Bitmap> AsGrayscale(this Scalar<Bitmap> input)
/// <param name="cropAnchor">If cropping is necessary, at what position will the image be fixed?</param>
/// <returns>The now uniformly sized images</returns>
/// <seealso cref="ImageResizerEstimator"/>
public static Scalar<Bitmap> Resize(this Scalar<UnknownSizeBitmap> input, int width, int height,
public static Custom<Bitmap> Resize(this Custom<UnknownSizeBitmap> input, int width, int height,
ImageResizerTransform.ResizingKind resizing = ImageResizerTransform.ResizingKind.IsoCrop,
ImageResizerTransform.Anchor cropAnchor = ImageResizerTransform.Anchor.Center)
{
Expand All @@ -93,7 +93,7 @@ public static Scalar<Bitmap> Resize(this Scalar<UnknownSizeBitmap> input, int wi
/// <param name="cropAnchor">If cropping is necessary, at what </param>
/// <returns>The resized images</returns>
/// <seealso cref="ImageResizerEstimator"/>
public static Scalar<Bitmap> Resize(this Scalar<Bitmap> input, int width, int height,
public static Custom<Bitmap> Resize(this Custom<Bitmap> input, int width, int height,
ImageResizerTransform.ResizingKind resizing = ImageResizerTransform.ResizingKind.IsoCrop,
ImageResizerTransform.Anchor cropAnchor = ImageResizerTransform.Anchor.Center)
{
Expand Down Expand Up @@ -121,7 +121,7 @@ public static Scalar<Bitmap> Resize(this Scalar<Bitmap> input, int width, int he
/// <param name="offset">Add this amount to the pixel values, before scaling</param>
/// <returns>The vectorized image</returns>
/// <seealso cref="ImagePixelExtractorEstimator"/>
public static Vector<float> ExtractPixels(this Scalar<Bitmap> input, bool useAlpha = false, bool useRed = true,
public static Vector<float> ExtractPixels(this Custom<Bitmap> input, bool useAlpha = false, bool useRed = true,
bool useGreen = true, bool useBlue = true, bool interleaveArgb = false, float scale = 1.0f, float offset = 0.0f)
{
var colParams = new ImagePixelExtractorTransform.Column
Expand Down Expand Up @@ -151,7 +151,7 @@ public static Vector<float> ExtractPixels(this Scalar<Bitmap> input, bool useAlp
/// <param name="interleaveArgb">Whether the pixel values should be interleaved, as opposed to being separated by channel</param>
/// <returns>The vectorized image</returns>
/// <seealso cref="ImagePixelExtractorEstimator"/>
public static Vector<byte> ExtractPixelsAsBytes(this Scalar<Bitmap> input, bool useAlpha = false, bool useRed = true,
public static Vector<byte> ExtractPixelsAsBytes(this Custom<Bitmap> input, bool useAlpha = false, bool useRed = true,
bool useGreen = true, bool useBlue = true, bool interleaveArgb = false)
{
var colParams = new ImagePixelExtractorTransform.Column
Expand Down