Repository navigation
fix(ocr_bench_v2): write text spotting files as UTF-8 - #1804
Open
RizgarOzan wants to merge 1 commit into
Open
RizgarOzan wants to merge 1 commit into
RizgarOzan wants to merge 1 commit into
Conversation
spotting_evaluation wrote the gt and submission files with the locale encoding, and the scorer reads them back with decode_utf8. On Windows the locale encoding is the ANSI code page, so a prediction like "Café → Exit" raised UnicodeEncodeError before scoring started. I pass encoding='utf-8' to both writes and added a test that gives open() a cp1252 default, so it fails the same way on Linux without the fix.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to the note in #1522 that a few encoding issues are left under
benchmarks/.spotting_evaluationin the OCRBench v2 scorer writes the gt and submission files with the locale encoding, but the scorer reads them back withdecode_utf8. On Windows the locale encoding is the ANSI code page, so as soon as a prediction has a character outside it, for exampleCafé → Exit, the write raisesUnicodeEncodeErrorand the sample never gets scored.I pass
encoding='utf-8'to both writes. The new test intests/benchmark/test_ocr_bench_v2_spotting.pygivesopen()a cp1252 default and reads the zipped files back with the realdecode_utf8, so it fails on Linux too without the fix:pre-commit run --files(ruff check, ruff format and the other hooks) passes on both files. I couldn't run the full spotting metric on Windows because Polygon3 has no wheel there, so the test stubsmain_evaluationand checks what the scorer would read.