Skip to content

chore: bump tflite_beam to v0.3.8 #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions .github/workflows/nerves-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ jobs:
env:
MIX_ENV: prod
NERVES_PROJ_NAME: nerves_tflite
NERVES_LIVEBOOK_VER: "v0.14.0"
NERVES_LIVEBOOK_VER: "v0.14.2"
TFLITE_BEAM_PREFER_PRECOMPILED: "true"
TFLITE_BEAM_CORAL_SUPPORT: "true"
FWUP_VERSION: "1.12.0"

strategy:
fail-fast: false
Expand Down Expand Up @@ -94,7 +95,8 @@ jobs:
libedgetpu_library: armv7l

steps:
- uses: actions/checkout@v4
- name: Checkout
uses: actions/checkout@v4

- uses: erlef/setup-beam@v1
with:
Expand All @@ -109,8 +111,8 @@ jobs:
mix local.hex --force
mix local.rebar --force
mix archive.install hex nerves_bootstrap --force
wget -k https://github.com/fwup-home/fwup/releases/download/v1.11.0/fwup_1.11.0_amd64.deb -O fwup_1.11.0_amd64.deb
sudo dpkg -i fwup_1.11.0_amd64.deb
curl -fSL "https://github.com/fwup-home/fwup/releases/download/v${FWUP_VERSION}/fwup_${FWUP_VERSION}_amd64.deb" -o "fwup_${FWUP_VERSION}_amd64.deb"
sudo dpkg -i "fwup_${FWUP_VERSION}_amd64.deb"

- name: Make a nerves project
run: |
Expand Down Expand Up @@ -138,12 +140,12 @@ jobs:
cp "./_build/${MIX_TARGET}_${MIX_ENV}/nerves/images/nerves_livebook.fw" "/tmp/firmware/${NERVES_PROJ_NAME}_${{ matrix.pair.target }}_${MIX_ENV}.fw"

- name: Upload build artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ env.NERVES_PROJ_NAME }}_${{ matrix.pair.target }}_${{ env.MIX_ENV }}.fw
path: /tmp/firmware/${{ env.NERVES_PROJ_NAME }}_${{ matrix.pair.target }}_${{ env.MIX_ENV }}.fw

- uses: softprops/action-gh-release@v1
- uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: /tmp/firmware/${{ env.NERVES_PROJ_NAME }}_${{ matrix.pair.target }}_${{ env.MIX_ENV }}.fw
9 changes: 7 additions & 2 deletions lib/tflite_elixir/flatbuffer_model.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ defmodule TFLiteElixir.FlatBufferModel do
An RAII object that represents a read-only tflite model, copied from disk, or
mmapped.
"""
import TFLiteElixir.Errorize

alias TFLiteElixir.ErrorReporter

Expand Down Expand Up @@ -48,7 +47,13 @@ defmodule TFLiteElixir.FlatBufferModel do
end
end

deferror(build_from_file(filename, opts))
def build_from_file!(filename, opts) do
case build_from_file(filename, opts) do
{:error, message} when is_list(message) -> raise List.to_string(message)
{:error, message} when is_binary(message) -> raise message
res -> res
end
end

@doc """
Verifies whether the content of the file is legit, then builds a model
Expand Down
4 changes: 2 additions & 2 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ defmodule TFLiteElixir.MixProject do
require Logger

@app :tflite_elixir
@version "0.3.7"
@version "0.3.8"
@github_url "https://github.com/cocoa-xu/tflite_elixir"

def project do
Expand All @@ -27,7 +27,7 @@ defmodule TFLiteElixir.MixProject do

defp deps do
[
{:tflite_beam, "~> 0.3.6"},
{:tflite_beam, "~> 0.3.8"},
{:nx, "~> 0.5"},
{:stb_image, "~> 0.6"},
{:ex_doc, "~> 0.27", only: :docs, runtime: false}
Expand Down
2 changes: 1 addition & 1 deletion mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
"nx": {:hex, :nx, "0.6.4", "948d9f42f81e63fc901d243ac0a985c8bb87358be62e27826cfd67f58bc640af", [:mix], [{:complex, "~> 0.5", [hex: :complex, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.0 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "bb9c2e2e3545b5eb4739d69046a988daaa212d127dba7d97801c291616aff6d6"},
"stb_image": {:hex, :stb_image, "0.6.4", "d7cf19791e80d2d18ef1a5f3f6a8a828e76871f6bb4c20d860a5fa58779c70aa", [:make, :mix], [{:cc_precompiler, "~> 0.1.0", [hex: :cc_precompiler, repo: "hexpm", optional: false]}, {:elixir_make, "~> 0.7.0", [hex: :elixir_make, repo: "hexpm", optional: false]}, {:kino, "~> 0.7", [hex: :kino, repo: "hexpm", optional: true]}, {:nx, "~> 0.4", [hex: :nx, repo: "hexpm", optional: true]}], "hexpm", "2719309d9e59271c0f92cfae5bd569690bbbad48bcb9b38b2b3d9d8856fa2d47"},
"telemetry": {:hex, :telemetry, "1.2.1", "68fdfe8d8f05a8428483a97d7aab2f268aaff24b49e0f599faa091f1d4e7f61c", [:rebar3], [], "hexpm", "dad9ce9d8effc621708f99eac538ef1cbe05d6a874dd741de2e689c47feafed5"},
"tflite_beam": {:hex, :tflite_beam, "0.3.6", "5ea1c0d98e8a35b561c8b5ff018781c25a18cb516344d6629763d930e611229a", [:rebar3], [], "hexpm", "695226c8ab6a0b4ddff505a69f3459202c14d3c679b3e946fa3a946801e4fe7a"},
"tflite_beam": {:hex, :tflite_beam, "0.3.8", "ed8ee5dd40941197670ce2a7430b0f39b23a16d22e663f6aec5e6ff41ece23c4", [:rebar3], [], "hexpm", "54a0e2fb7e76253de76d18ed13a59fa47b7bbb09b923d5c9b23a69ef4b7e5c06"},
}
4 changes: 2 additions & 2 deletions test/interpreter_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ defmodule TFLiteElixir.Interpreter.Test do
filename = Path.join([__DIR__, "test_data", "mobilenet_v2_1.0_224_inat_bird_quant.tflite"])
interpreter = Interpreter.new!(filename)

assert 67 == Interpreter.nodes_size(interpreter)
assert 65 == Interpreter.nodes_size(interpreter)
end

test "nodes_size/1 with invalid interpreter" do
Expand All @@ -102,7 +102,7 @@ defmodule TFLiteElixir.Interpreter.Test do
filename = Path.join([__DIR__, "test_data", "mobilenet_v2_1.0_224_inat_bird_quant.tflite"])
interpreter = Interpreter.new!(filename)

assert [65, 62, 66, 64] == Interpreter.execution_plan(interpreter)
assert Enum.to_list(0..64) == Interpreter.execution_plan(interpreter)
end

test "execution_plan/1 with invalid interpreter" do
Expand Down
Binary file modified test/test_data/parrot-expected-out.bin
Binary file not shown.
12 changes: 6 additions & 6 deletions test/tflite_task_classify_image_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ defmodule TFLiteElixir.Test.ClassifyImage do
)
end)

"""
-------RESULTS--------
Ara macao (Scarlet Macaw): 0.73828
Platycercus elegans (Crimson Rosella): 0.06641
Coracias caudatus (Lilac-breasted Roller): 0.01953
""" =
result =
String.split(output, "\n")
|> List.delete_at(0)
|> List.delete_at(0)
|> Enum.join("\n")

assert result =~ "-------RESULTS--------"
assert result =~ "Ara macao (Scarlet Macaw): 0.7"
assert result =~ "Platycercus elegans (Crimson Rosella): 0."
assert result =~ "Coracias caudatus (Lilac-breasted Roller): 0."
end

@tag :require_tpu
Expand Down
20 changes: 10 additions & 10 deletions test/tflite_task_detect_image_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ defmodule TFLiteElixir.Test.DetectImage do
)
end)

"""
cat
id : 16
score: 0.934
bbox : [3, -1, 294, 240]
""" =
String.split(output, "\n")
|> List.delete_at(0)
|> List.delete_at(0)
|> Enum.join("\n")
assert """
cat
id : 16
score: 0.953
bbox : [3, -1, 294, 240]
""" =
String.split(output, "\n")
|> List.delete_at(0)
|> List.delete_at(0)
|> Enum.join("\n")
end

@tag :require_tpu
Expand Down
Loading