Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
CrazyChaoz committed Nov 25, 2024
1 parent efd15da commit 395d9cc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 113 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@
This crates provides TensorFlow Lite APIs.
Please read the [`API documentation on docs.rs`](https://docs.rs/crate/tflite)

# Compatibility

This fork is only tested with
- a prebuilt `libtensorflowlite.so`
- tensorflow `v2.13.0`
- flatbuffers `v23.1.21`

For a working example check out the nix devshell using `nix develop`

### Using the interpreter from a model file

The following example shows how to use the TensorFlow Lite interpreter when provided a TensorFlow Lite FlatBuffer file.
Expand Down
60 changes: 0 additions & 60 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 4 additions & 53 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,80 +1,31 @@
{
inputs = {
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
naersk = {
url = "github:nix-community/naersk";
inputs.nixpkgs.follows = "nixpkgs";
};
nixpkgs.url = "nixpkgs/nixos-unstable";
utils = {
url = "github:numtide/flake-utils";
};
};

outputs = { self, naersk, fenix, nixpkgs, utils }:
outputs = { self, nixpkgs, utils }:
utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };

fixed-tensorflow-lite = (pkgs.tensorflow-lite).overrideAttrs (self: super: { meta.knownVulnerabilities = [ ]; });


stdenv = pkgs.clangStdenv;

toolchain = with fenix.packages.${system}; combine [
minimal.cargo
minimal.rustc
];
pname = "tflite-rs";

renamed_tflite = stdenv.mkDerivation {
name = "renamed_tflite";
src = fixed-tensorflow-lite;
buildPhase = ''
mkdir $out/
mkdir $out/lib/
# Copy everything except for specific files in lib/
cp -r $src/* $out/
# Rename specific files in lib/
if [ -d $out/lib ]; then
# Rename libtensorflowlite_c.so to libtensorflow-lite_c.so
if [ -f $out/lib/libtensorflowlite_c.so ]; then
cp $out/lib/libtensorflowlite_c.so $out/lib/libtensorflow-lite_c.so
fi
# Rename libtensorflowlite.so to libtensorflow-lite.so
if [ -f $out/lib/libtensorflowlite.so ]; then
cp $out/lib/libtensorflowlite.so $out/lib/libtensorflow-lite.so
fi
fi
'';
};

in
{
devShell = pkgs.mkShell {
TFLITE_X86_64_LIB_DIR = "${fixed-tensorflow-lite}/lib";
TFLITE_LIB_DIR = "${fixed-tensorflow-lite}/lib";
TFLITE_X86_64_LIB_DIR = "${pkgs.tensorflow-lite}/lib";
TFLITE_LIB_DIR = "${pkgs.tensorflow-lite}/lib";
LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
buildInputs = with pkgs;[
clang
llvmPackages.libclang.lib
];
nativeBuildInputs = with pkgs; [
rustc
cargo
fixed-tensorflow-lite
tensorflow-lite
pkg-config
opencv
perl
clang
libclang
vtk
rustPlatform.bindgenHook
];
};
Expand Down

0 comments on commit 395d9cc

Please sign in to comment.