Skip to content

Commit 1ecded3

Browse files
author
Sheil Kumar
committed
Add Embedded encrypted resource sample
1 parent 5b8b7c7 commit 1ecded3

File tree

14 files changed

+793
-39
lines changed

14 files changed

+793
-39
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ protected override async void OnNavigatedTo(NavigationEventArgs e)
3434
case "ImageSharpInterop":
3535
SampleFrame.Navigate(typeof(Samples.ImageSharpInterop));
3636
break;
37+
case "EncryptedResource":
38+
SampleFrame.Navigate(typeof(Samples.EncryptedResource));
39+
break;
3740
}
3841
if (sampleMetadata.Docs.Count > 0)
3942
DocsHeader.Visibility = Visibility.Visible;

Samples/WinMLSamplesGallery/WinMLSamplesGallery/SampleMetadata/SampleMetadata.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,16 @@
5454
"XAMLGithubLink": "https://github.com/microsoft/Windows-Machine-Learning/blob/master/Samples/WinMLSamplesGallery/WinMLSamplesGallery/Samples/ImageSharpInterop/ImageSharpInterop.xaml",
5555
"CSharpGithubLink": "https://github.com/microsoft/Windows-Machine-Learning/blob/master/Samples/WinMLSamplesGallery/WinMLSamplesGallery/Samples/ImageSharpInterop/ImageSharpInterop.xaml.cs",
5656
"Docs": []
57+
},
58+
{
59+
"Title": "Encrypted Models",
60+
"DescriptionShort": "The sample shows how to use Windows ML to load encrypted models from embedded resources.",
61+
"Description": "The sample shows how to use Windows ML to load encrypted models from embedded resources.",
62+
"Icon": "\uE155",
63+
"Tag": "EncryptedResource",
64+
"XAMLGithubLink": "https://github.com/microsoft/Windows-Machine-Learning/blob/master/Samples/WinMLSamplesGallery/WinMLSamplesGallery/Samples/ImageSharpInterop/EncryptedResource.xaml",
65+
"CSharpGithubLink": "https://github.com/microsoft/Windows-Machine-Learning/blob/master/Samples/WinMLSamplesGallery/WinMLSamplesGallery/Samples/ImageSharpInterop/EncryptedResource.xaml.cs",
66+
"Docs": []
5767
}
5868
]
5969
}
Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
<Page
2+
x:Class="WinMLSamplesGallery.Samples.EncryptedResource"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
6+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
7+
xmlns:local_controls="using:WinMLSamplesGallery.Controls"
8+
xmlns:local_samples="using:WinMLSamplesGallery.Samples"
9+
mc:Ignorable="d"
10+
11+
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
12+
13+
<Page.Resources>
14+
<DataTemplate x:Key="ImageTemplate" x:DataType="local_controls:Thumbnail">
15+
<Image Stretch="UniformToFill" Source="{x:Bind ImageUri}" Width="200" Height="204" />
16+
</DataTemplate>
17+
18+
<DataTemplate x:Name="InferenceResultsTemplate" x:DataType="local_controls:Prediction">
19+
<StackPanel Orientation="Horizontal">
20+
<TextBlock Width="414"
21+
FontSize="14"
22+
Foreground="Black"
23+
Padding="0,1,1,1"
24+
Typography.Capitals="AllSmallCaps"
25+
Typography.StylisticSet4="True"
26+
TextTrimming="CharacterEllipsis">
27+
<Run Text="[" />
28+
<Run Text="{Binding Index}" />
29+
<Run Text="] " />
30+
<Run Text="{Binding Name}" />
31+
</TextBlock>
32+
<TextBlock Width="120"
33+
FontSize="14"
34+
Foreground="Black"
35+
Padding="0,1,1,1"
36+
Typography.Capitals="AllSmallCaps"
37+
Typography.StylisticSet4="True">
38+
<Run Text="p =" />
39+
<Run Text="{Binding Probability}" />
40+
</TextBlock>
41+
</StackPanel>
42+
</DataTemplate>
43+
44+
<DataTemplate x:Name="AllModelsTemplate" x:DataType="local_samples:ClassifierViewModel">
45+
<Grid Background="#e6e6e6" BorderBrush="#12bef6" BorderThickness="1">
46+
<TextBlock FontSize="14" Text="{x:Bind Title}"
47+
Typography.Capitals="AllSmallCaps"
48+
Typography.StylisticSet4="True"
49+
VerticalAlignment="Top"
50+
Padding="10,2,10,2"
51+
MinWidth="136"
52+
/>
53+
</Grid>
54+
</DataTemplate>
55+
</Page.Resources>
56+
57+
<Grid>
58+
<ScrollViewer
59+
ZoomMode="Disabled"
60+
IsVerticalScrollChainingEnabled="True"
61+
HorizontalScrollMode="Enabled" HorizontalScrollBarVisibility="Disabled"
62+
VerticalScrollMode="Enabled" VerticalScrollBarVisibility="Visible">
63+
<Grid>
64+
<Grid.RowDefinitions>
65+
<RowDefinition Height="*" />
66+
<RowDefinition Height="Auto" />
67+
<RowDefinition Height="*" />
68+
</Grid.RowDefinitions>
69+
70+
<StackPanel Grid.Row="0" Orientation="Horizontal" Padding="0,10,0,0">
71+
<StackPanel Orientation="Vertical">
72+
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
73+
<Button FontFamily="Segoe MDL2 Assets" Content="&#xE1A5;" Width="55" Height="50" HorizontalAlignment="Left" Click="OpenButton_Clicked" />
74+
<Grid Padding="5,0,0,0">
75+
<ComboBox x:Name="DeviceComboBox" SelectedIndex="0" Background="LightGray" PlaceholderText="Device" Height="50" Width="139"
76+
SelectionChanged="DeviceComboBox_SelectionChanged">
77+
<TextBlock Text="CPU" FontSize="18" Typography.Capitals="AllSmallCaps" Typography.StylisticSet4="True"/>
78+
<TextBlock Text="DirectML" FontSize="18" Typography.Capitals="AllSmallCaps" Typography.StylisticSet4="True"/>
79+
</ComboBox>
80+
</Grid>
81+
</StackPanel>
82+
<GridView
83+
x:Name="BasicGridView"
84+
ItemTemplate="{StaticResource ImageTemplate}"
85+
IsItemClickEnabled="True"
86+
SelectionChanged="SampleInputsGridView_SelectionChanged"
87+
SelectionMode="Single"
88+
Padding="0,6,0,0"
89+
HorizontalAlignment="Center">
90+
<GridView.ItemsPanel>
91+
<ItemsPanelTemplate>
92+
<StackPanel Orientation="Vertical" />
93+
</ItemsPanelTemplate>
94+
</GridView.ItemsPanel>
95+
<GridView.Items>
96+
<local_controls:Thumbnail ImageUri="ms-appx:///InputData/hummingbird.jpg" />
97+
</GridView.Items>
98+
</GridView>
99+
</StackPanel>
100+
101+
<StackPanel Orientation="Horizontal">
102+
<StackPanel Orientation="Vertical" Margin="11,0,0,0">
103+
<Border x:Name="OriginalBorder" Background="LightGray" BorderBrush="LightGray" CornerRadius="5,5,0,0" Padding="0,5,0,5">
104+
<Grid Width="200">
105+
<TextBlock Text="Original" FontSize="18" Typography.Capitals="AllSmallCaps" Typography.StylisticSet4="True" HorizontalAlignment="Center"/>
106+
</Grid>
107+
</Border>
108+
<Grid Background="LightGray" HorizontalAlignment="Center" Height="200" Width="200" VerticalAlignment="Top">
109+
<Image x:Name="InputImage" Stretch="UniformToFill" Height="200" HorizontalAlignment="Center"/>
110+
</Grid>
111+
<Button Content="Classify" x:Name="InferOriginal" IsEnabled="false" FontFamily="Segoe UI Light" Typography.Capitals="AllSmallCaps" Typography.StylisticSet4="True"
112+
Style="{StaticResource AccentButtonStyle}" Width="200"
113+
Click="InferOriginal_Click"/>
114+
</StackPanel>
115+
116+
<StackPanel Orientation="Vertical" Margin="11,0,0,0">
117+
<Border x:Name="NoisyBorder" Background="LightGray" BorderBrush="LightGray" CornerRadius="5,5,0,0" Padding="0,5,0,5">
118+
<Grid Width="200">
119+
<TextBlock Text="Noisy" FontSize="18" Typography.Capitals="AllSmallCaps" Typography.StylisticSet4="True" HorizontalAlignment="Center"/>
120+
</Grid>
121+
</Border>
122+
<Grid Background="LightGray" HorizontalAlignment="Center" Height="200" Width="200" VerticalAlignment="Top">
123+
<Image x:Name="NoisyImage" Stretch="UniformToFill" Height="200" HorizontalAlignment="Center"/>
124+
</Grid>
125+
<Button Content="Classify" x:Name="InferNoisy" IsEnabled="false" FontFamily="Segoe UI Light" Typography.Capitals="AllSmallCaps" Typography.StylisticSet4="True"
126+
Style="{StaticResource AccentButtonStyle}" Width="200"
127+
Click="InferNoisy_Click"/>
128+
</StackPanel>
129+
130+
<StackPanel Orientation="Vertical" Margin="11,0,0,0">
131+
<Border x:Name="DenoisedBorder" Background="LightGray" BorderBrush="LightGray" CornerRadius="5,5,0,0" Padding="0,5,0,5">
132+
<Grid Width="200">
133+
<TextBlock Text="Denoised" FontSize="18" Typography.Capitals="AllSmallCaps" Typography.StylisticSet4="True" HorizontalAlignment="Center"/>
134+
</Grid>
135+
</Border>
136+
<Grid Background="LightGray" HorizontalAlignment="Center" Height="200" Width="200" VerticalAlignment="Top">
137+
<Image x:Name="DenoisedImage" Stretch="UniformToFill" Height="200" HorizontalAlignment="Center"/>
138+
</Grid>
139+
<Button Content="Classify" x:Name="InferDenoised" IsEnabled="false" FontFamily="Segoe UI Light" Typography.Capitals="AllSmallCaps" Typography.StylisticSet4="True"
140+
Style="{StaticResource AccentButtonStyle}" Width="200"
141+
Click="InferDenoised_Click"/>
142+
</StackPanel>
143+
</StackPanel>
144+
</StackPanel>
145+
146+
<StackPanel Orientation="Horizontal" Grid.Row="2"
147+
Padding="0,7,0,0">
148+
<ListView
149+
x:Name="InferenceResults"
150+
HorizontalAlignment="Stretch"
151+
Padding="0,2,0,0"
152+
ItemTemplate="{StaticResource InferenceResultsTemplate}"
153+
IsItemClickEnabled="False"
154+
SingleSelectionFollowsFocus="False">
155+
<ListView.ItemContainerStyle>
156+
<Style TargetType="ListViewItem">
157+
<Setter Property="Margin" Value="1,1,1,1"/>
158+
<Setter Property="MinHeight" Value="0"/>
159+
</Style>
160+
</ListView.ItemContainerStyle>
161+
162+
<ListView.ItemsPanel>
163+
<ItemsPanelTemplate>
164+
<ItemsWrapGrid x:Name="MaxItemsWrapGrid" Orientation="Vertical" HorizontalAlignment="Stretch"/>
165+
</ItemsPanelTemplate>
166+
</ListView.ItemsPanel>
167+
</ListView>
168+
<local_controls:PerformanceMonitor x:Name="PerformanceMetricsMonitor"/>
169+
</StackPanel>
170+
</Grid>
171+
</ScrollViewer>
172+
</Grid>
173+
</Page>

0 commit comments

Comments
 (0)