Skip to content

Commit 5f79cad

Browse files
author
Linnea May
committed
telemetry
2 parents f05b799 + 93e6abb commit 5f79cad

File tree

11 files changed

+56
-8
lines changed

11 files changed

+56
-8
lines changed

Samples/WinMLSamplesGallery/WinMLSamplesGallery (Package)/WinMLSamplesGallery (Package).wapproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@
132132
</ItemGroup>
133133
<Import Project="$(WapProjPath)\Microsoft.DesktopBridge.targets" />
134134
<ItemGroup>
135-
<PackageReference Include="Microsoft.AI.MachineLearning" Version="1.11.0" />
136-
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.0.0-stable" />
135+
<PackageReference Include="Microsoft.AI.MachineLearning" Version="1.12.1" />
136+
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.1.4" />
137137
</ItemGroup>
138138
</Project>

Samples/WinMLSamplesGallery/WinMLSamplesGallery/Pages/SampleBasePage.xaml.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using Microsoft.UI.Xaml;
22
using Microsoft.UI.Xaml.Controls;
33
using Microsoft.UI.Xaml.Navigation;
4+
using Microsoft.AI.MachineLearning;
5+
using Microsoft.AI.MachineLearning.Experimental;
46
using System;
57

68
namespace WinMLSamplesGallery
@@ -68,5 +70,12 @@ protected override async void OnNavigatingFrom(NavigatingCancelEventArgs e)
6870

6971

7072
}
73+
74+
public static void SetModelNameForTelemetry(String modelName, String sampleName, LearningModel model)
75+
{
76+
var telemetryModelName = modelName + "_" + sampleName;
77+
var experimentalModel = new LearningModelExperimental(model);
78+
experimentalModel.SetName(telemetryModelName);
79+
}
7180
}
7281
}

Samples/WinMLSamplesGallery/WinMLSamplesGallery/Samples/AdapterSelection/AdapterSelection.xaml.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ public AdapterSelection()
3333

3434
adapter_options.AddRange(adapters);
3535
AdapterListView.ItemsSource = adapter_options;
36+
37+
// Run in background thread to avoid blocking UI on sample launch
38+
Task.Run(() => SetModelNameForTelemetry(device));
3639
}
3740

3841
private void ChangeAdapter(object sender, RoutedEventArgs e)
@@ -100,5 +103,16 @@ private List<string> RemoveMicrosoftBasicRenderDriver(string[] adapters_arr)
100103
}
101104
return adapters;
102105
}
106+
107+
// Session must be created for telemety to be sent
108+
private void SetModelNameForTelemetry(LearningModelDevice device)
109+
{
110+
var modelName = "squeezenet1.1-7.onnx";
111+
var modelPath = Path.Join(Windows.ApplicationModel.Package.Current.InstalledLocation.Path, "Models", modelName);
112+
var model = LearningModel.LoadFromFilePath(modelPath);
113+
var options = new LearningModelSessionOptions();
114+
SampleBasePage.SetModelNameForTelemetry("SqueezeNet", "AdapterSelection", model);
115+
new LearningModelSession(model, device, options);
116+
}
103117
}
104118
}

Samples/WinMLSamplesGallery/WinMLSamplesGallery/Samples/Batching/Batching.xaml.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public Batching()
4444
var modelName = "squeezenet1.1-7-batched.onnx";
4545
var modelPath = Path.Join(Windows.ApplicationModel.Package.Current.InstalledLocation.Path, "Models", modelName);
4646
_model = LearningModel.LoadFromFilePath(modelPath);
47+
SampleBasePage.SetModelNameForTelemetry("SqueezeNet", "Batching", _model);
4748
}
4849

4950
async private void StartInference(object sender, RoutedEventArgs e)

Samples/WinMLSamplesGallery/WinMLSamplesGallery/Samples/EncryptedModel/EncryptedModel.xaml.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ private void DecryptAndEvauluate()
4848
// The encrypted model (encrypted.onnx) is embedded as a resource in
4949
// the native binary: WinMLSamplesGalleryNative.dll.
5050
var inferenceModel = WinMLSamplesGalleryNative.EncryptedModels.LoadEncryptedResource(DecryptionKey.Password);
51+
SampleBasePage.SetModelNameForTelemetry("Encrypted", "EncryptedModel", inferenceModel);
5152
var postProcessingModel = TensorizationModels.SoftMaxThenTopK(10);
5253

5354
// Update the status

Samples/WinMLSamplesGallery/WinMLSamplesGallery/Samples/ImageClassifier/ImageClassifier.xaml.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,8 @@ private void InitializeWindowsMachineLearning()
243243
{
244244
var modelPath = _modelDictionary[model];
245245
var inferenceModel = LearningModel.LoadFromFilePath(modelPath);
246+
SetModelNameForTelemetry(inferenceModel);
247+
246248
_inferenceSession = CreateLearningModelSession(inferenceModel);
247249

248250
var preProcessor = _preProcessorDictionary[model];
@@ -444,5 +446,13 @@ private void DeviceComboBox_SelectionChanged(object sender, SelectionChangedEven
444446
{
445447
TryPerformInference();
446448
}
449+
450+
private void SetModelNameForTelemetry(LearningModel model)
451+
{
452+
var viewModel = (ClassifierViewModel)AllModelsGrid.SelectedItem;
453+
var modelName = viewModel.Title;
454+
var sampleName = "ImageClassifier";
455+
SampleBasePage.SetModelNameForTelemetry(modelName, sampleName, model);
456+
}
447457
}
448458
}

Samples/WinMLSamplesGallery/WinMLSamplesGallery/Samples/ImageEffects/ImageEffects.xaml.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ private LearningModelSession CreateLearningModelSession(LearningModel model, boo
364364
CloseModelOnSessionCreation = closeModel, // Close the model to prevent extra memory usage
365365
BatchSizeOverride = 0
366366
};
367+
SampleBasePage.SetModelNameForTelemetry("TensorizationModel", "ImageEffects", model);
367368
var session = new LearningModelSession(model, device, options);
368369
return session;
369370
}

Samples/WinMLSamplesGallery/WinMLSamplesGallery/Samples/ImageSharpInterop/ImageSharpInterop.xaml.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public ImageSharpInterop()
6161
var inferenceModelName = "squeezenet1.1-7.onnx";
6262
var inferenceModelPath = Path.Join(Windows.ApplicationModel.Package.Current.InstalledLocation.Path, "Models", inferenceModelName);
6363
var inferenceModel = LearningModel.LoadFromFilePath(inferenceModelPath);
64+
SampleBasePage.SetModelNameForTelemetry("SqueezeNet", "ImageSharp", inferenceModel);
6465
_inferenceSession = CreateLearningModelSession(inferenceModel);
6566

6667
var postProcessingModel = TensorizationModels.SoftMaxThenTopK(TopK);

Samples/WinMLSamplesGallery/WinMLSamplesGallery/Samples/StreamEffect/StreamEffect.xaml.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Threading.Tasks;
55
using System.Diagnostics;
66
using System.Runtime.CompilerServices;
7+
using Microsoft.AI.MachineLearning;
78
using System.IO;
89
using WinMLSamplesGalleryNative;
910
using System.Runtime.InteropServices;
@@ -30,13 +31,23 @@ public sealed partial class StreamEffect : Page
3031
public StreamEffect()
3132
{
3233
this.InitializeComponent();
34+
// Run in background thread to avoid blocking UI on sample launch
35+
Task.Run(() => SetModelNameForTelemetry());
36+
3337
demoHwnd = (IntPtr)WinMLSamplesGalleryNative.StreamEffect.CreateInferenceWindow();
3438

3539
currentHwnd = GetForegroundWindow();
3640
modelPath = Path.Join(Windows.ApplicationModel.Package.Current.InstalledLocation.Path, "Models");
3741

3842
}
3943

44+
private void SetModelNameForTelemetry()
45+
{
46+
var inferenceBuilder = Microsoft.AI.MachineLearning.Experimental.LearningModelBuilder.Create(11);
47+
var inferenceModel = inferenceBuilder.CreateModel();
48+
SampleBasePage.SetModelNameForTelemetry("FCNResnet", "StreamEffect", inferenceModel);
49+
}
50+
4051
public void CloseInferenceWindow()
4152
{
4253
// if have a windtask running and it's not complete, destroy the window

Samples/WinMLSamplesGallery/WinMLSamplesGallery/WinMLSamplesGallery.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,10 @@
8686
</ItemGroup>
8787

8888
<ItemGroup>
89-
<PackageReference Include="Microsoft.AI.MachineLearning" Version="1.11.0" />
90-
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="1.3.5" />
91-
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.0.0-stable" />
92-
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.4" />
89+
<PackageReference Include="Microsoft.AI.MachineLearning" Version="1.12.1" />
90+
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="1.6.5" />
91+
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.1.4" />
92+
<PackageReference Include="SixLabors.ImageSharp" Version="2.1.3" />
9393
<Manifest Include="$(ApplicationManifest)" />
9494
</ItemGroup>
9595

0 commit comments

Comments
 (0)