Skip to content

An extension of thu-spmi/CAT which contains a full-fledged implementation of CTC-CRF for Tensorflow.

Notifications You must be signed in to change notification settings

TeaPoly/warp-ctc-crf

Repository files navigation

warp-ctc-crf

TensorFlow binding for CTC-CRF. An extension of thu-spmi/CAT for Tensorflow.

Introduction

This is a modified version of thu-spmi/CAT. I just modify the code to the new CPP Extensions API style of Tensorflow and refact the gpu_den code.

Requirements

Installation

Because CTC-CRF operator is based on CUDA Toolkit, so you should setting CUDA environment. For details, you can follow this link or TensorFlow official link.

  1. Install CUDA Toolkit
  • Follow this link to download and install CUDA Toolkit for your Linux distribution.
  • Installation instructions can be found here
  1. Environment Setup

    Append the following lines to ~/.bashrc or ~/.zshrc.

    export PATH=/usr/local/cuda-10.0/bin${PATH:+:${PATH}}
    export LD_LIBRARY_PATH=/usr/local/cuda-10.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
  2. Install TensorFlow with Anaconda virtual environment

    Create a virtual environment is recommended. You can choose Conda or venv. Here I use Conda as an example.

    # Install TensorFlow/cuda/nvcc first, reference is here:
    conda create --name tf pip python==3.7
    conda activate tf
    conda install tensorflow-gpu==1.15.0
  3. Install CTC-CRF TensorFlow wrapper

    setting your TENSORFLOW_SRC_PATH and OPENFST.

    NOTE: This is an example, please don't simply copy to your terminal:

    # Create a symlink libtensorflow_framework.so.1 which references the original file  libtensorflow_framework.so
    ln -s /home/huanglk/anaconda3_202002/envs/tf_subcomp/lib/python3.7/site-packages/tensorflow_core/libtensorflow_framework.so.1 /home/huanglk/anaconda3_202002/envs/tf_subcomp/lib/python3.7/site-packages/tensorflow_core/libtensorflow_framework.so
    
    # export TENSORFLOW_SRC_PATH
    export TENSORFLOW_SRC_PATH=/home/huanglk/anaconda3_202002/envs/tf_subcomp/lib/python3.7/site-packages/tensorflow_core/
    
    # export OPENFST
    export OPENFST=/usr/local/
    • It will compile three modules with gcc/g++, include GPUCTC, PATHWEIGHT and GPUDEN.
    • It is worth mentioning that if the version of gcc/g++ >= 5.0.0 and less than 6.0.0 will be helpful for following pipeline.
    • Finally, Makefile will exetucate python3 ./setup.py install for CTC-CRF TensorFlow wrapper.

    Now, you can install CTC-Crf TensorFlow wrapper warp-ctc-crf.

    # Install warp_ctc_crf
    cd warp_ctc_crf
    make -j 32

Contents

  • Test:

    • tests/test_ctc_crf_op.py is a simple test for Tensorflow API for CAT.
  • Tensorflow API:

    • setup.py: ctc_crf_loss setup script. It only test in g++ 5.0+ and Tensorflow 1.14.0
    • ctc_crf_op_kernel.cc: Tensorflow C++ binding.
    • ctc_crf_tensorflow/__init__.py: Tensorflow API for ctc_crf_loss.
  • Others:

References

CAT. https://github.com/thu-spmi/CAT.

About

An extension of thu-spmi/CAT which contains a full-fledged implementation of CTC-CRF for Tensorflow.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published