Git Product home page Git Product logo

kaldi-onnx-tf's Introduction

Kaldi-ONNX-Tensorflow Converter

Build Status

This is a tool for converting Kaldi model to onnx / tensorflow model for inference based on XiaoMi's Kaldi-ONNX project.

Background

XiaoMi's project can convert Kaldi model to onnx model. Usually, onnx model can be easily used for inference using ONNX Runtime toolkit, or convert to tensorflow model using ONNX-TF toolkit.

However, XiaoMi's implementation of converted onnx node can only support MACE framework.

Based on their project, Kaldi node is implemented using common onnx node, so that it can be easily used for inference.

Support

The inference of Kaldi's most popular TDNN-F networks in nnet3 is supported.

Usage

1. Environment

python3.6.8

2. Dependencies

pip3 install -r requirements.txt

3. Model Preparation

This tool only supports Kaldi's text model as an input.

If you have a binary model, Kaldi's nnet3-copy tool can help you get a text one:

kaldi/src/nnet3bin/nnet3-copy --binary=false --prepare-for-test=true <final.mdl> <final.txt>

Don't forget to use the --prepare-for-test=true option.

Before converting, you need to use kaldi/src/nnet3bin/nnet3-am-info <final.mdl> to get left_context and right_context, which is required for converting.

4. Convert

python3 -m converter.converter <input_kaldi_nnet3_file> <left_context> <right_context> <out_model_file> [--format <format>] [--chunk_size <chunk_size>]

--format: 'onnx' - default, output onnx model, 'tf' - output tensorflow pb model.

--chunk_size: using 21 as default chunk size. Subsample_factor is 3, input 21 frames feature, then 7 frames will be output for decoding.

5. Test

See tests for how to use pb model.

model1 use the model struct from swbd/tdnn_7p.

model2 use the model struct from swbd/tdnn_7q.

6. Graph review

After converting, there is a graphic tool for you to review the onnx model: ONNX Model Viewer.

Acknowledgement

kaldi-onnx-tf's People

Contributors

tonymou avatar llhe avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.