Comments (3)
Hi @mnishiguchi, I also added tests for TFLiteElixir.TFLiteTensor
, including improved error messages when backend
is invalid. What do you think?
from tflite_beam.
This should be better now. :)
iex> alias TFLiteElixir.InterpreterBuilder
TFLiteElixir.InterpreterBuilder
iex> alias TFLiteElixir.Ops.Builtin.BuiltinResolver
TFLiteElixir.Ops.Builtin.BuiltinResolver
iex> alias TFLiteElixir.FlatBufferModel
TFLiteElixir.FlatBufferModel
iex> alias TFLiteElixir.Interpreter
TFLiteElixir.Interpreter
iex> alias TFLiteElixir.TFLiteTensor
TFLiteElixir.TFLiteTensor
iex> filename = Path.join([__DIR__, "test", "test_data", "mobilenet_v2_1.0_224_inat_bird_quant.tflite"])
"./test/test_data/mobilenet_v2_1.0_224_inat_bird_quant.tflite"
iex> model = FlatBufferModel.build_from_file(filename)
#FlatBufferModel<%{
"initialized" => true,
"metadata" => %{"TFLITE_METADATA" => <<28>>, "min_runtime_version" => "1.5.0"},
"minimum_runtime" => "1.5.0"
}>
iex> resolver = BuiltinResolver.new!()
#Reference<0.331881720.996278283.169380>
iex> builder = InterpreterBuilder.new!(model, resolver)
#Reference<0.331881720.996278283.169392>
iex> interpreter = Interpreter.new!()
INFO: Initialized TensorFlow Lite runtime.
#Reference<0.331881720.996278283.169402>
iex> :ok = InterpreterBuilder.build!(builder, interpreter)
:ok
iex> :ok = Interpreter.allocate_tensors(interpreter)
:ok
iex> t = Interpreter.tensor(interpreter, 0)
%TFLiteElixir.TFLiteTensor{
name: "map/TensorArrayStack/TensorArrayGatherV3",
index: 0,
shape: [1, 224, 224, 3],
shape_signature: [1, 224, 224, 3],
type: {:u, 8},
quantization_params: %TFLiteElixir.TFLiteQuantizationParams{
scale: [0.0078125],
zero_point: [128],
quantized_dimension: 0
},
sparsity_params: %{},
reference: #Reference<0.331881720.996278283.169424>
}
iex> TFLiteTensor.to_nx(t)
#Nx.Tensor<
u8[1][224][224][3]
[
[
[
[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
[0, 0, ...],
...
],
...
]
]
>
iex> TFLiteTensor.to_nx(t, backend: nil)
#Nx.Tensor<
u8[1][224][224][3]
[
[
[
[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
[0, 0, ...],
...
],
...
]
]
>
iex> TFLiteTensor.to_nx(t, backend: Nx.BinaryBackend)
#Nx.Tensor<
u8[1][224][224][3]
[
[
[
[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
[0, 0, ...],
...
],
...
]
]
>
from tflite_beam.
Nice! The new error message is a lot less scary. Thank you!
from tflite_beam.
Related Issues (17)
- Add a wrapper layer `TFLite.Backend` for `TfLiteTensor` HOT 1
- Segfault HOT 3
- Missing module/function docs HOT 1
- TFLiteTensor.dims vs out_tensor.shape HOT 2
- Getting "Runtime node closed unexpectedly - no connection" on example tpu notebook HOT 6
- Erlang Bindings
- Parse `TFLITE_METADATA`
- Create some high-level modules
- Change name to `tflite_beam`
- Convert from `lib/tflite_beam_nif.ex` to `tflite_beam_nif.erl`
- Port all existing modules to Erlang. HOT 1
- Example: BERT Question and Answer HOT 3
- Implement BERT Tokenizer HOT 1
- rebar3: Add support for using precompiled binaries. HOT 1
- [deps] add support for TensorFlow 2.12.0
- precompile for armv6? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tflite_beam.