Skip to content

Commit df03d67

Browse files
authored
chore: bump tflite_beam to v0.3.8 (#20)
* chore: bump tflite_beam to v0.3.8 Signed-off-by: Cocoa <i@uwucocoa.moe> * chore: bump nerves-build Signed-off-by: Cocoa <i@uwucocoa.moe> * updated unit tests Signed-off-by: Cocoa <i@uwucocoa.moe>
1 parent 0e25c33 commit df03d67

8 files changed

+36
-29
lines changed

.github/workflows/nerves-build.yml

+8-6
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@ jobs:
4848
env:
4949
MIX_ENV: prod
5050
NERVES_PROJ_NAME: nerves_tflite
51-
NERVES_LIVEBOOK_VER: "v0.14.0"
51+
NERVES_LIVEBOOK_VER: "v0.14.2"
5252
TFLITE_BEAM_PREFER_PRECOMPILED: "true"
5353
TFLITE_BEAM_CORAL_SUPPORT: "true"
54+
FWUP_VERSION: "1.12.0"
5455

5556
strategy:
5657
fail-fast: false
@@ -94,7 +95,8 @@ jobs:
9495
libedgetpu_library: armv7l
9596

9697
steps:
97-
- uses: actions/checkout@v4
98+
- name: Checkout
99+
uses: actions/checkout@v4
98100

99101
- uses: erlef/setup-beam@v1
100102
with:
@@ -109,8 +111,8 @@ jobs:
109111
mix local.hex --force
110112
mix local.rebar --force
111113
mix archive.install hex nerves_bootstrap --force
112-
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
113-
sudo dpkg -i fwup_1.11.0_amd64.deb
114+
curl -fSL "https://github.com/fwup-home/fwup/releases/download/v${FWUP_VERSION}/fwup_${FWUP_VERSION}_amd64.deb" -o "fwup_${FWUP_VERSION}_amd64.deb"
115+
sudo dpkg -i "fwup_${FWUP_VERSION}_amd64.deb"
114116
115117
- name: Make a nerves project
116118
run: |
@@ -138,12 +140,12 @@ jobs:
138140
cp "./_build/${MIX_TARGET}_${MIX_ENV}/nerves/images/nerves_livebook.fw" "/tmp/firmware/${NERVES_PROJ_NAME}_${{ matrix.pair.target }}_${MIX_ENV}.fw"
139141
140142
- name: Upload build artifacts
141-
uses: actions/upload-artifact@v3
143+
uses: actions/upload-artifact@v4
142144
with:
143145
name: ${{ env.NERVES_PROJ_NAME }}_${{ matrix.pair.target }}_${{ env.MIX_ENV }}.fw
144146
path: /tmp/firmware/${{ env.NERVES_PROJ_NAME }}_${{ matrix.pair.target }}_${{ env.MIX_ENV }}.fw
145147

146-
- uses: softprops/action-gh-release@v1
148+
- uses: softprops/action-gh-release@v2
147149
if: startsWith(github.ref, 'refs/tags/')
148150
with:
149151
files: /tmp/firmware/${{ env.NERVES_PROJ_NAME }}_${{ matrix.pair.target }}_${{ env.MIX_ENV }}.fw

lib/tflite_elixir/flatbuffer_model.ex

+7-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ defmodule TFLiteElixir.FlatBufferModel do
33
An RAII object that represents a read-only tflite model, copied from disk, or
44
mmapped.
55
"""
6-
import TFLiteElixir.Errorize
76

87
alias TFLiteElixir.ErrorReporter
98

@@ -48,7 +47,13 @@ defmodule TFLiteElixir.FlatBufferModel do
4847
end
4948
end
5049

51-
deferror(build_from_file(filename, opts))
50+
def build_from_file!(filename, opts) do
51+
case build_from_file(filename, opts) do
52+
{:error, message} when is_list(message) -> raise List.to_string(message)
53+
{:error, message} when is_binary(message) -> raise message
54+
res -> res
55+
end
56+
end
5257

5358
@doc """
5459
Verifies whether the content of the file is legit, then builds a model

mix.exs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ defmodule TFLiteElixir.MixProject do
33
require Logger
44

55
@app :tflite_elixir
6-
@version "0.3.7"
6+
@version "0.3.8"
77
@github_url "https://github.com/cocoa-xu/tflite_elixir"
88

99
def project do
@@ -27,7 +27,7 @@ defmodule TFLiteElixir.MixProject do
2727

2828
defp deps do
2929
[
30-
{:tflite_beam, "~> 0.3.6"},
30+
{:tflite_beam, "~> 0.3.8"},
3131
{:nx, "~> 0.5"},
3232
{:stb_image, "~> 0.6"},
3333
{:ex_doc, "~> 0.27", only: :docs, runtime: false}

mix.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111
"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"},
1212
"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"},
1313
"telemetry": {:hex, :telemetry, "1.2.1", "68fdfe8d8f05a8428483a97d7aab2f268aaff24b49e0f599faa091f1d4e7f61c", [:rebar3], [], "hexpm", "dad9ce9d8effc621708f99eac538ef1cbe05d6a874dd741de2e689c47feafed5"},
14-
"tflite_beam": {:hex, :tflite_beam, "0.3.6", "5ea1c0d98e8a35b561c8b5ff018781c25a18cb516344d6629763d930e611229a", [:rebar3], [], "hexpm", "695226c8ab6a0b4ddff505a69f3459202c14d3c679b3e946fa3a946801e4fe7a"},
14+
"tflite_beam": {:hex, :tflite_beam, "0.3.8", "ed8ee5dd40941197670ce2a7430b0f39b23a16d22e663f6aec5e6ff41ece23c4", [:rebar3], [], "hexpm", "54a0e2fb7e76253de76d18ed13a59fa47b7bbb09b923d5c9b23a69ef4b7e5c06"},
1515
}

test/interpreter_test.exs

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ defmodule TFLiteElixir.Interpreter.Test do
9090
filename = Path.join([__DIR__, "test_data", "mobilenet_v2_1.0_224_inat_bird_quant.tflite"])
9191
interpreter = Interpreter.new!(filename)
9292

93-
assert 67 == Interpreter.nodes_size(interpreter)
93+
assert 65 == Interpreter.nodes_size(interpreter)
9494
end
9595

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

105-
assert [65, 62, 66, 64] == Interpreter.execution_plan(interpreter)
105+
assert Enum.to_list(0..64) == Interpreter.execution_plan(interpreter)
106106
end
107107

108108
test "execution_plan/1 with invalid interpreter" do
0 Bytes
Binary file not shown.

test/tflite_task_classify_image_test.exs

+6-6
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@ defmodule TFLiteElixir.Test.ClassifyImage do
2222
)
2323
end)
2424

25-
"""
26-
-------RESULTS--------
27-
Ara macao (Scarlet Macaw): 0.73828
28-
Platycercus elegans (Crimson Rosella): 0.06641
29-
Coracias caudatus (Lilac-breasted Roller): 0.01953
30-
""" =
25+
result =
3126
String.split(output, "\n")
3227
|> List.delete_at(0)
3328
|> List.delete_at(0)
3429
|> Enum.join("\n")
30+
31+
assert result =~ "-------RESULTS--------"
32+
assert result =~ "Ara macao (Scarlet Macaw): 0.7"
33+
assert result =~ "Platycercus elegans (Crimson Rosella): 0."
34+
assert result =~ "Coracias caudatus (Lilac-breasted Roller): 0."
3535
end
3636

3737
@tag :require_tpu

test/tflite_task_detect_image_test.exs

+10-10
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@ defmodule TFLiteElixir.Test.DetectImage do
1919
)
2020
end)
2121

22-
"""
23-
cat
24-
id : 16
25-
score: 0.934
26-
bbox : [3, -1, 294, 240]
27-
""" =
28-
String.split(output, "\n")
29-
|> List.delete_at(0)
30-
|> List.delete_at(0)
31-
|> Enum.join("\n")
22+
assert """
23+
cat
24+
id : 16
25+
score: 0.953
26+
bbox : [3, -1, 294, 240]
27+
""" =
28+
String.split(output, "\n")
29+
|> List.delete_at(0)
30+
|> List.delete_at(0)
31+
|> Enum.join("\n")
3232
end
3333

3434
@tag :require_tpu

0 commit comments

Comments
 (0)