Rust bindings for TensorFlow Lite

Overview

Build Status

Rust bindings for TensorFlow Lite

This crates provides TensorFlow Lite APIs. Please read the API documentation on docs.rs

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. The example also demonstrates how to run inference on input data.

use std::fs::{self, File};
use std::io::Read;

use tflite::ops::builtin::BuiltinOpResolver;
use tflite::{FlatBufferModel, InterpreterBuilder, Result};

fn test_mnist(model: &FlatBufferModel) -> Result<()> {
    let resolver = BuiltinOpResolver::default();

    let builder = InterpreterBuilder::new(model, &resolver)?;
    let mut interpreter = builder.build()?;

    interpreter.allocate_tensors()?;

    let inputs = interpreter.inputs().to_vec();
    assert_eq!(inputs.len(), 1);

    let input_index = inputs[0];

    let outputs = interpreter.outputs().to_vec();
    assert_eq!(outputs.len(), 1);

    let output_index = outputs[0];

    let input_tensor = interpreter.tensor_info(input_index).unwrap();
    assert_eq!(input_tensor.dims, vec![1, 28, 28, 1]);

    let output_tensor = interpreter.tensor_info(output_index).unwrap();
    assert_eq!(output_tensor.dims, vec![1, 10]);

    let mut input_file = File::open("data/mnist10.bin")?;
    for i in 0..10 {
        input_file.read_exact(interpreter.tensor_data_mut(input_index)?)?;

        interpreter.invoke()?;

        let output: &[u8] = interpreter.tensor_data(output_index)?;
        let guess = output.iter().enumerate().max_by(|x, y| x.1.cmp(y.1)).unwrap().0;

        println!("{}: {:?}", i, output);
        assert_eq!(i, guess);
    }
    Ok(())
}

#[test]
fn mobilenetv1_mnist() -> Result<()> {
    test_mnist(&FlatBufferModel::build_from_file("data/MNISTnet_uint8_quant.tflite")?)?;

    let buf = fs::read("data/MNISTnet_uint8_quant.tflite")?;
    test_mnist(&FlatBufferModel::build_from_buffer(buf)?)
}

#[test]
fn mobilenetv2_mnist() -> Result<()> {
    test_mnist(&FlatBufferModel::build_from_file("data/MNISTnet_v2_uint8_quant.tflite")?)?;

    let buf = fs::read("data/MNISTnet_v2_uint8_quant.tflite")?;
    test_mnist(&FlatBufferModel::build_from_buffer(buf)?)
}

Using the FlatBuffers model APIs

This crate also provides a limited set of FlatBuffers model APIs.

use tflite::model::stl::vector::{VectorInsert, VectorErase, VectorSlice};
use tflite::model::{BuiltinOperator, BuiltinOptions, Model, SoftmaxOptionsT};

#[test]
fn flatbuffer_model_apis_inspect() {
    let model = Model::from_file("data/MNISTnet_uint8_quant.tflite").unwrap();
    assert_eq!(model.version, 3);
    assert_eq!(model.operator_codes.size(), 5);
    assert_eq!(model.subgraphs.size(), 1);
    assert_eq!(model.buffers.size(), 24);
    assert_eq!(
        model.description.c_str().to_string_lossy(),
        "TOCO Converted."
    );

    assert_eq!(
        model.operator_codes[0].builtin_code,
        BuiltinOperator::BuiltinOperator_AVERAGE_POOL_2D
    );

    assert_eq!(
        model
            .operator_codes
            .iter()
            .map(|oc| oc.builtin_code)
            .collect::<Vec<_>>(),
        vec![
            BuiltinOperator::BuiltinOperator_AVERAGE_POOL_2D,
            BuiltinOperator::BuiltinOperator_CONV_2D,
            BuiltinOperator::BuiltinOperator_DEPTHWISE_CONV_2D,
            BuiltinOperator::BuiltinOperator_SOFTMAX,
            BuiltinOperator::BuiltinOperator_RESHAPE
        ]
    );

    let subgraph = &model.subgraphs[0];
    assert_eq!(subgraph.tensors.size(), 23);
    assert_eq!(subgraph.operators.size(), 9);
    assert_eq!(subgraph.inputs.as_slice(), &[22]);
    assert_eq!(subgraph.outputs.as_slice(), &[21]);

    let softmax = subgraph
        .operators
        .iter()
        .position(|op| {
            model.operator_codes[op.opcode_index as usize].builtin_code
                == BuiltinOperator::BuiltinOperator_SOFTMAX
        })
        .unwrap();

    assert_eq!(subgraph.operators[softmax].inputs.as_slice(), &[4]);
    assert_eq!(subgraph.operators[softmax].outputs.as_slice(), &[21]);
    assert_eq!(
        subgraph.operators[softmax].builtin_options.type_,
        BuiltinOptions::BuiltinOptions_SoftmaxOptions
    );

    let softmax_options: &SoftmaxOptionsT = subgraph.operators[softmax].builtin_options.as_ref();
    assert_eq!(softmax_options.beta, 1.);
}

#[test]
fn flatbuffer_model_apis_mutate() {
    let mut model = Model::from_file("data/MNISTnet_uint8_quant.tflite").unwrap();
    model.version = 2;
    model.operator_codes.erase(4);
    model.buffers.erase(22);
    model.buffers.erase(23);
    model
        .description
        .assign(CString::new("flatbuffer").unwrap());

    {
        let subgraph = &mut model.subgraphs[0];
        subgraph.inputs.erase(0);
        subgraph.outputs.assign(vec![1, 2, 3, 4]);
    }

    let model_buffer = model.to_buffer();
    let model = Model::from_buffer(&model_buffer);
    assert_eq!(model.version, 2);
    assert_eq!(model.operator_codes.size(), 4);
    assert_eq!(model.subgraphs.size(), 1);
    assert_eq!(model.buffers.size(), 22);
    assert_eq!(model.description.c_str().to_string_lossy(), "flatbuffer");

    let subgraph = &model.subgraphs[0];
    assert_eq!(subgraph.tensors.size(), 23);
    assert_eq!(subgraph.operators.size(), 9);
    assert!(subgraph.inputs.as_slice().is_empty());
    assert_eq!(subgraph.outputs.as_slice(), &[1, 2, 3, 4]);
}
Comments
  • Use git submodule

    Use git submodule

    This is a fix for https://github.com/boncheolgu/tflite-rs/issues/6. Because of the way tflite downloads dependencies, the easiest thing to do was to run the download script and commit it to the repository, so that accounts for 99% of lines changed, even though I removed most of the downloaded files like docs and tests. Most of the changes are in Cargo.toml where I removed all of the downloading dependencies. I also removed the feature for docs since this should work now. A build feature was added so that a precompiled libtensorflow-lite can be used without spending all of the time compiling.

    The build.rs was changed a lot, so I ran rustfmt on it. The only command left is the make command and all the other sed commands have been changed to be more portable and hopefully more readable.

    I know this is a large change, and I built it with and without the build and debug features to make sure it works. I'm also happy to move the file structure around if you want it changed.

    opened by tylerhawkes 5
  • Is this maintained?

    Is this maintained?

    Hello - it looks like version 0.9.0 doesn't build correctly because of an issue in build.rs. I can definitely put in some work to get it running, but wanted to know if this is being maintained long term before I do. It looks like it's been broken for several months as is.

    opened by zachChilders 4
  • Size issues when cross compiling

    Size issues when cross compiling

    I am trying to cross compiletflite-rs for a Raspberry Pi board. I am running in the following error. Do you have some pointers on how to make progress?

    error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
       --> src/interpreter.rs:318:17
        |
    318 |                 quantization as "TfLiteQuantizationParams",
        |                 ^^^^^^^^^^^^
        |
        = note: source type: `&bindings::root::TfLiteQuantizationParams` (32 bits)
        = note: target type: `[u8; 8]` (64 bits)
    

    Many thanks!

    opened by winding-lines 4
  • Use define instead of rewriting flatbuffers.h - update TensorFlow to 1.15.5

    Use define instead of rewriting flatbuffers.h - update TensorFlow to 1.15.5

    This uses a patch that introduces a define to makeNativeTable look different do different build steps. This is done to avoid re-writing the actual source code during the build, which prevents the package from building inside Nix.

    Because some dependency of 1.15.2 is no longer available under the original URL this also updates to 1.15.5, which would not be required otherwise. Fixing the URL of that dependency in TensorFlow would also work.

    opened by mschwaig 3
  • Rationale of submodule 'downloads'

    Rationale of submodule 'downloads'

    I would kindly like to ask for the rationale of the downloads submodule. I know that named submodule comprises necessary dependencies as flatbuffers and others. However, these dependencies might also be provisioned in a different way, for example by use of the script tensorflow/lite/tools/make/download_dependencies.sh which is part of Tensorflow's sources. Named script may be called from within the build script. I have a fork of tflite-rs which does this (actually forked from ionosnetworks tflite-rs which is a fork of this project).

    Did you consider different possibilities to provision the dependencies? Did you maybe prefer a provisioning mechanism via a separate submodule like downloads over downloading dependencies directly in the build script? If so, why?

    Thank you very much for your feedback.

    opened by Finfalter 2
  • Making changes necessary for allow for cross compilation

    Making changes necessary for allow for cross compilation

    This should all most cross-compiling to work. I've tested it for aarch64 and it compiles into a binary just fine. When not cross-compiling it still works the same.

    I changed some unwrap() calls to expect() to make it easier to diagnose failures as well.

    opened by tylerhawkes 2
  • Build failing on Mac OS

    Build failing on Mac OS

    Hi,

    the current master branch is failing to build on Mac OS 10.15.7 with the following error:

    (env) nmr@ tflite-rs % cargo build
        Updating crates.io index
       Compiling memchr v2.3.4
       Compiling proc-macro2 v1.0.26
       Compiling unicode-xid v0.2.1
       Compiling syn v1.0.70
       Compiling libc v0.2.94
       Compiling cfg-if v1.0.0
       Compiling glob v0.3.0
       Compiling lazy_static v1.4.0
       Compiling version_check v0.9.3
       Compiling bitflags v1.2.1
       Compiling log v0.4.14
       Compiling regex-syntax v0.6.23
       Compiling unicode-width v0.1.8
       Compiling quick-error v1.2.3
       Compiling vec_map v0.8.2
       Compiling bindgen v0.55.1
       Compiling termcolor v1.1.2
       Compiling if_rust_version v1.0.0
       Compiling strsim v0.8.0
       Compiling ansi_term v0.11.0
       Compiling peeking_take_while v0.1.2
       Compiling lazycell v1.3.0
       Compiling shlex v0.1.1
       Compiling rustc-hash v1.1.0
       Compiling cfg-if v0.1.10
       Compiling cc v1.0.67
       Compiling fs_extra v1.2.0
       Compiling byteorder v1.4.3
       Compiling maybe-owned v0.3.4
       Compiling libloading v0.7.0
       Compiling textwrap v0.11.0
       Compiling humantime v1.3.0
       Compiling nom v5.1.2
       Compiling clang-sys v1.2.0
       Compiling aho-corasick v0.7.15
       Compiling quote v1.0.9
       Compiling atty v0.2.14
       Compiling which v3.1.1
       Compiling clap v2.33.3
       Compiling regex v1.4.6
       Compiling env_logger v0.7.1
       Compiling cexpr v0.4.0
       Compiling cpp_common v0.5.6
       Compiling cpp_build v0.5.6
       Compiling cpp_macros v0.5.6
       Compiling thiserror-impl v1.0.24
       Compiling thiserror v1.0.24
       Compiling tflite v0.9.5 (/tflite-rs)
       Compiling cpp v0.5.6
    error: failed to run custom build command for `tflite v0.9.5 (/tflite-rs)`
    
    Caused by:
      process didn't exit successfully: `/tflite-rs/target/debug/build/tflite-3bc8f0fc52b19486/build-script-build` (exit code: 101)
      --- stderr
      csrc/tflite_wrapper.hpp:1:10: fatal error: 'tensorflow/lite/interpreter.h' file not found
      csrc/tflite_wrapper.hpp:1:10: fatal error: 'tensorflow/lite/interpreter.h' file not found, err: true
      thread 'main' panicked at 'Unable to generate bindings: ()', build.rs:257:40
      note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
    

    It looks like the submodule downloads are missing entirely? I have a feeling I'm making a novice mistake here - apologies in advance.

    opened by NMRobert 1
  • Exclude everything that isn't necessary to get crate size down

    Exclude everything that isn't necessary to get crate size down

    Hopefully fixes #21. I'm having an error building this locally from the cpp crate. It doesn't happen when I cross compile for aarch64 or when I build on my mac. Wondering if this will pass ci.

    opened by tylerhawkes 1
  • v0.7.0 cannot be published to crates.io due to the size limit.

    v0.7.0 cannot be published to crates.io due to the size limit.

    @tylerhawkes Do you have any idea to solve this problem?

    └─(12:15:59 on master)──> cargo publish                                                                                                                                                             ──(Wed,Nov13)─┘
        Updating crates.io index
       Packaging tflite v0.7.0 (/home/comatose/workspace/tflite-rs)
       Verifying tflite v0.7.0 (/home/comatose/workspace/tflite-rs)
       Compiling memchr v2.2.1
       Compiling proc-macro2 v0.4.30
       Compiling libc v0.2.65
       Compiling unicode-xid v0.1.0
       Compiling version_check v0.1.5
       Compiling cc v1.0.41
       Compiling lazy_static v1.4.0
       Compiling proc-macro2 v1.0.1
       Compiling bitflags v1.1.0
       Compiling log v0.4.8
       Compiling glob v0.3.0
       Compiling byteorder v1.3.2
       Compiling syn v0.15.44
       Compiling unicode-xid v0.2.0
       Compiling cfg-if v0.1.9
       Compiling quick-error v1.2.2
       Compiling regex-syntax v0.6.11
       Compiling unicode-width v0.1.6
       Compiling ansi_term v0.11.0
       Compiling termcolor v1.0.5
       Compiling bindgen v0.51.1
       Compiling strsim v0.8.0
       Compiling vec_map v0.8.1
       Compiling shlex v0.1.1
       Compiling failure_derive v0.1.5
       Compiling peeking_take_while v0.1.2
       Compiling rustc-demangle v0.1.16
       Compiling fs_extra v1.1.0
       Compiling maybe-owned v0.3.2
       Compiling thread_local v0.3.6
       Compiling nom v4.2.3
       Compiling humantime v1.2.0
       Compiling textwrap v0.11.0
       Compiling clang-sys v0.28.1
       Compiling libloading v0.5.2
       Compiling backtrace-sys v0.1.31
       Compiling atty v0.2.13
       Compiling which v3.1.0
       Compiling rustc-hash v1.0.1
       Compiling aho-corasick v0.7.6
       Compiling aho-corasick v0.6.10
       Compiling clap v2.33.0
       Compiling quote v1.0.2
       Compiling quote v0.6.13
       Compiling backtrace v0.3.35
       Compiling cexpr v0.3.5
       Compiling regex v1.2.1
       Compiling env_logger v0.6.2
       Compiling cpp_common v0.5.3
       Compiling synstructure v0.10.2
       Compiling cpp_build v0.5.3
       Compiling cpp_macros v0.5.3
       Compiling cpp v0.5.3
       Compiling failure v0.1.5
       Compiling tflite v0.7.0 (/home/comatose/workspace/tflite-rs/target/package/tflite-0.7.0)
        Finished dev [unoptimized + debuginfo] target(s) in 1m 34s
       Uploading tflite v0.7.0 (/home/comatose/workspace/tflite-rs)
    error: api errors (status 200 OK): max upload size is: 10485760
    
    opened by boncheolgu 1
  • Unable to build 0.6.3 on linux

    Unable to build 0.6.3 on linux

    I just upgraded to the latest (I tried it when 0.6 was first released and got a build error and just reverted for the time being). I got the following:

    error: failed to run custom build command for tflite v0.6.3

    Caused by: process didn't exit successfully: /target/debug/build/tflite-fe3dac74f1fccc3f/build-script-build (exit code: 101) --- stdout cargo:warning=couldn't execute llvm-config --prefix (error: No such file or directory (os error 2)) cargo:warning=set the LLVM_CONFIG_PATH environment variable to a valid llvm-config executable

    --- stderr /usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../include/c++/9/memory:121:25: error: cast from pointer to smaller type 'uintptr_t' (aka 'unsigned int') loses information /usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../include/c++/9/memory:121:25: error: cast from pointer to smaller type 'uintptr_t' (aka 'unsigned int') loses information, err: true thread 'main' panicked at 'Unable to generate STL bindings: ()', src/libcore/result.rs:1084:5 stack backtrace: 0: 0x5644f8489f6b - backtrace::backtrace::libunwind::trace::h89fcc71e59e3bc5b at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.34/src/backtrace/libunwind.rs:88 1: 0x5644f8489f6b - backtrace::backtrace::trace_unsynchronized::h0bad9be1379e729a at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.34/src/backtrace/mod.rs:66 2: 0x5644f8489f6b - std::sys_common::backtrace::_print::hd3382a1f33c473da at src/libstd/sys_common/backtrace.rs:47 3: 0x5644f8489f6b - std::sys_common::backtrace::print::h0ec6f03cfb8e76a6 at src/libstd/sys_common/backtrace.rs:36 4: 0x5644f8489f6b - std::panicking::default_hook::{{closure}}::h96cbf7b454e3f557 at src/libstd/panicking.rs:200 5: 0x5644f8489c46 - std::panicking::default_hook::h95a8f00337383d83 at src/libstd/panicking.rs:214 6: 0x5644f848a6dd - std::panicking::rust_panic_with_hook::h92f98b46e22f14ed at src/libstd/panicking.rs:477 7: 0x5644f848a262 - std::panicking::continue_panic_fmt::h25abfbb4e5b7043a at src/libstd/panicking.rs:384 8: 0x5644f848a146 - rust_begin_unwind at src/libstd/panicking.rs:311 9: 0x5644f84acf4d - core::panicking::panic_fmt::h7e9f94035af782b3 at src/libcore/panicking.rs:85 10: 0x5644f84ad047 - core::result::unwrap_failed::hf7591c1dd9412006 at src/libcore/result.rs:1084 11: 0x5644f7dc0941 - core::result::Result<T,E>::expect::h95f9a79adaa44083 at /rustc/625451e376bb2e5283fc4741caa0a3e8a2ca4d54/src/libcore/result.rs:879 12: 0x5644f7dc3fa1 - build_script_build::import_stl_types::h1c2a9dba812ec57c at /rust/cargo/registry/src/github.com-1ecc6299db9ec823/tflite-0.6.3/build.rs:261 13: 0x5644f7dc40ba - build_script_build::main::h95b9cf054ee99db6 at /rust/cargo/registry/src/github.com-1ecc6299db9ec823/tflite-0.6.3/build.rs:513 14: 0x5644f7dd4ff3 - std::rt::lang_start::{{closure}}::h0c7f757304ff61f9 at /rustc/625451e376bb2e5283fc4741caa0a3e8a2ca4d54/src/libstd/rt.rs:64 15: 0x5644f848a0e3 - std::rt::lang_start_internal::{{closure}}::h4e93c1949c7a1955 at src/libstd/rt.rs:49 16: 0x5644f848a0e3 - std::panicking::try::do_call::h9440ccd4dc467eaa at src/libstd/panicking.rs:296 17: 0x5644f849473a - __rust_maybe_catch_panic at src/libpanic_unwind/lib.rs:80 18: 0x5644f848acad - std::panicking::try::hc046e7ee42ee744f at src/libstd/panicking.rs:275 19: 0x5644f848acad - std::panic::catch_unwind::h27dfc457c200aee0 at src/libstd/panic.rs:394 20: 0x5644f848acad - std::rt::lang_start_internal::hea1b49a567afe309 at src/libstd/rt.rs:48 21: 0x5644f7dd4feb - std::rt::lang_start::h230272963a6d05aa at /rustc/625451e376bb2e5283fc4741caa0a3e8a2ca4d54/src/libstd/rt.rs:64 22: 0x7f7c6c3cdf33 - __libc_start_main 23: 0x5644f7dbd23e - _start 24: 0x0 -

    I've run into this before in other projects and it seems like we just need to add some other flags to the compiler invocation.

    opened by tylerhawkes 1
  • Pass through TARGET_TOOLCHAIN_PREFIX for rpi

    Pass through TARGET_TOOLCHAIN_PREFIX for rpi

    This change enable the cross compilation for the Raspberry PI by setting the following env variable before starting cargo.

    TARGET_TOOLCHAIN_PREFIX=arm-linux-gnueabihf-
    
    opened by winding-lines 1
  • Segfault in unit tests

    Segfault in unit tests

    I'm using the lastest rust version (1.63) on Centos7. I get a clean build of tflite-rs but the unit tests are segfaulting. I can trace one such problem down to the following line in unittest_struct_with_strings:

    https://github.com/boncheolgu/tflite-rs/blob/master/src/model/stl/string.rs#L116

    The error text is:

    error: test failed, to rerun pass '--lib'
    
    Caused by:
      process didn't exit successfully: `/home/csaunders/devel/github/tflite-rs/target/debug/deps/tflite-87cf1d995d6e7fc6 --test-threads 1 --nocapture unittest_struct_with_strings` (signal: 11, SIGSEGV: invalid memory reference)
    

    This is the primary issue I'm concerned about.

    As a related issue/question - I was going to play with the cpp macro interaction in the unittest_struct_with_strings test a bit to uncover what was happening, but then I discovered that all of the inline c++ is pre-built once and doesn't updated on a rebuild. A full clean requires a full tensorflow rebuild. Is there a cargo command or other workaround to force the rust cpp macros to rebuild?

    opened by ctsa 1
  • Can't compile with newer versions of Rust

    Can't compile with newer versions of Rust

    Concretely I'm on version 1.61and while trying to compile a project with tflite in there this is what I get:

    Checking tflite v0.9.6 (https://github.com/boncheolgu/tflite-rs#50ed6075)
    error[E0740]: unions cannot contain fields that may need dropping
       --> /home/sergio/Documentos/Voice_Assistants/precise-rs/target/debug/build/tflite-f45dcb97c94f6ca3/out/tflite_types.rs:411:13
        |
    411 |             pub _M_val: _Tp,
        |             ^^^^^^^^^^^^^^^
        |
        = note: a type is guaranteed not to need dropping when it implements `Copy`, or when it is the special `ManuallyDrop<_>` type
    help: when the type does not implement `Copy`, wrap it inside a `ManuallyDrop<_>` and ensure it is manually dropped
        |
    411 |             pub _M_val: std::mem::ManuallyDrop<_Tp>,
        |                         +++++++++++++++++++++++   +
    
    For more information about this error, try `rustc --explain E0740`.
    error: could not compile `tflite` due to previous error
    

    Note that I compiled the project with older versions and this seems a problem of modern Rust with this lib.

    opened by sheosi 3
  • Old TFLite binary with newer model.

    Old TFLite binary with newer model.

    @boncheolgu got the following error

    Finished dev [unoptimized + debuginfo] target(s) in 2m 14s
         Running `target/debug/tftest`
    ERROR: Op builtin_code out of range: 127. Are you using old TFLite binary with newer model?
    ERROR: Registration failed.
    
    thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: InternalError("failed to build")', src/main.rs:57:18
    

    tflite model was build and converted using tensorflow-gpu==2.7.0 Host-OS :- Pop_Os(linux X86_64) At some stage, i have plans to cross compile the application to arm architecture for raspberry pi model3

    opened by Techseeker-404 2
  • csrc/tflite_wrapper.hpp:1:10: fatal error: 'tensorflow/lite/interpreter.h' file not found

    csrc/tflite_wrapper.hpp:1:10: fatal error: 'tensorflow/lite/interpreter.h' file not found

    when I run the 'cargo build',the console output the error,I'm a new Rust developer,can you help me,thank you.

    Compiling tflite v0.9.6 (/opt/paul/ubuntu/workspace/app/wasm/wasmedge-nodejs/tflite-rs) warning: panic message is not a string literal --> build.rs:156:24 | 156 | panic!(format!("Unable to copy libtensorflow-lite.a to {}", tf_lib_name.display())) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[warn(non_fmt_panic)] on by default = note: this is no longer accepted in Rust 2021 = note: the panic!() macro supports formatting, so there's no need for the format!() macro here help: remove the format!(..) macro call | 156 | panic!("Unable to copy libtensorflow-lite.a to {}", tf_lib_name.display()) | -- --

    warning: 1 warning emitted

    error: failed to run custom build command for tflite v0.9.6 (/opt/paul/ubuntu/workspace/app/wasm/wasmedge-nodejs/tflite-rs)

    Caused by: process didn't exit successfully: /opt/paul/ubuntu/workspace/app/wasm/wasmedge-nodejs/tflite-rs/target/debug/build/tflite-6f77aab17005c2de/build-script-build (exit status: 101) --- stderr csrc/tflite_wrapper.hpp:1:10: fatal error: 'tensorflow/lite/interpreter.h' file not found csrc/tflite_wrapper.hpp:1:10: fatal error: 'tensorflow/lite/interpreter.h' file not found, err: true thread 'main' panicked at 'Unable to generate bindings: ()', build.rs:237:40 stack backtrace: 0: 0x556f82b0d7c0 - std::backtrace_rs::backtrace::libunwind::trace::h34055254b57d8e79 at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5 1: 0x556f82b0d7c0 - std::backtrace_rs::backtrace::trace_unsynchronized::h8f1e3fbd9afff6ec at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5 2: 0x556f82b0d7c0 - std::sys_common::backtrace::_print_fmt::h3a99a796b770c360

    opened by javadoors 2
  • Update TF to 2.6.0rc2

    Update TF to 2.6.0rc2

    (Sending this with assuming that previous attempts to updating it to 2.4.1 is halting now.)

    This PR updates the base Tensorflow version to 2.6.0rc2. I think it is easy to again upgrade it to the official 2.6.0 once this is merged.

    Upgrading to 2.6.0rc2 required a strange patch for making it compatible with macOS+LLVM environment. https://github.com/yotarok/tflite-rs-downloads/commit/29c578e665abca2a17a9fa3efc6cb2db14bf8e3d I hope it is okay, but I think I should dive a bit deeper to find a root cause of this.

    opened by yotarok 1
Owner
Boncheol Gu
Boncheol Gu
An example of using TensorFlow rust bindings to serve trained machine learning models via Actix Web

Serving TensorFlow with Actix-Web This repository gives an example of training a machine learning model using TensorFlow2.0 Keras in python, exporting

Kyle Kosic 39 Dec 12, 2022
Tensors and differentiable operations (like TensorFlow) in Rust

autograd Differentiable operations and tensors backed by ndarray. Motivation Machine learning is one of the field where Rust lagging behind other lang

Ryo ASAKURA 403 Dec 25, 2022
Tiny, no-nonsense, self-contained, Tensorflow and ONNX inference

Sonos' Neural Network inference engine. This project used to be called tfdeploy, or Tensorflow-deploy-rust. What ? tract is a Neural Network inference

Sonos, Inc. 1.5k Jan 8, 2023
Rust bindings for the C++ api of PyTorch.

tch-rs Rust bindings for the C++ api of PyTorch. The goal of the tch crate is to provide some thin wrappers around the C++ PyTorch api (a.k.a. libtorc

Laurent Mazare 2.3k Jan 1, 2023
Rust bindings for XGBoost.

rust-xgboost Rust bindings for the XGBoost gradient boosting library. Documentation Basic usage example: extern crate xgboost; use xgboost::{paramete

Dave Challis 79 Nov 28, 2022
Rust language bindings for Faiss

Faiss-rs This project provides Rust bindings to Faiss, the state-of-the-art vector search and clustering library. Installing as a dependency Currently

Eduardo Pinho 86 Jan 7, 2023
Locality Sensitive Hashing in Rust with Python bindings

lsh-rs (Locality Sensitive Hashing) Locality sensitive hashing can help retrieving Approximate Nearest Neighbors in sub-linear time. For more informat

Ritchie Vink 65 Jan 2, 2023
OpenAI Gym bindings for Rust

gym-rs OpenAI gym binding for Rust. Actively maintained! If you have any problem just create an issue. Install Just install the requierements layed ou

Mr.Robb 45 Dec 11, 2022
High-level non-blocking Deno bindings to the rust-bert machine learning crate.

bertml High-level non-blocking Deno bindings to the rust-bert machine learning crate. Guide Introduction The ModelManager class manages the FFI bindin

Carter Snook 14 Dec 15, 2022
Docker for PyTorch rust bindings `tch`. Example of pretrain model.

tch-rs-pretrain-example-docker Docker for PyTorch rust bindings tch-rs. Example of pretrain model. Docker files support the following install libtorch

vaaaaanquish 5 Oct 7, 2022
Rust language bindings for the LIBLINEAR C/C++ library.

liblinear-rs Rust bindings for the liblinear C/C++ library. Provides a thin (but rustic) wrapper around the original C-interface exposed by the librar

Madeesh Kannan 8 Sep 22, 2022
mxnet Rust Bindings

mxnet Rust Bindings This is a work in progress. Contributions gladly accepted! The mxnet crate defines a high-level Rust API for mxnet using the mxnet

Jacob Lee 5 Sep 17, 2022
Rust bindings for darknet

Rust bindings for darknet Darknet: Convolutional Neural Networks todo rewrite the demo function used in yolo.c in rust Examples Link existing files an

Oliver Funk 8 Jul 11, 2021
SlintDotnet is a C# bindings project to enable developers to use Slint UI with .NET C#

SlintDotnet (Alpha) Slint is a UI toolkit that supports different programming languages. SlintDotnet is the integration with .NET C#. ⚠️ This is exper

Matheus Castello 9 Oct 2, 2023
Msgpack serialization/deserialization library for Python, written in Rust using PyO3, and rust-msgpack. Reboot of orjson. msgpack.org[Python]

ormsgpack ormsgpack is a fast msgpack library for Python. It is a fork/reboot of orjson It serializes faster than msgpack-python and deserializes a bi

Aviram Hassan 139 Dec 30, 2022
Practice repo for learning Rust. Currently going through "Rust for JavaScript Developers" course.

rust-practice ?? Practice repo for learning Rust. Directories /rust-for-js-dev Files directed towards "Rust for JavaScript Developers" course. Thank y

Sammy Samkough 0 Dec 25, 2021
A Rust library with homemade machine learning models to classify the MNIST dataset. Built in an attempt to get familiar with advanced Rust concepts.

mnist-classifier Ideas UPDATED: Finish CLI Flags Parallelize conputationally intensive functions Class-based naive bayes README Image parsing Confusio

Neil Kaushikkar 0 Sep 2, 2021
🦀Rust Turkiye - Rust Dersleri

Rust Turkiye - Rust Dersleri CURIOSITY - Featuring Richard Feynman Bu repo Rust Turkiye tarafindan duzenlenen Rust Dersleri egitiminin alistirma ve ko

Theo M. Bulut 12 Jan 14, 2023
A Rust machine learning framework.

Linfa linfa (Italian) / sap (English): The vital circulating fluid of a plant. linfa aims to provide a comprehensive toolkit to build Machine Learning

Rust-ML 2.2k Jan 2, 2023