@tensorflow/tfjs-converter
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -18,9 +18,12 @@ "use strict"; | ||
*/ | ||
var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
@@ -27,0 +30,0 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { |
@@ -37,2 +37,5 @@ "use strict"; | ||
]; | ||
case 'IdentityN': | ||
return utils_1.getParamValue('x', node, tensorMap, context) | ||
.map(function (t) { return t.clone(); }); | ||
case 'Snapshot': | ||
@@ -39,0 +42,0 @@ var snapshot = utils_1.getParamValue('x', node, tensorMap, context); |
@@ -45,2 +45,7 @@ "use strict"; | ||
{ | ||
'tfOpName': 'IdentityN', | ||
'category': 'graph', | ||
'inputs': [{ 'start': 0, 'end': 0, 'name': 'x', 'type': 'tensors' }] | ||
}, | ||
{ | ||
'tfOpName': 'Snapshot', | ||
@@ -47,0 +52,0 @@ 'category': 'graph', |
/** @license See the LICENSE file. */ | ||
declare const version = "1.0.0"; | ||
declare const version = "1.0.1"; | ||
export { version }; |
@@ -5,4 +5,4 @@ "use strict"; | ||
// This code is auto-generated, do not modify this file! | ||
var version = '1.0.0'; | ||
var version = '1.0.1'; | ||
exports.version = version; | ||
//# sourceMappingURL=version.js.map |
{ | ||
"name": "@tensorflow/tfjs-converter", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Tensorflow model converter for javascript", | ||
@@ -17,6 +17,6 @@ "main": "dist/src/index.js", | ||
"peerDependencies": { | ||
"@tensorflow/tfjs-core": "1.0.0" | ||
"@tensorflow/tfjs-core": "1.0.1" | ||
}, | ||
"devDependencies": { | ||
"@tensorflow/tfjs-core": "1.0.0", | ||
"@tensorflow/tfjs-core": "1.0.1", | ||
"@types/jasmine": "~2.8.6", | ||
@@ -51,3 +51,3 @@ "@types/long": "~3.0.32", | ||
"tslint-no-circular-imports": "~0.5.0", | ||
"typescript": "~2.9.2", | ||
"typescript": "3.3.3333", | ||
"yalc": "~1.0.0-pre.21" | ||
@@ -54,0 +54,0 @@ }, |
@@ -6,13 +6,13 @@ [![Build Status](https://travis-ci.org/tensorflow/tfjs-converter.svg?branch=master)](https://travis-ci.org/tensorflow/tfjs-converter) | ||
**TensorFlow.js converter** is an open source library to load a pretrained | ||
TensorFlow [SavedModel](https://www.tensorflow.org/programmers_guide/saved_model#overview_of_saving_and_restoring_models), [Frozen Model](https://www.tensorflow.org/mobile/prepare_models#how_do_you_get_a_model_you_can_use_on_mobile), [Session Bundle](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/session_bundle/README.md) or [TensorFlow Hub module](https://www.tensorflow.org/hub/) | ||
TensorFlow [SavedModel](https://www.tensorflow.org/programmers_guide/saved_model#overview_of_saving_and_restoring_models) or [TensorFlow Hub module](https://www.tensorflow.org/hub/) | ||
into the browser and run inference through [TensorFlow.js](https://js.tensorflow.org). | ||
(Note: TensorFlow has deprecated session bundle format, please switch to SavedModel.) | ||
(Note: Session bundle and Frozen model formats have been deprecated in TensorFlow.js 1.0. Please use TensorFlow.js 0.15.x version to convert these formats.) | ||
A 2-step process to import your model: | ||
1. A python pip package to convert a TensorFlow SavedModel/Frozen Model/Session Bundle to a web friendly format. If you already have a converted model, or are using an already hosted model (e.g. MobileNet), skip this step. | ||
1. A python pip package to convert a TensorFlow SavedModel or TensorFlow Hub module to a web friendly format. If you already have a converted model, or are using an already hosted model (e.g. MobileNet), skip this step. | ||
2. [Javascript API](./src/executor/tf_model.ts), for loading and running inference. | ||
## Step 1: Converting a [SavedModel](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/saved_model/README.md), [Keras h5](https://keras.io/getting-started/faq/#how-can-i-save-a-keras-model), [tf.keras SavedModel](https://www.tensorflow.org/api_docs/python/tf/contrib/saved_model/save_keras_model), [Session Bundle](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/session_bundle/README.md), [Frozen Model](https://www.tensorflow.org/mobile/prepare_models#how_do_you_get_a_model_you_can_use_on_mobile) or [TensorFlow Hub module](https://www.tensorflow.org/hub/) to a web-friendly format | ||
## Step 1: Converting a [SavedModel](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/saved_model/README.md), [Keras h5](https://keras.io/getting-started/faq/#how-can-i-save-a-keras-model), [tf.keras SavedModel](https://www.tensorflow.org/api_docs/python/tf/contrib/saved_model/save_keras_model) or [TensorFlow Hub module](https://www.tensorflow.org/hub/) to a web-friendly format | ||
@@ -34,3 +34,3 @@ 1. Install the TensorFlow.js pip package: | ||
--input_format=tf_saved_model \ | ||
--output_node_names='MobilenetV1/Predictions/Reshape_1' \ | ||
--signature_name=serving_default \ | ||
--saved_model_tags=serve \ | ||
@@ -41,23 +41,2 @@ /mobilenet/saved_model \ | ||
Frozen model example: | ||
```bash | ||
$ tensorflowjs_converter \ | ||
--input_format=tf_frozen_model \ | ||
--output_node_names='MobilenetV1/Predictions/Reshape_1' \ | ||
--saved_model_tags=serve \ | ||
/mobilenet/frozen_model.pb \ | ||
/mobilenet/web_model | ||
``` | ||
Session bundle model example: | ||
```bash | ||
$ tensorflowjs_converter \ | ||
--input_format=tf_session_bundle \ | ||
--output_node_names='MobilenetV1/Predictions/Reshape_1' \ | ||
/mobilenet/session_bundle \ | ||
/mobilenet/web_model | ||
``` | ||
Tensorflow Hub module example: | ||
@@ -103,9 +82,9 @@ | ||
|`--input_format` | The format of input model, use `tf_saved_model` for SavedModel, `tf_frozen_model` for frozen model, `tf_session_bundle` for session bundle, `tf_hub` for TensorFlow Hub module, `tfjs_layers_model` for TensorFlow.js JSON format, and `keras` for Keras HDF5. | | ||
|<nobr>`--output_node_names`</nobr>| The names of the output nodes, separated by commas.| | ||
|`--output_format`| The desired output format. Must be `tfjs_layers_model`, `tfjs_graph_model` or `keras`. Not all pairs of input-output formats are supported. Please file a [github issue](https://github.com/tensorflow/tfjs/issues) if your desired input-output pair is not supported.| | ||
|<nobr>`--saved_model_tags`</nobr> | Only applicable to SavedModel conversion. Tags of the MetaGraphDef to load, in comma separated format. Defaults to `serve`.| | ||
|`--signature_name` | Only applicable to TensorFlow Hub module conversion, signature to load. Defaults to `default`. See https://www.tensorflow.org/hub/common_signatures/.| | ||
|`--signature_name` | Only applicable to TensorFlow SavedModel and Hub module conversion, signature to load. Defaults to `serving_default` for SavedModel and `default` for Hub module. See https://www.tensorflow.org/hub/common_signatures/.| | ||
|`--strip_debug_ops` | Strips out TensorFlow debug operations `Print`, `Assert`, `CheckNumerics`. Defaults to `True`.| | ||
|`--quantization_bytes` | How many bytes to optionally quantize/compress the weights to. Valid values are 1 and 2. which will quantize int32 and float32 to 1 or 2 bytes respectively. The default (unquantized) size is 4 bytes.| | ||
Note: If you want to convert TensorFlow frozen model or session bundle, you can install older versions of the tensorflowjs pip package, i.e. `pip install tensorflowjs==0.8.0`. | ||
@@ -122,8 +101,6 @@ ### Format Conversion Support Tables | ||
|---|---|---| | ||
| `keras` | `tfjs_layers_model` | Convert a keras or tf.keras HDF5 model file to TensorFlow.js Layers model format. Use [`tf.lodLayersModel()`](https://js.tensorflow.org/api/latest/#loadLayersModel) to load the model in JavaScript. | | ||
| `keras_saved_model` | `tfjs_layers_model` | Convert a tf.keras SavedModel model file (from [`tf.contrib.saved_model.save_keras_model`](https://www.tensorflow.org/api_docs/python/tf/contrib/saved_model/save_keras_model)) to TensorFlow.js Layers model format. Use [`tf.lodLayersModel()`](https://js.tensorflow.org/api/latest/#loadLayersModel) to load the model in JavaScript. | | ||
| `tf_frozen_model` | `tfjs_graph_model` | Convert a TensorFlow Frozen Graph (.pb) file to TensorFlow.js graph model format. Use [`tf.loadGraphModel()`](https://js.tensorflow.org/api/latest/#loadGraphModel) to load the converted model in JavaScript. | | ||
| `keras` | `tfjs_layers_model` | Convert a keras or tf.keras HDF5 model file to TensorFlow.js Layers model format. Use [`tf.loadLayersModel()`](https://js.tensorflow.org/api/latest/#loadLayersModel) to load the model in JavaScript. | | ||
| `keras_saved_model` | `tfjs_layers_model` | Convert a tf.keras SavedModel model file (from [`tf.contrib.saved_model.save_keras_model`](https://www.tensorflow.org/api_docs/python/tf/contrib/saved_model/save_keras_model)) to TensorFlow.js Layers model format. Use [`tf.loadLayersModel()`](https://js.tensorflow.org/api/latest/#loadLayersModel) to load the model in JavaScript. | | ||
| `tf_hub` | `tfjs_graph_model` | Convert a [TF-Hub](https://www.tensorflow.org/hub) model file to TensorFlow.js graph model format. Use [`tf.loadGraphModel()`](https://js.tensorflow.org/api/latest/#loadGraphModel) to load the converted model in JavaScript. | | ||
| `tf_saved_model` | `tfjs_graph_model` | Convert a [TensorFlow SavedModel](https://www.tensorflow.org/guide/saved_model#build_and_load_a_savedmodel) to TensorFlow.js graph model format. Use [`tf.loadGraphModel()`](https://js.tensorflow.org/api/latest/#loadGraphModel) to load the converted model in JavaScript. | | ||
| `tf_session_bundle` | `tfjs_graph_model` | Convert a TensorFlow Session Bundle to TensorFlow.js graph model format. Use [`tf.loadGraphModel()`](https://js.tensorflow.org/api/latest/#loadGraphModel) to load the converted model in JavaScript. | | ||
@@ -202,3 +179,3 @@ #### JavaScript-to-Python | ||
[full list](./docs/supported_ops.md). | ||
If your model uses an unsupported ops, the `tensorflowjs_converter` script will fail and | ||
If your model uses unsupported ops, the `tensorflowjs_converter` script will fail and | ||
produce a list of the unsupported ops in your model. Please file issues to let us | ||
@@ -209,3 +186,3 @@ know what ops you need support with. | ||
If you prefer to load the weights only, you can use follow code snippet. | ||
If you prefer to load the weights only, you can use the following code snippet. | ||
@@ -254,2 +231,16 @@ ```typescript | ||
6. I have a model converted with a previous version of TensorFlow.js converter (0.15.x), that is in .pb format. How do I convert it to the new JSON format? | ||
You can use the built-in migration tool to convert the models generated by previous versions. Here are the steps: | ||
``` | ||
git clone git@github.com:tensorflow/tfjs-converter.git | ||
cd tfjs-converter | ||
yarn | ||
yarn ts-node tools/pb2json_converter.ts pb_model_directory/ json_model_directory/ | ||
``` | ||
`pb_model_directory` is the directory where the model generated by previous version is located. | ||
`json_model_directory` is the destination directory for the converted model. | ||
## Development | ||
@@ -268,3 +259,3 @@ | ||
development. Make sure to install | ||
[TSLint VSCode extension](https://marketplace.visualstudio.com/items?itemName=eg2.tslint) | ||
[TSLint VSCode extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.vscode-typescript-tslint-plugin) | ||
and the npm [clang-format](https://github.com/angular/clang-format) `1.2.2` or later | ||
@@ -271,0 +262,0 @@ with the |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2451095
252
26112
2
80
278