# Getting started
**TensorFlow.js converter** is an open source library to load a pretrained
TensorFlow
[SavedModel](https://www.tensorflow.org/guide/saved_model)
or [TensorFlow Hub module](https://www.tensorflow.org/hub/)
into the browser and run inference through
[TensorFlow.js](https://js.tensorflow.org).
__Note__: _Session bundle format have been deprecated.
A 2-step process to import your model:
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/graph_model.ts), for loading and running
inference.
## Step 1: Converting a [TensorFlow SavedModel](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/saved_model/README.md), [TensorFlow Hub module](https://www.tensorflow.org/hub/), [Keras HDF5](https://keras.io/getting_started/faq/#what-are-my-options-for-saving-models), [tf.keras SavedModel](https://www.tensorflow.org/api_docs/python/tf/keras/saving/save_model), or [Flax/JAX model](http://github.com/google/flax) to a web-friendly format
__0. Please make sure that you run in a Docker container or a virtual environment.__
The script pulls its own subset of TensorFlow, which might conflict with the
existing TensorFlow/Keras installation.
__Note__: *Check that [`tf-nightly-cpu-2.0-preview`](https://pypi.org/project/tf-nightly-cpu-2.0-preview/#files) is available for your platform.*
Most of the times, this means that you have to use Python 3.6.8 in your local
environment. To force Python 3.6.8 in your local project, you can install
[`pyenv`](https://github.com/pyenv/pyenv) and proceed as follows in the target
directory:
```bash
pyenv install 3.6.8
pyenv local 3.6.8
```
Now, you can
[create and activate](https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/)
a `venv` virtual environment in your current folder:
```bash
virtualenv --no-site-packages venv
. venv/bin/activate
```
__1. Install the TensorFlow.js pip package:__
Install the library with interactive CLI:
```bash
pip install tensorflowjs[wizard]
```
__2. Run the converter script provided by the pip package:__
There are three way to trigger the model conversion, explain below:
- The conversion wizard: `tensorflowjs_wizard` ([go to section](https://github.com/tensorflow/tfjs/blob/master/tfjs-converter/README.md#conversion-wizard-tensorflowjs_wizard))
- Regular conversion script: `tensorflowjs_converter` ([go to section](https://github.com/tensorflow/tfjs/tree/master/tfjs-converter#regular-conversion-script-tensorflowjs_converter))
- Calling a converter function in Python (Flax/JAX) ([go to section](https://github.com/tensorflow/tfjs/tree/master/tfjs-converter#calling-a-converter-function-in-python-flaxjax))
## Conversion wizard: `tensorflowjs_wizard`
To start the conversion wizard:
```bash
tensorflowjs_wizard
```
This tool will walk you through the conversion process and provide you with
details explanations for each choice you need to make. Behind the scene it calls
the converter script (`tensorflowjs_converter`) in pip package. This is the
recommended way to convert a single model.
There is also a dry run mode for the wizard, which will not perform the actual
conversion but only generate the command for `tensorflowjs_converter` command.
This generated command can be used in your own shell script.
Here is an screen capture of the wizard in action. ![wizard](./tensorflowjs_wizard.gif)
```bash
tensorflowjs_wizard --dryrun
```
To convert a batch of models or integrate the conversion process into your own
script, you should use the tensorflowjs_converter script.
## Regular conversion script: `tensorflowjs_converter`
The converter expects a __TensorFlow SavedModel__, __TensorFlow Hub module__,
__TensorFlow.js JSON__ format, __Keras HDF5 model__, or __tf.keras SavedModel__
for input.
* __TensorFlow SavedModel__ example:
```bash
tensorflowjs_converter \
--input_format=tf_saved_model \
--output_format=tfjs_graph_model \
--signature_name=serving_default \
--saved_model_tags=serve \
/mobilenet/saved_model \
/mobilenet/web_model
```
* __TensorFlow Frozen Model__ example:
__Note:__ Frozen model is a deprecated format and support is added for backward compatibility purpose.
```bash
$ tensorflowjs_converter \
--input_format=tf_frozen_model \
--output_node_names='MobilenetV1/Predictions/Reshape_1' \
/mobilenet/frozen_model.pb \
/mobilenet/web_model
```
* __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
```
* __Keras HDF5 model__ example:
```bash
tensorflowjs_converter \
--input_format=keras \
/tmp/my_keras_model.h5 \
/tmp/my_tfjs_model
```
* __tf.keras SavedModel__ example:
```bash
tensorflowjs_converter \
--input_format=keras_saved_model \
/tmp/my_tf_keras_saved_model/1542211770 \
/tmp/my_tfjs_model
```
Note that the input path used above is a subfolder that has a Unix epoch
time (1542211770) and is generated automatically by tensorflow when it
saved a tf.keras model in the SavedModel format.
### Conversion Flags
|Positional Arguments | Description |
|---|---|
|`input_path` | Full path of the saved model directory or TensorFlow Hub module handle or path.|
|`output_path` | Path for all output artifacts.|
| Options | Description
|---|---|
|`--input_format` | The format of input model, use `tf_saved_model` for SavedModel, `tf_hub` for TensorFlow Hub module, `tfjs_layers_model` for TensorFlow.js JSON format, and `keras` for Keras HDF5. |
|`--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. If there are no tags defined in the saved model, set it to empty string `saved_model_tags=''`. Defaults to `serve`.|
|`--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` | (Deprecated) 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.|
|`--quantize_float16` | Comma separated list of node names to apply float16 quantization. You can also use wildcard symbol (\*) to apply quantization to multiple nodes (e.g., conv/\*/weights). When the flag is provided without any nodes the default behavior will match all nodes. |
|`--quantize_uint8` | Comma separated list of node names to apply 1-byte affine quantization. You can also use wildcard symbol (\*) to apply quantization to multiple nodes (e.g., conv/\*/weights). When the flag is provided without any nodes the default behavior will match all nodes. |
|`--quantize_uint16` | Comma separated list of node names to apply 2-byte affine quantization. You can also use wildcard symbol (\*) to apply quantization to multiple nodes (e.g., conv/\*/weights). When the flag is provided without any nodes the default behavior will match all nodes. |
|`--weight_shard_size_bytes` | Shard size (in bytes) of the weight files. Only supported when `output_format` is `tfjs_layers_model` or `tfjs_graph_model`. Default size is 4 MB (4194304 bytes).|
|<nobr>`--output
没有合适的资源?快使用搜索试试~ 我知道了~
TensorFlow.js 是一个开源硬件加速 JavaScript 库,用于训练和部署机器学习模型.zip
共2000个文件
ts:1284个
json:172个
js:111个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 66 浏览量
2024-04-29
10:59:44
上传
评论
收藏 24.16MB ZIP 举报
温馨提示
机器学习 机器学习使计算机能够从研究数据和统计信息中学习。 机器学习是迈向人工智能(AI)方向的其中一步。 机器学习是一种程序,可以分析数据并学习预测结果。 从何处开始? 在本教程中,我们将回到数学并研究统计学,以及如何根据数据集计算重要数值。 我们还将学习如何使用各种 Python 模块来获得所需的答案。 并且,我们将学习如何根据所学知识编写能够预测结果的函数。 数据集 在计算机中,数据集指的是任何数据集合。它可以是从数组到完整数据库的任何内容。 通过查看数据库,我们可以看到最受欢迎的颜色是白色,最老的车龄是 17 年,但是如果仅通过查看其他值就可以预测汽车是否具有 AutoPass,该怎么办? 这就是机器学习的目的!分析数据并预测结果! 在机器学习中,通常使用非常大的数据集。在本教程中,我们会尝试让您尽可能容易地理解机器学习的不同概念,并将使用一些易于理解的小型数据集。 数据类型 如需分析数据,了解我们要处理的数据类型非常重要。 我们可以将数据类型分为三种主要类别: 数值(Numerical) 分类(Categorical) 序数(Ordinal) 数值数据是数字,可以分为两种数值
资源推荐
资源详情
资源评论
收起资源包目录
TensorFlow.js 是一个开源硬件加速 JavaScript 库,用于训练和部署机器学习模型.zip (2000个子文件)
.babelrc 132B
gradlew.bat 3KB
BUILD.bazel 10KB
BUILD.bazel 7KB
BUILD.bazel 5KB
BUILD.bazel 5KB
BUILD.bazel 5KB
BUILD.bazel 4KB
BUILD.bazel 4KB
BUILD.bazel 3KB
BUILD.bazel 3KB
BUILD.bazel 3KB
BUILD.bazel 3KB
BUILD.bazel 3KB
BUILD.bazel 3KB
BUILD.bazel 3KB
BUILD.bazel 3KB
BUILD.bazel 2KB
BUILD.bazel 2KB
BUILD.bazel 2KB
BUILD.bazel 2KB
BUILD.bazel 2KB
BUILD.bazel 1KB
BUILD.bazel 988B
BUILD.bazel 832B
BUILD.bazel 799B
BUILD.bazel 529B
BUILD.bazel 262B
.bazelignore 510B
group1-shard2of3.bin 4MB
group1-shard1of3.bin 4MB
group1-shard1of2.bin 4MB
group1-shard2of2.bin 3.48MB
group1-shard3of3.bin 982KB
weights.bin 9KB
group1-shard1of1.bin 44B
bundle_model_test_weights.bin 44B
weights.bin 16B
weights.bin 16B
group1-shard1of1.bin 8B
BUCK 1KB
BUCK 152B
.buckconfig 114B
tfjs_bundle.bzl 7KB
tfjs_web_test.bzl 6KB
copy_to_dist.bzl 4KB
defaults.bzl 2KB
tflite_repositories.bzl 2KB
gen_op.bzl 2KB
get_extension.bzl 2KB
enumerate_tests.bzl 2KB
tfdf_repositories.bzl 2KB
kernels_to_ops.bzl 2KB
make_version_test_file.bzl 1KB
build_defs.bzl 1KB
setup.cfg 40B
tfjs.code-workspace 3KB
tufte.css 9KB
tufte.css 9KB
main.css 4KB
main.css 3KB
main.css 1KB
index.css 734B
Dockerfile 1KB
Dockerfile 337B
tensorflowjs_wizard.gif 521KB
.gitattributes 16B
.gitignore 952B
build.gradle 7KB
build.gradle 2KB
settings.gradle 1KB
gradlew 6KB
utils.h 12KB
conv3d_impl.h 8KB
pool3d_impl.h 7KB
dilation2d_impl.h 6KB
util.h 6KB
tfjs_backend.h 4KB
binary.h 4KB
backend.h 3KB
unary.h 3KB
shape.h 2KB
argminmax_impl.h 2KB
napi_auto_ref.h 2KB
FusedConv2D.h 2KB
conv2d_impl.h 2KB
FusedDepthwiseConv2D.h 2KB
bincount_impl.h 2KB
Conv2D.h 1KB
non_max_suppression_impl.h 1KB
DepthwiseConv2dNative.h 1KB
interpolate_bilinear_impl.h 1KB
MaxPool.h 1KB
batch_mat_mul_impl.h 1KB
_FusedMatMul.h 1KB
AvgPool.h 1KB
scatter_impl.h 1KB
ResizeNearestNeighbor.h 1KB
BatchMatMul.h 1KB
PadV2.h 1KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
野生的狒狒
- 粉丝: 2353
- 资源: 2099
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 7777端口抓包数据集
- IMG_0694.GIF
- 基于图像的三维模型重建C++源代码+文档说明(高分课程设计)
- 基于聚焦法的工件立体测量方案,根据数据进行三维重建 使用HALCON处理图像,MATLAB拟合数据+源代码+数据集+效果图
- 锄战三国村 修改:货币使用不减 v1.10(2) 原创 (中文).apk
- 基于python实现的单目双目视觉三维重建+源代码+图像图片(高分课程设计)
- 基于C+++OPENCV的全景图像拼接源码(课程设计)
- 基于Python+OpenCV对多张图片进行全景图像拼接,消除鬼影,消除裂缝+源代码+文档说明+界面截图(高分课程设计)
- 基于C++实现的全景图像拼接源码(课程设计)
- 基于SIFT特征点提取和RASIC算法实现全景图像拼接python源码+文档说明+界面截图+详细注释(95分以上课程大作业)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功