tensorflow_lite
Version, currently 2.2.121 versions
- 2.2.1latestJun 7, 2024
- 2.2.0not indexedJun 7, 2024
- 2.1.3not indexedJun 7, 2024
- 2.1.1not indexedJun 7, 2024
- 2.1.0not indexedJun 7, 2024
- 2.0.0not indexedJun 7, 2024
- 1.6.4not indexedJun 7, 2024
- 1.6.3not indexedJun 7, 2024
- 1.6.2not indexedJun 7, 2024
- 1.6.1not indexedJun 7, 2024
- 1.6.0not indexedJun 7, 2024
- 1.5.0not indexedJun 7, 2024
- 1.4.0not indexedJun 7, 2024
- 1.2.2not indexedJun 7, 2024
- 1.2.1not indexedJun 7, 2024
- 1.2.0not indexedJun 7, 2024
- 1.1.0not indexedJun 7, 2024
- 1.0.0not indexedJun 7, 2024
- 0.9.2not indexedJun 7, 2024
- 0.9.1not indexedJun 7, 2024
- 0.9.0not indexedJun 7, 2024
github.com/spider-gazelle/tensorflow_lite
tensorflow lite bindings for crystal lang
Installation
# Add this to your shard.yml
dependencies:
tensorflow_lite:
github: spider-gazelle/tensorflow_lite
version: ~> 2.2.1Then run:
shards installshard.yml
- Crystal
- no constraint declared
- License
- MIT
- Author
- Stephen von Takach
Dependencies
Development Dependencies
- ameba*github: veelenga/amebadev
README
tensorflow_lite
A library for running TF Lite models
- once you've trained a model in TensorFlow you can convert it to TF Lite for production use
- inspect the TF Lite model using netron.app
- some good TF models for object detection (need conversion)
Also see the project documentation
Installation
-
Add the dependency to your
shard.yml:dependencies: tensorflow_lite: github: spider-gazelle/tensorflow_lite -
Run
shards install
Usage
See the specs for basic usage or have a look at imagine
require "tensorflow_lite"
you can use the example metadata extractor to obtain the metadata for TF Lite models downloaded from tfhub.dev
With and EdgeTPU
Such as a Coral USB device
require "tensorflow_lite/edge_tpu"
To install the edge tpu delegate:
# Add Google Cloud public key
RUN wget -q -O - https://packages.cloud.google.com/apt/doc/apt-key.gpg | gpg --dearmor > /etc/apt/trusted.gpg.d/coral-edgetpu.gpg
# Add Coral packages repository
RUN echo "deb [signed-by=/etc/apt/trusted.gpg.d/coral-edgetpu.gpg] https://packages.cloud.google.com/apt coral-edgetpu-stable main" | tee /etc/apt/sources.list.d/coral-edgetpu.list
# install the lib
sudo apt update
sudo apt install libedgetpu-dev
To install the Coral USB drivers
sudo apt install libedgetpu1-std
# OR for max frequency
sudo apt install libedgetpu1-max
# unplug and re-plug the coral or run this
sudo systemctl restart udev
NOTE:: when using a coral and running lsusb you need to look for either:
- Global Unichip Corp.
- Google Inc.
after running something on the chip it will change identity to Google Inc.
And you need to include the Google identity version in any docker files.
Development
To update tensorflow lite bindings ./generate_bindings.sh
lib installation
Dockerfile
The dockerfile is used to build a compatible tensorflow build for target platforms.
There is an image pre-built at docker pull stakach/tensorflowlite:latest
To build an image run:
docker buildx build --progress=plain --platform linux/arm64,linux/amd64 -t stakach/tensorflowlite:latest --push .
to extract the libraries
mkdir -p ./ext
docker pull stakach/tensorflowlite:latest
docker create --name tflite_tmp stakach/tensorflowlite:latest true
docker cp tflite_tmp:/usr/local/lib/libedgetpu.so ./ext/libedgetpu.so
docker cp tflite_tmp:/usr/local/lib/libtensorflowlite_c.so ./ext/libtensorflowlite_c.so
docker cp tflite_tmp:/usr/local/lib/libtensorflowlite_gpu_delegate.so ./ext/libtensorflowlite_gpu_delegate.so
docker rm tflite_tmp
this operation is performed post-install by this library
Old method
Requires libtensorflow to be installed, this is handled automatically by ./build_tensorflowlite.sh
- there is a guide to building it
- you can use
./build_tensorflowlite.shto automate this - then requires
export LD_LIBRARY_PATH=/usr/local/libto run - test if installed successfully
crystal ./src/tensorflow_lite.cr- this will output
Launching with tensorflow lite vx.x.x
- this will output
NOTE:: the lib is installed for local use via a postinstall script.
Make sure to distribute libtensorflowlite_c.so with your production app
Contributing
- Fork it (https://github.com/your-github-user/tensorflow_lite/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Contributors
- Stephen von Takach - creator and maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
2.2.1- Tagged
- Jun 7, 2024
- Commit
4a49ba99cffd- Indexed
- yes
Dependents
Repository
github.com/spider-gazelle/tensorflow_lite
Metadata
- Created
- Aug 12, 2026
- Updated
- Sep 30, 2026
- Synced
- Sep 30, 2026
- Versions
- 21