Skip to content

Commit

Permalink
Merge pull request #186 from cocoa-xu/cx-fix-outputBlob-in-list
Browse files Browse the repository at this point in the history
Fixed outputBlob in a list
  • Loading branch information
cocoa-xu authored Mar 24, 2023
2 parents 0c2550c + bc5fc64 commit 91fc18e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/zoo/image_classification/mobilenet_v1.ex
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,13 @@ defmodule Evision.Zoo.ImageClassification.MobileNetV1 do
inputBlob = preprocess(image)
Evision.DNN.Net.setInput(self, inputBlob)
outputBlob = Evision.DNN.Net.forward(self, outputName: "")
outputBlob =
if is_list(outputBlob) do
[outputBlob] = outputBlob
outputBlob
else
outputBlob
end
# todo: use Evision.Backend when Nx.slice is implemented
result = Nx.squeeze(Evision.Mat.to_nx(outputBlob, Nx.BinaryBackend))
Nx.to_flat_list(Nx.argsort(result, direction: :desc)[[0..top_k-1]])
Expand Down
7 changes: 7 additions & 0 deletions lib/zoo/text_recognition/crnn.ex
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,13 @@ defmodule Evision.Zoo.TextRecognition.CRNN do
# Forward
Evision.DNN.Net.setInput(self, inputBlob)
outputBlob = Evision.DNN.Net.forward(self, outputName: "")
outputBlob =
if is_list(outputBlob) do
[outputBlob] = outputBlob
outputBlob
else
outputBlob
end

# Postprocess
charset = opts[:charset]
Expand Down

0 comments on commit 91fc18e

Please sign in to comment.