Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 🐛 fix sar saved model export #635

Closed
wants to merge 1 commit into from
Closed

Conversation

khalidMindee
Copy link
Contributor

This PR solves #602 for SAR recognition models to allow export as a saved model.

Copy link
Contributor

@fg-mindee fg-mindee left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! I added some comments, let's avoid breaking changes in this PR if possible 🙏

if kwargs.get('training') and gt is None:
raise ValueError('Need to provide labels during training for teacher forcing')

Copy link
Contributor

Choose a reason for hiding this comment

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

This needs to stay, was it blocking the savedmodel export?

@@ -150,7 +149,8 @@ def call(
# shape (N, rnn_units + 1) -> (N, vocab_size + 1)
logits = self.output_dense(logits, **kwargs)
# update symbol with predicted logits for t+1 step
if kwargs.get('training'):
if kwargs.get('training') and gt is not None:
#'Need to provide labels during training for teacher forcing'
Copy link
Contributor

Choose a reason for hiding this comment

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

no need to duplicate comment

@@ -150,7 +149,8 @@ def call(
# shape (N, rnn_units + 1) -> (N, vocab_size + 1)
logits = self.output_dense(logits, **kwargs)
# update symbol with predicted logits for t+1 step
if kwargs.get('training'):
if kwargs.get('training') and gt is not None:
Copy link
Contributor

Choose a reason for hiding this comment

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

can be reverted since we already ensure that the gt is provided in training mode above

Comment on lines -305 to +309
word_values = [word.decode() for word in decoded_strings_pred.numpy().tolist()]

return list(zip(word_values, probs.numpy().tolist()))

return {
"decoded_strings_pred":decoded_strings_pred,
"probs":probs,
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We can't change the output signature of the call method in this PR or we'll break the high-level API

@fg-mindee fg-mindee added type: breaking change Introducing a breaking change module: models Related to doctr.models topic: text recognition Related to the task of text recognition wontfix This will not be worked on labels Dec 23, 2021
@fharper fharper requested a review from charlesmindee April 8, 2022 18:50
@fharper
Copy link
Contributor

fharper commented Apr 8, 2022

@khalidMindee is this PR still good? If yes, can you review FG's comments, modify in consequences so we can potentially merge it please?

@felixdittrich92
Copy link
Contributor

@khalidMindee Do you want to go further with this ? :) Otherwise i think we have on track to provide, that every model can be exported to ONNX #789 If you are good with this we could close the PR :)

@khalidMindee
Copy link
Contributor Author

Ah great @felixdittrich92 that's fine for me to close the PR .

@frgfm frgfm deleted the fix-sar-saved-model branch June 23, 2022 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: models Related to doctr.models topic: text recognition Related to the task of text recognition type: breaking change Introducing a breaking change wontfix This will not be worked on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants