transformers icon indicating copy to clipboard operation
transformers copied to clipboard

Added option for users to modify config parameter when calling pytess…

Open kelvinAI opened this issue 3 years ago • 7 comments

What does this PR do?

This is a feature addition to LayoutLMV3, a follow up to the same feature added to LayoutLMV2's feature extractor

Giving user option to set config parameter used by Tesseract when performing feature extraction. Eg. to change psm levels while performing transcription by passing in '--psm 10' to config parameter while invoking image_to_data

It is shown that changing the psm values greatly influences the end result of LayoutLMV2/XLM/LMV3, and the specific psm value is different depending on the document formatting. Refer : PSM

pytesseract.image_to_data(image, lang=lang, output_type="dict", config="--psm 10") 

Users can now set the tesseract config parameter during Processor initialization, like so:

processor = AutoProcessor.from_pretrained("microsoft/layoutlmv3-base", ocr_lang="eng", tesseract_config="--psm 5")

Before submitting

  • [❌] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • [✔️] Did you read the contributor guideline, Pull Request section?
  • [✔️] Was this discussed/approved via a Github issue or the forum? Please add a link to it if that's the case.
  • [✔️] Did you make sure to update the documentation with your changes? Here are the documentation guidelines, and here are tips on formatting docstrings.
  • [❌] Did you write any new necessary tests?

kelvinAI avatar Jul 01 '22 18:07 kelvinAI

The documentation is not available anymore as the PR was closed or merged.

@NielsRogge Added & tested LayoutLMV3 feature extractor

kelvinAI avatar Jul 01 '22 18:07 kelvinAI

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the contributing guidelines are likely to be ignored.

github-actions[bot] avatar Aug 01 '22 15:08 github-actions[bot]

Hmm @kelvinAI for some reason I'm seeing "files changed = 0", did something go wrong here?

NielsRogge avatar Aug 26 '22 14:08 NielsRogge

Hey @NielsRogge , the changes for this branch have already been merged into this pr as discussed earlier. And since that PR have already been merged with main earlier that's probably why it's showing 0 files changed over here. Looking at the autogenerated documentation for main it seems that the changes for both LayoutLMv2 and LayoutLMv3 are already included :). Could you please help to verify?

kelvinAI avatar Aug 26 '22 19:08 kelvinAI

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the contributing guidelines are likely to be ignored.

github-actions[bot] avatar Sep 20 '22 15:09 github-actions[bot]

Yes, so seems like you can close this PR.

NielsRogge avatar Sep 20 '22 15:09 NielsRogge

Right, forgot to close this :)

kelvinAI avatar Sep 24 '22 03:09 kelvinAI