From fe33a68324671528b31d1bd9f20ad335316593e1 Mon Sep 17 00:00:00 2001 From: Huy Le Nguyen Date: Wed, 15 May 2024 00:32:51 +0700 Subject: [PATCH] chore: update docs --- .github/workflows/wiki-publish.yml | 3 +-- README.md | 33 +++++------------------------- docs/tutorials/tflite.md | 12 +++++++++++ 3 files changed, 18 insertions(+), 30 deletions(-) create mode 100644 docs/tutorials/tflite.md diff --git a/.github/workflows/wiki-publish.yml b/.github/workflows/wiki-publish.yml index 53b5880b64..ca7f6f4ab5 100644 --- a/.github/workflows/wiki-publish.yml +++ b/.github/workflows/wiki-publish.yml @@ -14,7 +14,6 @@ jobs: - uses: actions/checkout@v4.1.4 - uses: nglehuy/github-wiki-action@master with: - strategy: clone token: ${{ secrets.TOKEN }} - path: ./ + path: docs preprocess: true diff --git a/README.md b/README.md index 15b8d80fd8..013b337590 100755 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@

-

TensorFlowASR :zap:

+TensorFlowASR :zap: +

GitHub @@ -10,9 +11,8 @@ PyPI

-

-

Almost State-of-the-art Automatic Speech Recognition in Tensorflow 2

+Almost State-of-the-art Automatic Speech Recognition in Tensorflow 2

@@ -161,32 +161,9 @@ See [augmentations](./tensorflow_asr/augmentations/README.md) After converting to tflite, the tflite model is like a function that transforms directly from an **audio signal** to **unicode code points**, then we can convert unicode points to string. -1. Install `tf-nightly` using `pip install tf-nightly` -2. Build a model with the same architecture as the trained model _(if model has tflite argument, you must set it to True)_, then load the weights from trained model to the built model -3. Load `TFSpeechFeaturizer` and `TextFeaturizer` to model using function `add_featurizers` -4. Convert model's function to tflite as follows: - -```python -func = model.make_tflite_function(**options) # options are the arguments of the function -concrete_func = func.get_concrete_function() -converter = tf.lite.TFLiteConverter.from_concrete_functions([concrete_func]) -converter.experimental_new_converter = True -converter.optimizations = [tf.lite.Optimize.DEFAULT] -converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS, - tf.lite.OpsSet.SELECT_TF_OPS] -tflite_model = converter.convert() -``` - -5. Save the converted tflite model as follows: - -```python -if not os.path.exists(os.path.dirname(tflite_path)): - os.makedirs(os.path.dirname(tflite_path)) -with open(tflite_path, "wb") as tflite_out: - tflite_out.write(tflite_model) -``` +See [tflite_convertion](./docs/tutorials/tflite.md) -5. Then the `.tflite` model is ready to be deployed +1. Then the `.tflite` model is ready to be deployed ## Pretrained Models diff --git a/docs/tutorials/tflite.md b/docs/tutorials/tflite.md new file mode 100644 index 0000000000..1f2d31cc3f --- /dev/null +++ b/docs/tutorials/tflite.md @@ -0,0 +1,12 @@ +# TFLite Conversion Tutorial + +## Run + +```bash +python examples/train.py \ + --config-path=/path/to/config.yml.j2 \ + --h5=/path/to/weight.h5 \ + --output=/path/to/output.tflite +## See others params +python examples/tflite.py --help +``` \ No newline at end of file