Merge remote-tracking branch 'origin/user/sheilk/winml-samples-gallery' into user/numform/winml-samples-gallery
This commit is contained in:
Коммит
cbcbbcffa6
|
@ -13,13 +13,13 @@
|
|||
"test": "mocha",
|
||||
"eject": "react-scripts-ts eject",
|
||||
"postinstall": "node scripts/postinstall.js && yarn copy-netron",
|
||||
"copy-netron": "yarn --cwd deps/Netron && python deps/copy_netron.py",
|
||||
"copy-netron": "yarn lock-netron-deps && yarn --cwd deps/Netron && python deps/copy_netron.py",
|
||||
"build-electron": "react-app-rewired build --scripts-version react-scripts-ts",
|
||||
"build-cpp": "msbuild src/cpp/DebugRunner.sln",
|
||||
"nuget-restore-cpp": "nuget restore src/cpp/DebugRunner.sln",
|
||||
"electron-dev": "electron . http://localhost:3000",
|
||||
"electron-prod": "yarn nuget-restore-cpp && yarn build-cpp && yarn build-electron && electron .",
|
||||
"lock-netron-deps": "cd deps/Netron && yarn upgrade d3@5.16.0"
|
||||
"lock-netron-deps": "yarn --cwd deps/Netron install && yarn --cwd deps/Netron upgrade d3@5.16.0 flatbuffers@1.12.0"
|
||||
},
|
||||
"build": {
|
||||
"appId": "com.microsoft.dashboard.winml",
|
||||
|
|
|
@ -7,6 +7,7 @@ def parse_args():
|
|||
parser.add_argument('source', help='source model')
|
||||
parser.add_argument('framework', help='source framework model comes from')
|
||||
parser.add_argument('ONNXVersion', help='which ONNX Version to convert to')
|
||||
parser.add_argument('inputNames', help='names of input nodes')
|
||||
parser.add_argument('outputNames', help='names of output nodes')
|
||||
parser.add_argument('destination', help='destination ONNX model (ONNX or prototxt extension)')
|
||||
parser.add_argument('--name', default='WimMLDashboardConvertedModel', help='(ONNX output only) model name')
|
||||
|
@ -29,9 +30,20 @@ def get_opset(ONNXVersion):
|
|||
return 7
|
||||
elif '1.3' == ONNXVersion:
|
||||
return 8
|
||||
elif '1.4' == ONNXVersion:
|
||||
return 9
|
||||
elif '1.5' == ONNXVersion:
|
||||
return 10
|
||||
elif '1.6' == ONNXVersion:
|
||||
return 11
|
||||
elif '1.7' == ONNXVersion:
|
||||
return 12
|
||||
elif '1.8' == ONNXVersion:
|
||||
return 13
|
||||
elif '1.9' == ONNXVersion:
|
||||
return 14
|
||||
else:
|
||||
print('WARNING: ONNX Version ' + ONNXVersion + ' does not map to any known opset version, defaulting to opset V7')
|
||||
return 7
|
||||
|
||||
|
||||
|
@ -87,7 +99,7 @@ def libSVM_converter(args):
|
|||
target_opset=get_opset(args.ONNXVersion))
|
||||
return onnx_model
|
||||
|
||||
def convert_tensorflow_file(filename, opset, output_names):
|
||||
def convert_tensorflow_file(filename, opset, input_names, output_names):
|
||||
import tensorflow
|
||||
from tensorflow.core.framework import graph_pb2
|
||||
from tensorflow.python.tools import freeze_graph
|
||||
|
@ -97,12 +109,12 @@ def convert_tensorflow_file(filename, opset, output_names):
|
|||
graph_def = graph_pb2.GraphDef()
|
||||
with open(filename, 'rb') as file:
|
||||
graph_def.ParseFromString(file.read())
|
||||
converted_model = onnxmltools.convert_tensorflow(graph_def, target_opset=opset, input_names=[], output_names=output_names)
|
||||
converted_model = onnxmltools.convert_tensorflow(graph_def, target_opset=opset, input_names=input_names, output_names=output_names)
|
||||
onnx.checker.check_model(converted_model)
|
||||
return converted_model
|
||||
|
||||
def tensorFlow_converter(args):
|
||||
return convert_tensorflow_file(args.source, get_opset(args.ONNXVersion), args.outputNames.split())
|
||||
return convert_tensorflow_file(args.source, get_opset(args.ONNXVersion), args.inputNames.split(), args.outputNames.split())
|
||||
|
||||
def onnx_converter(args):
|
||||
onnx_model = onnxmltools.load_model(args.source)
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
coremltools_windows==2.0b1
|
||||
onnxmltools==1.7.0
|
||||
onnxmltools==1.9.1
|
||||
onnxconverter-common==1.7.0
|
||||
h5py==2.8.0
|
||||
tensorflow==1.12.2
|
||||
tf2onnx==1.7.2
|
||||
tf2onnx==1.9.2
|
||||
Keras==2.2.4
|
||||
Keras-Applications==1.0.6
|
||||
Keras-Preprocessing==1.0.5
|
||||
keras2onnx==1.7.0
|
||||
protobuf==3.8.0
|
||||
protobuf==3.17.3
|
||||
PyYAML==4.2b1
|
||||
scipy==1.1.0
|
||||
scikit-learn==0.20.1
|
||||
|
|
|
@ -61,8 +61,15 @@ function createWindow() {
|
|||
|
||||
mainWindow = new BrowserWindow({
|
||||
height: 1000,
|
||||
icon: path.join(__dirname, '../public/winml_icon.ico'),
|
||||
width: 1200,
|
||||
|
||||
icon: path.join(__dirname, '../public/winml_icon.ico'),
|
||||
webPreferences: {
|
||||
contextIsolation: false,
|
||||
enableRemoteModule: true,
|
||||
nodeIntegration: true,
|
||||
webviewTag: true,
|
||||
}
|
||||
});
|
||||
global.mainWindow = mainWindow;
|
||||
|
||||
|
|
|
@ -51,6 +51,7 @@ interface IComponentState {
|
|||
currentStep: Step,
|
||||
error?: Error | string,
|
||||
framework: string,
|
||||
inputNames: string,
|
||||
outputNames: string,
|
||||
source?: string,
|
||||
}
|
||||
|
@ -67,6 +68,7 @@ class ConvertView extends React.Component<IComponentProperties, IComponentState>
|
|||
currentStep: Step.Idle,
|
||||
error,
|
||||
framework: '',
|
||||
inputNames: '',
|
||||
outputNames: '',
|
||||
};
|
||||
log.info("Convert view is created.");
|
||||
|
@ -220,10 +222,12 @@ class ConvertView extends React.Component<IComponentProperties, IComponentState>
|
|||
const ONNXVersionOptions = [
|
||||
{ value: '1.2', label: '1.2 (opset V7)' },
|
||||
{ value: '1.3', label: '1.3 (opset V8)' },
|
||||
{ value: '1.4', label: '1.4 (opset V9)' },
|
||||
{ value: '1.5', label: '1.5 (opset V10)' },
|
||||
{ value: '1.6', label: '1.6 (opset V11)' },
|
||||
{ value: '1.7', label: '1.7 (opset V12)' },
|
||||
{ value: '1.8', label: '1.8 (opset V13)' },
|
||||
{ value: '1.9', label: '1.9 (opset V14)' },
|
||||
]
|
||||
return (
|
||||
<div className="ModelConvert">
|
||||
|
@ -248,6 +252,13 @@ class ConvertView extends React.Component<IComponentProperties, IComponentState>
|
|||
/>
|
||||
</div>
|
||||
<br />
|
||||
<div className={this.state.framework === 'TensorFlow' ? ' ' : 'hidden'}>
|
||||
<div className='DisplayFlex'>
|
||||
<label className='label-left-align'>Input Names: </label>
|
||||
<TextField id='inputNames' className='inputNames' placeholder='X:0 (optional)' value={this.state.inputNames} onChanged={this.setInputNames} />
|
||||
</div>
|
||||
</div>
|
||||
<br />
|
||||
<div className={this.state.framework === 'TensorFlow' ? ' ' : 'hidden'}>
|
||||
<div className='DisplayFlex'>
|
||||
<label className='label-left-align'>Output Names: </label>
|
||||
|
@ -265,6 +276,11 @@ class ConvertView extends React.Component<IComponentProperties, IComponentState>
|
|||
value: framework,
|
||||
}
|
||||
}
|
||||
|
||||
private setInputNames = (inputNames: string) => {
|
||||
this.setState({inputNames})
|
||||
}
|
||||
|
||||
private setOutputNames = (outputNames: string) => {
|
||||
this.setState({outputNames})
|
||||
}
|
||||
|
@ -323,6 +339,7 @@ class ConvertView extends React.Component<IComponentProperties, IComponentState>
|
|||
await python([packagedFile('convert.py'), this.state.source!,
|
||||
this.state.framework,
|
||||
this.state.ONNXVersion.value,
|
||||
this.state.inputNames,
|
||||
this.state.outputNames,
|
||||
packagedFile('tempConvertResult.onnx')], {}, this.outputListener);
|
||||
} catch (e) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче