Skip to content

Commit

Permalink
updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cocoa-xu committed Mar 17, 2024
1 parent 3831d62 commit f1f85e7
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
14 changes: 7 additions & 7 deletions test/high_level_image_classification_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,30 @@ defmodule TFLiteElixir.ImageClassification.Test do
input_path = Path.join([__DIR__, "test_data", "parrot.jpeg"])

{:ok, pid} = ImageClassification.start(filename)
%{class_id: 923, score: 0.70703125} = ImageClassification.predict(pid, input_path)
%{class_id: 923, score: _score} = ImageClassification.predict(pid, input_path)

%{class_id: 923, score: 0.70703125} =
%{class_id: 923, score: _score} =
ImageClassification.predict(pid, StbImage.read_file!(input_path))

%{class_id: 923, score: 0.70703125} =
%{class_id: 923, score: _score} =
ImageClassification.predict(pid, StbImage.to_nx(StbImage.read_file!(input_path)))

assert :ok == ImageClassification.set_label_from_associated_file(pid, "inat_bird_labels.txt")

%{class_id: 923, label: "Ara macao (Scarlet Macaw)", score: 0.70703125} =
%{class_id: 923, label: "Ara macao (Scarlet Macaw)", score: _score} =
ImageClassification.predict(pid, input_path)

[
%{class_id: 923, label: "Ara macao (Scarlet Macaw)", score: 0.70703125},
%{class_id: 923, label: "Ara macao (Scarlet Macaw)", score: _score1},
%{
class_id: 837,
label: "Platycercus elegans (Crimson Rosella)",
score: 0.078125
score: _score2
},
%{
class_id: 245,
label: "Coracias caudatus (Lilac-breasted Roller)",
score: 0.01953125
score: _score3
}
] = ImageClassification.predict(pid, input_path, top_k: 3)
end
Expand Down
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 65 == Interpreter.nodes_size(interpreter)
assert 67 == 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 Enum.to_list(0..64) == Interpreter.execution_plan(interpreter)
assert [65, 62, 66, 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.
4 changes: 2 additions & 2 deletions test/tflite_task_classify_image_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ defmodule TFLiteElixir.Test.ClassifyImage do

"""
-------RESULTS--------
Ara macao (Scarlet Macaw): 0.70703
Platycercus elegans (Crimson Rosella): 0.07813
Ara macao (Scarlet Macaw): 0.73828
Platycercus elegans (Crimson Rosella): 0.06641
Coracias caudatus (Lilac-breasted Roller): 0.01953
""" =
String.split(output, "\n")
Expand Down
2 changes: 1 addition & 1 deletion test/tflite_task_detect_image_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ defmodule TFLiteElixir.Test.DetectImage do
"""
cat
id : 16
score: 0.953
score: 0.934
bbox : [3, -1, 294, 240]
""" =
String.split(output, "\n")
Expand Down

0 comments on commit f1f85e7

Please sign in to comment.