@tensorflow/tfjs-converter
Advanced tools
Comparing version 0.2.1 to 0.3.0
@@ -175,3 +175,3 @@ [ | ||
{ | ||
"tfOpName": "Conv2DTranspose", | ||
"tfOpName": "Conv2DBackpropInput", | ||
"dlOpName": "conv2dTranspose", | ||
@@ -191,3 +191,3 @@ "category": "convolution", | ||
{ | ||
"tfParamName": "output_shape", | ||
"tfInputIndex": 2, | ||
"dlParamName": "outputShape", | ||
@@ -194,0 +194,0 @@ "type": "number[]" |
@@ -1,2 +0,2 @@ | ||
declare const version = "0.2.1"; | ||
declare const version = "0.3.0"; | ||
export { version }; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var version = '0.2.1'; | ||
var version = '0.3.0'; | ||
exports.version = version; | ||
//# sourceMappingURL=version.js.map |
{ | ||
"name": "@tensorflow/tfjs-converter", | ||
"version": "0.2.1", | ||
"version": "0.3.0", | ||
"description": "Tensorflow model converter for javascript", | ||
@@ -15,6 +15,6 @@ "main": "dist/index.js", | ||
"peerDependencies": { | ||
"@tensorflow/tfjs-core": "0.9.0" | ||
"@tensorflow/tfjs-core": "0.9.1" | ||
}, | ||
"devDependencies": { | ||
"@tensorflow/tfjs-core": "0.9.0", | ||
"@tensorflow/tfjs-core": "0.9.1", | ||
"@types/jasmine": "~2.8.6", | ||
@@ -21,0 +21,0 @@ "@types/seedrandom": "~2.4.27", |
@@ -6,4 +6,3 @@ [![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) | ||
or [Session Bundle](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/session_bundle/README.md) | ||
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) or [Session Bundle](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/session_bundle/README.md) | ||
into the browser and run inference through [TensorFlow.js](https://js.tensorflow.org). | ||
@@ -15,6 +14,6 @@ | ||
1. A python pip package to convert a TensorFlow SavedModel/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/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. | ||
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) or [Session Bundle](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/session_bundle/README.md) to a web-friendly format | ||
## Step 1: Converting a [SavedModel](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/saved_model/README.md), [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 | ||
@@ -37,3 +36,3 @@ 1. Install the TensorFlow.js pip package: | ||
--output_node_names='MobilenetV1/Predictions/Reshape_1' \ | ||
--saved_model_tags=serve | ||
--saved_model_tags=serve \ | ||
/mobilenet/saved_model \ | ||
@@ -43,2 +42,13 @@ /mobilenet/web_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: | ||
@@ -54,5 +64,14 @@ | ||
Tensorflow Hub module example: | ||
```bash | ||
$ tensorflowjs_converter \ | ||
--input_format=tf_hub \ | ||
'https://tfhub.dev/google/imagenet/mobilenet_v1_100_224/classification/1' \ | ||
/mobilenet/web_model | ||
``` | ||
|Positional Arguments | Description | | ||
|---|---| | ||
|`input_path` | Full path of the saved model or session bundle directory.| | ||
|`input_path` | Full path of the saved model directory, session bundle directory, frozen model file or Tensorflow Hub module handle or path.| | ||
|`output_dir` | Path for all output artifacts.| | ||
@@ -63,3 +82,3 @@ | ||
|---|---| | ||
|`--input_format` | The format of input model, use tf_saved_model for SavedModel and tf_session_bundle for session bundle. | | ||
|`--input_format` | The format of input model, use tf_saved_model for SavedModel, tf_frozen_model for frozen model and tf_session_bundle for session bundle. | | ||
|`--output_node_names`| The names of the output nodes, separated by commas.| | ||
@@ -204,1 +223,15 @@ |`--saved_model_tags` | Only applicable to SavedModel conversion, Tags of the MetaGraphDef to load, in comma separated format. Defaults to `serve`.| | ||
``` | ||
To generate the static js file for GraphDef proto, run following steps: | ||
1. Generate static js file with comment first, in order to generate typescript definition. | ||
```bash | ||
$ node_modules/protobufjs/bin/pbjs -t static-module -w commonjs -o src/data/compiled_api.js --no-create --no-encode --no-verify --no-convert --no-delimited --no-beautify src/data/api.proto | ||
$ node_modules/protobufjs/bin/pbts -o src/data/compiled_api.d.ts src/data/compiled_api.js | ||
``` | ||
2. Replace the static js file with the version without comments. | ||
```bash | ||
$ node_modules/protobufjs/bin/pbjs -t static-module -w commonjs -o src/data/compiled_api.js --no-create --no-encode --no-verify --no-convert --no-delimited --no-beautify --no-comments src/data/api.proto | ||
``` |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
231
630047
14623