Skip to content
Merged
Show file tree
Hide file tree
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
10 changes: 10 additions & 0 deletions src/Microsoft.ML.ImageAnalytics/EntryPoints/ImageAnalytics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ namespace Microsoft.ML.Runtime.ImageAnalytics.EntryPoints
{
public static class ImageAnalytics
{
// This method is needed for the Pipeline API, since ModuleCatalog does not load entry points that are located
// in assemblies that aren't directly used in the code. Users who want to use ImageAnalytics components will have to call
// ImageAnalytics.Initialize() before creating the pipeline.
/// <summary>
/// Initialize the Image Analytics environment. Call this method before adding Image components to a learning pipeline.
/// </summary>
public static void Initialize()
{
}

[TlcModule.EntryPoint(Name = "Transforms.ImageLoader", Desc = ImageLoaderTransform.Summary,
UserName = ImageLoaderTransform.UserName, ShortName = ImageLoaderTransform.LoaderSignature)]
public static CommonOutputs.TransformOutput ImageLoader(IHostEnvironment env, ImageLoaderTransform.Arguments input)
Expand Down
4 changes: 2 additions & 2 deletions src/Microsoft.ML.ImageAnalytics/ImageResizerTransform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
using Microsoft.ML.Runtime.Internal.Utilities;
using Microsoft.ML.Runtime.Model;

[assembly: LoadableClass(ImageResizerTransform.Summary, typeof(ImageResizerTransform), typeof(ImageResizerTransform.Arguments),
[assembly: LoadableClass(ImageResizerTransform.Summary, typeof(IDataTransform), typeof(ImageResizerTransform), typeof(ImageResizerTransform.Arguments),
typeof(SignatureDataTransform), ImageResizerTransform.UserName, "ImageResizerTransform", "ImageResizer")]

[assembly: LoadableClass(ImageResizerTransform.Summary, typeof(ImageResizerTransform), null, typeof(SignatureLoadDataTransform),
[assembly: LoadableClass(ImageResizerTransform.Summary, typeof(IDataTransform), typeof(ImageResizerTransform), null, typeof(SignatureLoadDataTransform),
ImageResizerTransform.UserName, ImageResizerTransform.LoaderSignature)]

[assembly: LoadableClass(typeof(ImageResizerTransform), null, typeof(SignatureLoadModel),
Expand Down
1 change: 1 addition & 0 deletions src/Microsoft.ML.TensorFlow/Microsoft.ML.TensorFlow.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<ItemGroup>
<ProjectReference Include="..\Microsoft.ML.Core\Microsoft.ML.Core.csproj" />
<ProjectReference Include="..\Microsoft.ML.Data\Microsoft.ML.Data.csproj" />
<ProjectReference Include="..\Microsoft.ML.ImageAnalytics\Microsoft.ML.ImageAnalytics.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
16 changes: 14 additions & 2 deletions src/Microsoft.ML.TensorFlow/TensorFlow/TensorflowUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,23 @@
using System;
using System.Runtime.InteropServices;
using Microsoft.ML.Runtime.Data;
using Microsoft.ML.Runtime.ImageAnalytics.EntryPoints;

namespace Microsoft.ML.Transforms.TensorFlow
{
internal partial class TensorFlowUtils
public static class TensorFlowUtils
Copy link
Member

@abgoswam abgoswam Aug 31, 2018

Choose a reason for hiding this comment

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

TensorFlowUtils [](start = 24, length = 15)

so in the unit test TensorFlowTransformCifarLearningPipelineTest I need to call TensorFlowUtils.Initialize() before creating the pipeline ? #Resolved

Copy link
Author

Choose a reason for hiding this comment

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

I think it would be useful, since the unit test serves as an example of how to use the transform in a learning pipeline.


In reply to: 214484316 [](ancestors = 214484316)

{
// This method is needed for the Pipeline API, since ModuleCatalog does not load entry points that are located
// in assemblies that aren't directly used in the code. Users who want to use TensorFlow components will have to call
// TensorFlowUtils.Initialize() before creating the pipeline.
/// <summary>
/// Initialize the TensorFlow environment. Call this method before adding TensorFlow components to a learning pipeline.
/// </summary>
public static void Initialize()
{
ImageAnalytics.Initialize();
}

internal static PrimitiveType Tf2MlNetType(TFDataType type)
{
switch (type)
Expand All @@ -27,7 +39,7 @@ internal static PrimitiveType Tf2MlNetType(TFDataType type)
}
}

public static unsafe void FetchData<T>(IntPtr data, T[] result)
internal static unsafe void FetchData<T>(IntPtr data, T[] result)
{
var size = result.Length;

Expand Down
2 changes: 2 additions & 0 deletions test/Microsoft.ML.Tests/Scenarios/TensorflowTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Microsoft.ML.Runtime.LightGBM;
using Microsoft.ML.Trainers;
using Microsoft.ML.Transforms;
using Microsoft.ML.Transforms.TensorFlow;
using System.Collections.Generic;
using System.IO;
using Xunit;
Expand Down Expand Up @@ -57,6 +58,7 @@ public void TensorFlowTransformCifarLearningPipelineTest()
pipeline.Add(new TextToKeyConverter("Label"));
pipeline.Add(new StochasticDualCoordinateAscentClassifier());

TensorFlowUtils.Initialize();
var model = pipeline.Train<CifarData, CifarPrediction>();
string[] scoreLabels;
model.TryGetScoreLabelNames(out scoreLabels);
Expand Down