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

support Chinese for kie show result #464

Merged
merged 4 commits into from
Aug 30, 2021

Conversation

cuhk-hbsun
Copy link
Collaborator

No description provided.

Comment on lines 419 to 429
font_size = int(new_box[3][1] - new_box[0][1])
dirname, _ = os.path.split(os.path.abspath(__file__))
font_path = os.path.join(dirname, 'font.TTF')
if not os.path.exists(font_path):
url = ('http://download.openmmlab.com/mmocr/data/font.TTF')
print(f'Downloading {url} ...')
local_filename, _ = urllib.request.urlretrieve(url)
shutil.move(local_filename, font_path)
fnt = ImageFont.truetype(font_path, font_size)
pred_draw.text((x_min * 2, y_min), text, font=fnt, fill=(0, 0, 255))
del pred_draw
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not use draw_texts_by_pil()?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

draw_texts_by_pil will draw text on a new empty image (then return) but not the original image. Here we need draw the text on pred_img directly.

Copy link
Collaborator

Choose a reason for hiding this comment

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

How about adding an in_place option to draw_texts_by_pil?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

cannot done in_place since it need to convert numpy array to PIL Image and then PIL Image to numpy array

tools/kie_test_imgs.py Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Aug 26, 2021

Codecov Report

Merging #464 (db8f8d0) into main (f9d158f) will decrease coverage by 0.00%.
The diff coverage is 82.14%.

❗ Current head db8f8d0 differs from pull request most recent head ecb9bbb. Consider uploading reports for the commit ecb9bbb to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##             main     #464      +/-   ##
==========================================
- Coverage   85.72%   85.72%   -0.01%     
==========================================
  Files         142      142              
  Lines        9516     9532      +16     
  Branches     1360     1365       +5     
==========================================
+ Hits         8158     8171      +13     
- Misses       1045     1046       +1     
- Partials      313      315       +2     
Flag Coverage Δ
unittests 85.72% <82.14%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
mmocr/core/visualize.py 91.91% <82.14%> (-1.32%) ⬇️
mmocr/models/textrecog/convertors/seg.py 94.52% <0.00%> (+2.73%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f9d158f...ecb9bbb. Read the comment docs.

@gaotongxiao gaotongxiao merged commit cc0d4d3 into open-mmlab:main Aug 30, 2021
gaotongxiao pushed a commit to gaotongxiao/mmocr that referenced this pull request Jul 15, 2022
* support Chinese for kie show result

* update visualize

* add arg for draw_texts

* update font_size
gaotongxiao pushed a commit to gaotongxiao/mmocr that referenced this pull request Jul 15, 2022
* support Chinese for kie show result

* update visualize

* add arg for draw_texts

* update font_size
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

kie模型输出结果可视化不支持中文
2 participants