Skip to content

Commit

Permalink
[smartcell] updated CRNN models
Browse files Browse the repository at this point in the history
  • Loading branch information
cocoa-xu committed Dec 17, 2022
1 parent e6ec261 commit 931727b
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 34 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
- [smartcell] register the model zoo smart cell (`Evision.SmartCell.Zoo`) on starting. Thanks to @josevalim.
- [smartcell] make `:kino` and `:progress_bar` optional dependencies.
- [ci] added one more step to make sure it compiles without optional deps. Thanks to @josevalim.
- [smartcell] hide all FP16 models of CRNN because they were not supported until [opencv/opencv #22337](https://github.com/opencv/opencv/pull/22337), which was after the release date of OpenCV 4.6.0.

See more on [https://github.com/opencv/opencv/issues/18735#issuecomment-1273125970](https://github.com/opencv/opencv/issues/18735#issuecomment-1273125970).

- [smartcell] hide `CRNN CH (INT8)` and `CRNN EN (INT8)` because OpenCV 4.6.0 seemed to have problems loading/parsing them even with the `demo.py` script in the official opencv_zoo repo.

## v0.1.22 (2022-12-16)
[Browse the Repository](https://github.com/cocoa-xu/evision/tree/v0.1.22) | [Released Assets](https://github.com/cocoa-xu/evision/releases/tag/v0.1.22)
Expand Down
9 changes: 6 additions & 3 deletions lib/smartcell/evision_zoo.ex
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,12 @@ else

defp field_defaults_for(task_id, variant_id) do
variant = variant_by_id(task_id, variant_id)

for param <- variant.params, pparam <- param.params, into: %{} do
{pparam.field, pparam.default}
if variant == nil do
%{}
else
for param <- variant.params, pparam <- param.params, into: %{} do
{pparam.field, pparam.default}
end
end
end

Expand Down
58 changes: 30 additions & 28 deletions lib/zoo/text_recognition/crnn.ex
Original file line number Diff line number Diff line change
Expand Up @@ -424,41 +424,41 @@ defmodule Evision.Zoo.TextRecognition.CRNN do
params: smartcell_params(),
docs: docs()
},
%{
id: "crnn_en_fp16",
label: "CRNN EN (FP16)",
docs_url: "https://github.com/opencv/opencv_zoo/tree/master/models/text_recognition_crnn",
params: smartcell_params(),
docs: docs()
},
%{
id: "crnn_en_int8",
label: "CRNN EN (INT8)",
docs_url: "https://github.com/opencv/opencv_zoo/tree/master/models/text_recognition_crnn",
params: smartcell_params(),
docs: docs()
},
# %{
# id: "crnn_en_fp16",
# label: "CRNN EN (FP16)",
# docs_url: "https://github.com/opencv/opencv_zoo/tree/master/models/text_recognition_crnn",
# params: smartcell_params(),
# docs: docs()
# },
# %{
# id: "crnn_en_int8",
# label: "CRNN EN (INT8)",
# docs_url: "https://github.com/opencv/opencv_zoo/tree/master/models/text_recognition_crnn",
# params: smartcell_params(),
# docs: docs()
# },
%{
id: "crnn_ch",
label: "CRNN CH",
docs_url: "https://github.com/opencv/opencv_zoo/tree/master/models/text_recognition_crnn",
params: smartcell_params(),
docs: docs()
},
%{
id: "crnn_ch_fp16",
label: "CRNN CH (FP16)",
docs_url: "https://github.com/opencv/opencv_zoo/tree/master/models/text_recognition_crnn",
params: smartcell_params(),
docs: docs()
},
%{
id: "crnn_ch_int8",
label: "CRNN CH (INT8)",
docs_url: "https://github.com/opencv/opencv_zoo/tree/master/models/text_recognition_crnn",
params: smartcell_params(),
docs: docs()
},
# %{
# id: "crnn_ch_fp16",
# label: "CRNN CH (FP16)",
# docs_url: "https://github.com/opencv/opencv_zoo/tree/master/models/text_recognition_crnn",
# params: smartcell_params(),
# docs: docs()
# },
# %{
# id: "crnn_ch_int8",
# label: "CRNN CH (INT8)",
# docs_url: "https://github.com/opencv/opencv_zoo/tree/master/models/text_recognition_crnn",
# params: smartcell_params(),
# docs: docs()
# },
%{
id: "crnn_cn",
label: "CRNN CN",
Expand All @@ -481,6 +481,7 @@ defmodule Evision.Zoo.TextRecognition.CRNN do
"""
@spec to_quoted(map()) :: list()
def to_quoted(attrs) do
IO.inspect(attrs, label: "attrs")
{backend, target} = Evision.Zoo.to_quoted_backend_and_target(attrs)

opts = [
Expand All @@ -506,6 +507,7 @@ defmodule Evision.Zoo.TextRecognition.CRNN do
raise "Unknown variant: #{inspect(unknown_id)}"
end


{detector_module, detector_model} =
case attrs["detector"] do
"db_" <> db_detector ->
Expand Down
7 changes: 4 additions & 3 deletions lib/zoo/text_recognition/text_recognition.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ defmodule Evision.Zoo.TextRecognition do

@modules %{
"crnn_en" => Evision.Zoo.TextRecognition.CRNN,
"crnn_en_fp16" => Evision.Zoo.TextRecognition.CRNN,
"crnn_en_int8" => Evision.Zoo.TextRecognition.CRNN,
# "crnn_en_fp16" => Evision.Zoo.TextRecognition.CRNN,
# "crnn_en_int8" => Evision.Zoo.TextRecognition.CRNN,
"crnn_ch" => Evision.Zoo.TextRecognition.CRNN,
"crnn_ch_fp16" => Evision.Zoo.TextRecognition.CRNN,
# "crnn_ch_fp16" => Evision.Zoo.TextRecognition.CRNN,
# "crnn_ch_int8" => Evision.Zoo.TextRecognition.CRNN,
"crnn_cn" => Evision.Zoo.TextRecognition.CRNN,
"crnn_cn_int8" => Evision.Zoo.TextRecognition.CRNN,
}
Expand Down

0 comments on commit 931727b

Please sign in to comment.