Skip to content

Commit c729952

Browse files
authored
Merge pull request #138 from Microsoft/user/xianz/winmldb
User/xianz/winmldb
2 parents 367079d + 1e23d88 commit c729952

File tree

7 files changed

+37
-12
lines changed

7 files changed

+37
-12
lines changed

Tools/WinMLDashboard/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ public/*
4141
!public/WinMLRunner.exe
4242
!public/libsvm-3.22-cp36-cp36m-win_amd64.whl
4343
!public/winmltools-1.3.0-py2.py3-none-any.whl
44+
!public/questionmark.png
45+
!public/questionmark2.png
4446

4547
npm-debug.log*
4648
yarn-debug.log*

Tools/WinMLDashboard/README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,18 @@ The **Edit/View** button switches from Edit mode to View-only mode and vice vers
2828

2929
## Converting Models
3030

31-
The **Convert** tab (see snip below) helps convert models from several different frameworks (as listed above) to ONNX format.
31+
The **Convert** tab (see snip below) helps convert models from several different frameworks (as listed above) to ONNX format by [WinMLTools](https://pypi.org/project/winmltools/). Also you can select the ONNX version to convert to and apply Quantization.
3232

3333
In order to do the conversion, the tool installs a separate Python environment and a set of converter tools. This helps alleviate one of the big pain points of a typical developer - installing the right Python environment and tool chain for conversion and validating the model.
3434

35+
WinMLTools provides quantization feature to reduce the memory footprint of the model.
36+
37+
For **quantization**:
38+
|Type |Usage |
39+
|-----|--------|
40+
|**Type1**|Do not use dequantize_linear option, the converted model can only be run in Win10 released before [Version 1809 (OS build 17763)](https://support.microsoft.com/en-us/help/4464619/windows-10-update-history)|
41+
|**Type2**|Use dequantize_linear option, the converted model can also be run in Win10 release after Version 1809 (OS build 17763)|
42+
3543
<img src="./public/Converter.png" width=800/>
3644

3745
## Validating Models
-28.7 KB
Loading

Tools/WinMLDashboard/public/convert.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ def onnx_converter(args):
112112
return onnx_model
113113

114114
framework_converters = {
115+
'': onnx_converter,
115116
'coreml': coreml_converter,
116117
'keras': keras_converter,
117118
'scikit-learn': scikit_learn_converter,
@@ -124,7 +125,7 @@ def onnx_converter(args):
124125
'h5': keras_converter,
125126
'keras': keras_converter,
126127
'mlmodel': coreml_converter,
127-
'onnx': coreml_converter,
128+
'onnx': onnx_converter,
128129
}
129130

130131

2.74 KB
Loading
4.6 KB
Loading

Tools/WinMLDashboard/src/view/convert/View.tsx

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class ConvertView extends React.Component<IComponentProperties, IComponentState>
6161
super(props);
6262
const error = isWeb() ? "The converter can't be run in the web interface" : undefined;
6363
this.state = {
64-
ONNXVersion: {value: '1.2', label: '1.2(V7)'},
64+
ONNXVersion: {value: '1.2', label: '1.2 (opset V7)'},
6565
console: '',
6666
currentStep: Step.Idle,
6767
error,
@@ -215,13 +215,13 @@ class ConvertView extends React.Component<IComponentProperties, IComponentState>
215215
{ value: 'TensorFlow', label: 'TensorFlow' },
216216
];
217217
const ONNXVersionOptions = [
218-
{ value: '1.2', label: '1.2(V7)' },
219-
{ value: '1.3', label: '1.3(V8)' },
218+
{ value: '1.2', label: '1.2 (opset V7)' },
219+
{ value: '1.3', label: '1.3 (opset V8)' },
220220
]
221221
const QuantizationOptions = [
222222
{ value: 'none', label: 'None' },
223-
{ value: 'RS5', label: 'Quantize on OS 1809' },
224-
{ value: '19H1', label: 'Quantize on pre-release of 19H1' },
223+
{ value: 'RS5', label: 'Type1'},
224+
{ value: '19H1', label: 'Type2'},
225225
]
226226
return (
227227
<div className="ModelConvert">
@@ -244,7 +244,13 @@ class ConvertView extends React.Component<IComponentProperties, IComponentState>
244244
onChange={this.setONNXVersion}
245245
options={ONNXVersionOptions}
246246
/>
247-
<label className='label-center-align'>Quantization: </label>
247+
<label className='label-center-align'>
248+
Quantization
249+
<img onClick={this.openReadMe} src={packagedFile('questionmark.png')}
250+
onMouseOver = {this.hover}
251+
onMouseOut = {this.unhover}
252+
title="WinMLTools provides quantization feature to reduce the memory footprint of the model." height="16px"/>:
253+
</label>
248254
<Select className='QuantizationOptions'
249255
value={this.newOption(this.state.quantizationOption.label)}
250256
onChange={this.setQuantization}
@@ -258,11 +264,22 @@ class ConvertView extends React.Component<IComponentProperties, IComponentState>
258264
<TextField id='outputNames' className='outputNames' placeholder='output:0 output:1' value={this.state.outputNames} onChanged={this.setOutputNames} />
259265
</div>
260266
</div>
261-
<DefaultButton id='ConvertButton' text='Convert' disabled={!this.state.source || !this.state.framework} onClick={this.convert}/>
267+
<DefaultButton id='ConvertButton' text='Convert' disabled={!this.state.source || (!this.state.framework && this.state.quantizationOption.value === 'none')} onClick={this.convert}/>
262268
</div>
263269
);
264270
}
271+
272+
private hover = (event: React.MouseEvent<HTMLImageElement>) => {
273+
event.currentTarget.setAttribute('src', packagedFile('questionmark2.png'))
274+
}
265275

276+
private unhover = (event: React.MouseEvent<HTMLImageElement>) => {
277+
event.currentTarget.setAttribute('src', packagedFile('questionmark.png'))
278+
}
279+
private openReadMe = () => {
280+
const tpnUrl = 'https://github.com/Microsoft/Windows-Machine-Learning/tree/master/Tools/WinMLDashboard#converting-models';
281+
require('electron').shell.openExternal(tpnUrl);
282+
}
266283
private newOption = (framework: string):ISelectOpition => {
267284
return {
268285
label: framework,
@@ -320,9 +337,6 @@ class ConvertView extends React.Component<IComponentProperties, IComponentState>
320337
private convert = async () => {
321338
this.initializeState();
322339

323-
if (!this.state.framework) {
324-
return;
325-
}
326340
const convertDialogOptions = {
327341
message: '',
328342
title: 'convert result',

0 commit comments

Comments
 (0)