Skip to content

About

Fast bitmap to tensor conversion

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

tensor-bolt

About

A lightning fast bitmap to tensor conversion library for Android.

In time-critical scenarios, per-pixel normalization and channel reordering can determine whether a computer-vision pipeline runs in real time. Tensor Bolt accelerates these operations by performing them in parallel using NEON or SSE intrinsics.

Designed to work seamlessly with the most popular mobile machine-learning frameworks, this lightweight library delivers up to 10× faster bitmap-to-tensor conversions, helping you optimize performance in ML-powered apps with minimal overhead.

Getting Started

import com.laoluani.tensorbolt.TensorBolt
import android.graphics.Bitmap

  private val rgbConverter = TensorBolt.rgbFloat32Converter(WIDTH, HEIGHT)
  
  val bitmap: Bitmap = // Your bitmap
  val tensorBuffer: ByteBuffer = rgbConverter.convert(bitmap)
  // Convert buffer into native type for respective ML framework
  // For max performance use a zero copy conversion method

Install SDK

You need to build the AAR for this library locally and then add the build artifact a as a local dependency

  1. Clone repo Tensor Bolt repo

    git clone git@github.com:laoluani/tensor-bolt.git
  2. Build Tensor Bolt AAR

    cd tensor-bolt
    ./gradlew tensor-bolt:assembleRelease
  3. Copy build artifact into your projects local dependencies folder, artifact can be found in tensor-bolt/tensor-bolt/build/outputs/aar/tensor-bolt-release.aar

  4. Now in your Android project add Tensor Bolt as a local dependency

    dependencies {
        implementation(files("libs/tensor-bolt-release.aar"))
    }
  5. Sync and build your project

Compatibility

Framework / Toolkit Android Support
TensorFlow Lite ✅ Supported
PyTorch Mobile ✅ Supported
ONNX Runtime Mobile ✅ Supported
Lite RT ✅ Supported
ExecuTorch ✅ Supported

Requirements

Min SDK Android 21 (Lollipop)

Features

  • Bitmap to float32 normalisation
  • Bitmap to gray scale

About

Fast bitmap to tensor conversion

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages