All Projects → jpuigcerver → Pytorch Baidu Ctc

jpuigcerver / Pytorch Baidu Ctc

Licence: apache-2.0
PyTorch bindinga for Baidu's Warp-CTC

Programming Languages

shell
77523 projects

Projects that are alternatives of or similar to Pytorch Baidu Ctc

Slic cuda
Superpixel SLIC for GPU (CUDA)
Stars: ✭ 45 (-26.23%)
Mutual labels:  cuda
3d Ken Burns
an implementation of 3D Ken Burns Effect from a Single Image using PyTorch
Stars: ✭ 1,073 (+1659.02%)
Mutual labels:  cuda
Cme213 material 2013
CME 213 Class Material
Stars: ✭ 57 (-6.56%)
Mutual labels:  cuda
Hornet
Hornet data structure for sparse dynamic graphs and matrices
Stars: ✭ 49 (-19.67%)
Mutual labels:  cuda
Pamtri
PAMTRI: Pose-Aware Multi-Task Learning for Vehicle Re-Identification (ICCV 2019) - Official PyTorch Implementation
Stars: ✭ 53 (-13.11%)
Mutual labels:  cuda
Hzproc
torch data augmentation toolbox (supports affine transform)
Stars: ✭ 56 (-8.2%)
Mutual labels:  cuda
Docs Pytorch
Deep Object Co-Segmentation
Stars: ✭ 43 (-29.51%)
Mutual labels:  cuda
Flattened Cnn
Flattened convolutional neural networks (1D convolution modules for Torch nn)
Stars: ✭ 59 (-3.28%)
Mutual labels:  cuda
Deformable conv2d pytorch
deformable_conv2d layer implemented in pytorch
Stars: ✭ 53 (-13.11%)
Mutual labels:  cuda
Heteroflow
Concurrent CPU-GPU Programming using Task Models
Stars: ✭ 57 (-6.56%)
Mutual labels:  cuda
Cs344
Introduction to Parallel Programming class code
Stars: ✭ 1,051 (+1622.95%)
Mutual labels:  cuda
Carlsim3
CARLsim is an efficient, easy-to-use, GPU-accelerated software framework for simulating large-scale spiking neural network (SNN) models with a high degree of biological detail.
Stars: ✭ 52 (-14.75%)
Mutual labels:  cuda
Nvbio Gpl
NVBIO is a library of reusable components designed to accelerate bioinformatics applications using CUDA.
Stars: ✭ 56 (-8.2%)
Mutual labels:  cuda
Singularity Tutorial
Tutorial for using Singularity containers
Stars: ✭ 46 (-24.59%)
Mutual labels:  cuda
Dokai
Collection of Docker images for ML/DL and video processing projects
Stars: ✭ 58 (-4.92%)
Mutual labels:  cuda
Lyra
Stars: ✭ 43 (-29.51%)
Mutual labels:  cuda
Dink
点云深度学习框架 | Point cloud Deep learning Framework
Stars: ✭ 56 (-8.2%)
Mutual labels:  cuda
Optix Path Tracer
OptiX Path Tracer
Stars: ✭ 60 (-1.64%)
Mutual labels:  cuda
Pytorch knn cuda
K-Nearest Neighbor in Pytorch
Stars: ✭ 59 (-3.28%)
Mutual labels:  cuda
Cuda Samples
Samples for CUDA Developers which demonstrates features in CUDA Toolkit
Stars: ✭ 1,087 (+1681.97%)
Mutual labels:  cuda

torch-baidu-ctc

Build Status

Pytorch bindings for Baidu's Warp-CTC. These bindings were inspired by SeanNaren's but these include some bug fixes, and offer some additional features.

import torch
from torch_baidu_ctc import ctc_loss, CTCLoss

# Activations. Shape T x N x D.
# T -> max number of frames/timesteps
# N -> minibatch size
# D -> number of output labels (including the CTC blank)
x = torch.rand(10, 3, 6)
# Target labels
y = torch.tensor(
  [
    # 1st sample
    1, 1, 2, 5, 2,
    # 2nd
    1, 5, 2,
    # 3rd
    4, 4, 2, 3,
  ],
  dtype=torch.int,
)
# Activations lengths
xs = torch.tensor([10, 6, 9], dtype=torch.int)
# Target lengths
ys = torch.tensor([5, 3, 4], dtype=torch.int)

# By default, the costs (negative log-likelihood) of all samples are summed.
# This is equivalent to:
#   ctc_loss(x, y, xs, ys, average_frames=False, reduction="sum")
loss1 = ctc_loss(x, y, xs, ys)

# You can also average the cost of each sample among the number of frames.
# The averaged costs are then summed.
loss2 = ctc_loss(x, y, xs, ys, average_frames=True)

# Instead of summing the costs of each sample, you can perform
# other `reductions`: "none", "sum", or "mean"
#
# Return an array with the loss of each individual sample
losses = ctc_loss(x, y, xs, ys, reduction="none")
#
# Compute the mean of the individual losses
loss3 = ctc_loss(x, y, xs, ys, reduction="mean")
#
# First, normalize loss by number of frames, later average losses
loss4 = ctc_loss(x, y, xs, ys, average_frames=True, reduction="mean")


# Finally, there's also a nn.Module to use this loss.
ctc = CTCLoss(average_frames=True, reduction="mean", blank=0)
loss4_2 = ctc(x, y, xs, ys)

# Note: the `blank` option is also available for `ctc_loss`.
# By default it is 0.

Requirements

  • C++11 compiler (tested with GCC 4.9).
  • Python: 2.7, 3.5, 3.6, 3.7 (tested with versions 2.7, 3.5 and 3.6).
  • PyTorch >= 1.1.0 (tested with version 1.1.0).
  • For GPU support: CUDA Toolkit.

Installation

The installation process should be pretty straightforward assuming that you have correctly installed the required libraries and tools.

The setup process compiles the package from source, and will compile with CUDA support if this is available for PyTorch.

From Pypi (recommended)

pip install torch-baidu-ctc

From GitHub

git clone --recursive https://github.com/jpuigcerver/pytorch-baidu-ctc.git
cd pytorch-baidu-ctc
python setup.py build
python setup.py install

AVX512 related issues

Some compiling problems may arise when using CUDA and newer host compilers with AVX512 instructions. Please, install GCC 4.9 and use it as the host compiler for NVCC. You can simply set the CC and CXX environment variables before the build/install commands:

CC=gcc-4.9 CXX=g++-4.9 pip install torch-baidu-ctc

or (if you are using the GitHub source code):

CC=gcc-4.9 CXX=g++-4.9 python setup.py build

Testing

You can test the library once installed using unittest. In particular, run the following commands:

python -m unittest torch_baidu_ctc.test

All tests should pass (CUDA tests are only executed if supported).

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].