Skip to content

Add text recognition to examples_dnn_text_decoder#16941

Merged
alalek merged 1 commit intoopencv:3.4from
apertovs:examples_dnn_text_decoder
May 6, 2020
Merged

Add text recognition to examples_dnn_text_decoder#16941
alalek merged 1 commit intoopencv:3.4from
apertovs:examples_dnn_text_decoder

Conversation

@apertovs
Copy link
Copy Markdown
Contributor

@apertovs apertovs commented Mar 31, 2020

Trained model taked from here: https://github.com/meijieru/crnn.pytorch

How to convert from pb to onnx
Using classes from here: https://github.com/meijieru/crnn.pytorch/blob/master/models/crnn.py

import torch
import models.crnn as crnn

model = CRNN(32, 1, 37, 256)
model.load_state_dict(torch.load('crnn.pth'))
dummy_input = torch.randn(1, 1, 32, 100)
torch.onnx.export(model, dummy_input, "crnn.onnx", verbose=True)

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under OpenCV (BSD) License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or other license that is incompatible with OpenCV
  • The PR is proposed to proper branch
  • There is reference to original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

"{ help h | | Print help message. }"
"{ input i | | Path to input image or video file. Skip this argument to capture frames from a camera.}"
"{ model_decoder m | | Path to a binary .pb file contains trained detector network.}"
"{ model_recognition | | Path to a binary .pb file contains trained recognition network.}"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

helo, just curious, which model is used here ?

and if it is not (yet) in the model zoo, shouldn't there be a download link somewhere ?

@apertovs
Copy link
Copy Markdown
Contributor Author

apertovs commented Apr 1, 2020

Trained model taked from here: github.com/meijieru/crnn.pytorch

How to convert from pth to onnx
Using classes from here: github.com/meijieru/crnn.pytorch/blob/master/models/crnn.py

import torch

model = CRNN(32, 1, 37, 256)
model.load_state_dict(torch.load('./crnn.pth'))
dummy_input = torch.randn(1, 1, 32, 100)
torch.onnx.export(model, dummy_input, "crnn.onnx", verbose=True)

@alalek alalek mentioned this pull request Apr 2, 2020
6 tasks
@asmorkalov
Copy link
Copy Markdown
Contributor

@rngtna @dkurt What is the patch status? Could you review and list remaining items?

Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for contribution!

Please take a look on comments below.

@asmorkalov
Copy link
Copy Markdown
Contributor

@rngtna Friendly reminder.

@apertovs apertovs force-pushed the examples_dnn_text_decoder branch from db23f51 to 5518973 Compare May 5, 2020 09:13
@dkurt dkurt changed the base branch from master to 3.4 May 5, 2020 09:13
@dkurt
Copy link
Copy Markdown
Member

dkurt commented May 6, 2020

@rngtna, please resolve compilation warnings: https://pullrequest.opencv.org/buildbot/builders/precommit_windows64/builds/24606

@apertovs apertovs force-pushed the examples_dnn_text_decoder branch from 663b547 to 00b19d6 Compare May 6, 2020 12:27
Copy link
Copy Markdown
Member

@dkurt dkurt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Well done!

@dkurt dkurt self-assigned this May 6, 2020
@alalek alalek merged commit 4f1ba5e into opencv:3.4 May 6, 2020
@alalek alalek mentioned this pull request May 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error while loading pytorch model in opencv Feature Request: cv::dnn::readNetFromONNX does not support parsing LSTM layer

6 participants