Skip to content

Commit 4deb4fc

Browse files
Ivanidzo4kaShahab Moradi
authored and
Shahab Moradi
committed
Update xml documentation for Image estimators (#3376)
* Update xml documentation for Image estimators * Remove doc.xml * update markdown * update to different types * adress comments * address senja comments * ReadOnly.. to TextDataViewType * address comments
1 parent b809394 commit 4deb4fc

File tree

7 files changed

+151
-175
lines changed

7 files changed

+151
-175
lines changed

src/Microsoft.ML.ImageAnalytics/ExtensionsCatalog.cs

+46-41
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,15 @@ namespace Microsoft.ML
1010
{
1111
public static class ImageEstimatorsCatalog
1212
{
13-
/// <include file='doc.xml' path='doc/members/member[@name="ImageGrayscalingEstimator"]/*' />
13+
///<summary>
14+
/// Create a <see cref="ImageGrayscalingEstimator"/>, which converts images in the column specified in <see cref="InputOutputColumnPair.InputColumnName"/>
15+
/// to grayscale images in a new column: <see cref="InputOutputColumnPair.OutputColumnName" />.
16+
///</summary>
1417
/// <param name="catalog">The transform's catalog.</param>
15-
/// <param name="outputColumnName">Name of the column resulting from the transformation of <paramref name="inputColumnName"/>.</param>
16-
/// <param name="inputColumnName">Name of the column to transform. If set to <see langword="null"/>, the value of the <paramref name="outputColumnName"/> will be used as source.</param>
18+
/// <param name="outputColumnName">Name of the column resulting from the transformation of <paramref name="inputColumnName"/>.
19+
/// This column's data type will be the same as that of the input column.</param>
20+
/// <param name="inputColumnName">Name of the column to convert images to grayscale from.
21+
/// This estimator operates only on <see cref="System.Drawing.Bitmap"/>.</param>
1722
/// <example>
1823
/// <format type="text/markdown">
1924
/// <![CDATA[
@@ -23,9 +28,12 @@ public static class ImageEstimatorsCatalog
2328
public static ImageGrayscalingEstimator ConvertToGrayscale(this TransformsCatalog catalog, string outputColumnName, string inputColumnName = null)
2429
=> new ImageGrayscalingEstimator(CatalogUtils.GetEnvironment(catalog), new[] { (outputColumnName, inputColumnName ?? outputColumnName) });
2530

26-
/// <include file='doc.xml' path='doc/members/member[@name="ImageGrayscalingEstimator"]/*' />
31+
///<summary>
32+
/// Create a <see cref="ImageGrayscalingEstimator"/>, which converts images in the column specified in <see cref="InputOutputColumnPair.InputColumnName"/>
33+
/// to grayscale images in a new column: <see cref="InputOutputColumnPair.OutputColumnName" />.
34+
///</summary>
2735
/// <param name="catalog">The transform's catalog.</param>
28-
/// <param name="columns">Specifies the names of the input columns for the transformation, and their respective output column names.</param>
36+
/// <param name="columns">The pairs of input and output columns. This estimator operates only on <see cref="System.Drawing.Bitmap"/>.</param>
2937
/// <example>
3038
/// <format type="text/markdown">
3139
/// <![CDATA[
@@ -41,20 +49,15 @@ internal static ImageGrayscalingEstimator ConvertToGrayscale(this TransformsCata
4149
}
4250

4351
/// <summary>
44-
/// Loads the images from the <see cref="ImageLoadingTransformer.ImageFolder" /> into memory.
52+
/// Create a <see cref="ImageLoadingEstimator"/>, which loads the data from the column specified in <paramref name="inputColumnName"/>
53+
/// as an image to a new column: <paramref name="outputColumnName"/>.
4554
/// </summary>
46-
/// <remarks>
47-
/// The image get loaded in memory as a <see cref="System.Drawing.Bitmap" /> type.
48-
/// Loading is the first step of almost every pipeline that does image processing, and further analysis on images.
49-
/// The images to load need to be in the formats supported by <see cref = "System.Drawing.Bitmap" />.
50-
/// For end-to-end image processing pipelines, and scenarios in your applications, see the
51-
/// <a href="https://github.com/dotnet/machinelearning-samples/tree/master/samples/csharp/getting-started"> examples in the machinelearning-samples github repository.</a>
52-
/// <seealso cref = "ImageEstimatorsCatalog" />
53-
/// </remarks>
5455
/// <param name="catalog">The transform's catalog.</param>
55-
/// <param name="outputColumnName">Name of the column resulting from the transformation of <paramref name="inputColumnName"/>.</param>
56-
/// <param name="imageFolder">The images folder.</param>
57-
/// <param name="inputColumnName">Name of the column to transform. If set to <see langword="null"/>, the value of the <paramref name="outputColumnName"/> will be used as source.</param>
56+
/// <param name="outputColumnName">Name of the column resulting from the transformation of <paramref name="inputColumnName"/>.
57+
/// This column's data type will be <see cref="System.Drawing.Bitmap"/>.</param>
58+
/// <param name="inputColumnName">Name of the column with paths to the images to load.
59+
/// This estimator operates over text data.</param>
60+
/// <param name="imageFolder">Folder where to look for images.</param>
5861
/// <example>
5962
/// <format type="text/markdown">
6063
/// <![CDATA[
@@ -73,10 +76,9 @@ public static ImageLoadingEstimator LoadImages(this TransformsCatalog catalog, s
7376
/// The images to load need to be in the formats supported by <see cref = "System.Drawing.Bitmap" />.
7477
/// For end-to-end image processing pipelines, and scenarios in your applications, see the
7578
/// <a href="https://github.com/dotnet/machinelearning-samples/tree/master/samples/csharp/getting-started"> examples in the machinelearning-samples github repository.</a>
76-
/// <seealso cref = "ImageEstimatorsCatalog" />
7779
/// </remarks>
7880
/// <param name="catalog">The transform's catalog.</param>
79-
/// <param name="imageFolder">The images folder.</param>
81+
/// <param name="imageFolder">Folder where to look for images.</param>
8082
/// <param name="columns">Specifies the names of the input columns for the transformation, and their respective output column names.</param>
8183
/// <example>
8284
/// <format type="text/markdown">
@@ -92,10 +94,15 @@ internal static ImageLoadingEstimator LoadImages(this TransformsCatalog catalog,
9294
return new ImageLoadingEstimator(env, imageFolder, InputOutputColumnPair.ConvertToValueTuples(columns));
9395
}
9496

95-
/// <include file='doc.xml' path='doc/members/member[@name="ImagePixelExtractingEstimator"]/*' />
97+
/// <summary>
98+
/// Create a <see cref="ImagePixelExtractingEstimator"/>, which extracts pixels values from the data specified in column: <paramref name="inputColumnName"/>
99+
/// to a new column: <paramref name="outputColumnName"/>.
100+
/// </summary>
96101
/// <param name="catalog">The transform's catalog.</param>
97-
/// <param name="outputColumnName">Name of the column resulting from the transformation of <paramref name="inputColumnName"/>.</param>
98-
/// <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>
102+
/// <param name="outputColumnName">Name of the column resulting from the transformation of <paramref name="inputColumnName"/>.
103+
/// This column's data type will be a known-sized vector of <see cref="System.Single"/> or <see cref="System.Byte"/> depending on <paramref name="outputAsFloatArray"/>.</param>
104+
/// <param name="inputColumnName">Name of the column with images.
105+
/// This estimator operates over <see cref="System.Drawing.Bitmap"/>.</param>
99106
/// <param name="colorsToExtract">The colors to extract from the image.</param>
100107
/// <param name="orderOfExtraction">The order in which to extract colors from pixel.</param>
101108
/// <param name="interleavePixelColors">Whether to interleave the pixels colors, meaning keep them in the <paramref name="orderOfExtraction"/> order, or leave them in the plannar form:
@@ -120,28 +127,25 @@ public static ImagePixelExtractingEstimator ExtractPixels(this TransformsCatalog
120127
bool outputAsFloatArray = ImagePixelExtractingEstimator.Defaults.Convert)
121128
=> new ImagePixelExtractingEstimator(CatalogUtils.GetEnvironment(catalog), outputColumnName, inputColumnName, colorsToExtract, orderOfExtraction, interleavePixelColors, offsetImage, scaleImage, outputAsFloatArray);
122129

123-
/// <include file='doc.xml' path='doc/members/member[@name="ImagePixelExtractingEstimator"]/*' />
130+
/// <summary>
131+
/// Create a <see cref="ImagePixelExtractingEstimator"/>, which exctracts pixel values from the data specified in column: <see cref="ImagePixelExtractingEstimator.ColumnOptions.InputColumnName"/>
132+
/// to a new column: <see cref="ImagePixelExtractingEstimator.ColumnOptions.Name"/>.
133+
/// </summary>
124134
/// <param name="catalog">The transform's catalog.</param>
125135
/// <param name="columnOptions">The <see cref="ImagePixelExtractingEstimator.ColumnOptions"/> describing how the transform handles each image pixel extraction output input column pair.</param>
126136
[BestFriend]
127137
internal static ImagePixelExtractingEstimator ExtractPixels(this TransformsCatalog catalog, params ImagePixelExtractingEstimator.ColumnOptions[] columnOptions)
128138
=> new ImagePixelExtractingEstimator(CatalogUtils.GetEnvironment(catalog), columnOptions);
129139

130140
/// <summary>
131-
/// Resizes the images to a new width and height.
141+
/// Create a <see cref="ImageResizingEstimator"/>, which resize the image from the column specified in <paramref name="inputColumnName"/>
142+
/// to a new column: <paramref name="outputColumnName"/>.
132143
/// </summary>
133-
/// <remarks>
134-
/// In image processing pipelines, often machine learning practitioner make use of<a href= "https://blogs.msdn.microsoft.com/mlserver/2017/04/12/image-featurization-with-a-pre-trained-deep-neural-network-model/">
135-
/// pre-trained DNN featurizers</a> to extract features for usage in the machine learning algorithms.
136-
/// Those pre-trained models have a defined width and height for their input images, so often, after getting loaded, the images will need to get resized before
137-
/// further processing.
138-
/// The new width and height can be specified in the <paramref name="imageWidth"/> and <paramref name="imageHeight"/>
139-
/// <seealso cref = "ImageEstimatorsCatalog" />
140-
/// <seealso cref= "ImageLoadingEstimator" />
141-
/// </remarks >
142144
/// <param name="catalog">The transform's catalog.</param>
143-
/// <param name="outputColumnName">Name of the column resulting from the transformation of <paramref name="inputColumnName"/>.</param>
144-
/// <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>
145+
/// <param name="outputColumnName">Name of the column resulting from the transformation of <paramref name="inputColumnName"/>.
146+
/// This column's data type will be the same as that of the input column.</param>
147+
/// <param name="inputColumnName">Name of the column with images.
148+
/// This estimator operates over <see cref="System.Drawing.Bitmap"/>.</param>
145149
/// <param name="imageWidth">The transformed image width.</param>
146150
/// <param name="imageHeight">The transformed image height.</param>
147151
/// <param name="resizing"> The type of image resizing as specified in <see cref="ImageResizingEstimator.ResizingKind"/>.</param>
@@ -171,8 +175,6 @@ public static ImageResizingEstimator ResizeImages(this TransformsCatalog catalog
171175
/// further processing.
172176
/// The new width and height, as well as other properties of resizing, like type of scaling (uniform, or non-uniform), and whether to pad the image,
173177
/// or just crop it can be specified separately for each column loaded, through the <see cref="ImageResizingEstimator.ColumnOptions"/>.
174-
/// <seealso cref = "ImageEstimatorsCatalog" />
175-
/// <seealso cref= "ImageLoadingEstimator" />
176178
/// </remarks >
177179
/// <param name="catalog">The transform's catalog.</param>
178180
/// <param name="columnOptions">The <see cref="ImageResizingEstimator.ColumnOptions"/> describing how the transform handles each image resize column.</param>
@@ -196,13 +198,16 @@ internal static VectorToImageConvertingEstimator ConvertToImage(this TransformsC
196198
=> new VectorToImageConvertingEstimator(CatalogUtils.GetEnvironment(catalog), columnOptions);
197199

198200
/// <summary>
199-
/// Converts vectors of pixels into <see cref="ImageDataViewType"/> representation.
201+
/// Create a <see cref="VectorToImageConvertingEstimator"/>, which creates image from the data from the column specified in <paramref name="inputColumnName"/>
202+
/// to a new column: <paramref name="outputColumnName"/>.
200203
/// </summary>
201-
/// <param name="catalog">The transforms' catalog.</param>
204+
/// <param name="catalog">The transform's catalog.</param>
202205
/// <param name="imageHeight">The height of the output images.</param>
203206
/// <param name="imageWidth">The width of the output images.</param>
204-
/// <param name="outputColumnName"> Name of the column resulting from the transformation of <paramref name="inputColumnName"/>.</param>
205-
/// <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>
207+
/// <param name="outputColumnName">Name of the column resulting from the transformation of <paramref name="inputColumnName"/>.
208+
/// This column's data type will be <see cref="System.Drawing.Bitmap"/>.</param>
209+
/// <param name="inputColumnName">Name of the column with data to be converted to image.
210+
/// This estimator operates over known-sized vector of <see cref="System.Single"/>, <see cref="System.Double"/> and <see cref="System.Byte"/>.</param>
206211
/// <param name="colorsPresent">Specifies which <see cref="ImagePixelExtractingEstimator.ColorBits"/> are in present the input pixel vectors. The order of colors is specified in <paramref name="orderOfColors"/>.</param>
207212
/// <param name="orderOfColors">The order in which colors are presented in the input vector.</param>
208213
/// <param name="interleavedColors">Whether the pixels are interleaved, meaning whether they are in <paramref name="orderOfColors"/> order, or separated in the planar form:

src/Microsoft.ML.ImageAnalytics/ImageGrayscale.cs

+20-18
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,8 @@ namespace Microsoft.ML.Transforms.Image
3232
// REVIEW: Rewrite as LambdaTransform to simplify.
3333
// REVIEW: Should it be separate transform or part of ImageResizerTransform?
3434
/// <summary>
35-
/// <see cref="ITransformer"/> produced by fitting the <see cref="IDataView"/> to an <see cref="ImageGrayscalingEstimator" />.
35+
/// <see cref="ITransformer"/> resulting from fitting an <see cref="ImageGrayscalingTransformer"/>.
3636
/// </summary>
37-
/// <remarks>
38-
/// Calling <see cref="ITransformer.Transform(IDataView)"/> converts the image to grayscale.
39-
/// The images might be converted to grayscale to reduce the complexity of the model.
40-
/// The grayed out images contain less information to process than the colored images.
41-
/// Another use case for converting to grayscale is to generate new images out of the existing ones, so you can have a larger dataset,
42-
/// a technique known as <a href = "http://www.stat.harvard.edu/Faculty_Content/meng/JCGS01.pdf"> data augmentation</a>.
43-
/// For end-to-end image processing pipelines, and scenarios in your applications, see the
44-
/// <a href="https://github.com/dotnet/machinelearning-samples/tree/master/samples/csharp/getting-started"> examples in the machinelearning-samples github repository.</a>
45-
/// <seealso cref = "ImageEstimatorsCatalog" />
46-
/// </remarks>
4737
public sealed class ImageGrayscalingTransformer : OneToOneTransformerBase
4838
{
4939
internal sealed class Column : OneToOneColumn
@@ -226,21 +216,33 @@ protected override Delegate MakeGetter(DataViewRow input, int iinfo, Func<int, b
226216
}
227217

228218
/// <summary>
229-
/// <see cref="IEstimator{TTransformer}"/> that converts the image to grayscale.
219+
/// <see cref="IEstimator{TTransformer}"/> for the <see cref="ImageGrayscalingTransformer"/>.
230220
/// </summary>
231221
/// <remarks>
232-
/// Calling <see cref="IEstimator{TTransformer}.Fit(IDataView)"/> in this estimator, produces an <see cref="ImageGrayscalingEstimator"/>.
222+
/// <format type="text/markdown"><![CDATA[
223+
/// ### Estimator Characteristics
224+
/// | | |
225+
/// | -- | -- |
226+
/// | Does this estimator need to look at the data to train its parameters? | No |
227+
/// | Input column data type | <xref:System.Drawing.Bitmap> |
228+
/// | Output column data type | <xref:System.Drawing.Bitmap> |
229+
/// | Required NuGet in addition to Microsoft.ML | Microsoft.ML.ImageAnalytics |
230+
///
231+
/// The resulting <xref:Microsoft.ML.Transforms.Image.ImageGrayscalingTransformer> creates a new column, named as specified in the output column name parameters, and
232+
/// converts the image from the input column into a grayscale image.
233233
/// The images might be converted to grayscale to reduce the complexity of the model.
234234
/// The grayed out images contain less information to process than the colored images.
235235
/// Another use case for converting to grayscale is to generate new images out of the existing ones, so you can have a larger dataset,
236-
/// a technique known as <a href = "http://www.stat.harvard.edu/Faculty_Content/meng/JCGS01.pdf"> data augmentation</a>.
236+
/// a technique known as [data augmentation](http://www.stat.harvard.edu/Faculty_Content/meng/JCGS01.pdf).
237237
/// For end-to-end image processing pipelines, and scenarios in your applications, see the
238-
/// <a href="https://github.com/dotnet/machinelearning-samples/tree/master/samples/csharp/getting-started"> examples in the machinelearning-samples github repository.</a>
239-
/// <seealso cref = "ImageEstimatorsCatalog" />
240-
/// </remarks >
238+
/// [examples](https://github.com/dotnet/machinelearning-samples/tree/master/samples/csharp/getting-started) in the machinelearning-samples github repository.
239+
/// See the See Also section for links to more examples of the usage.
240+
/// ]]>
241+
/// </format>
242+
/// </remarks>
243+
/// <seealso cref="ImageEstimatorsCatalog.ConvertToGrayscale(TransformsCatalog, string, string)" />
241244
public sealed class ImageGrayscalingEstimator : TrivialEstimator<ImageGrayscalingTransformer>
242245
{
243-
244246
/// <summary>
245247
/// Converts the images to grayscale.
246248
/// </summary>

0 commit comments

Comments
 (0)