open-mmlab / mmpretrain

OpenMMLab Pre-training Toolbox and Benchmark
https://mmpretrain.readthedocs.io/en/latest/
Apache License 2.0
3.38k stars 1.05k forks source link

[Feature] Support Chinese and other Asian characters #1627

Open HuaiyuZhang opened 1 year ago

HuaiyuZhang commented 1 year ago

Describe the feature

Hi team,

I really appreciate your amazing work.

I had some difficulties recently when I tried to display Chinese characters for the ImageClassificationInferencer. To reproduce:

inferencer=ImageClassificationInferencer(
    'config_file_path', 
    pretrained='checkpoint_path'  )
inferencer('test_image.jpg', show_dir="output_path")

The labels were in Chinese; eventually, the predicted label on the image was shown as two squares.

I spend quite some time solving this but failed. There are some workarounds, e.g., manually adding the Chinese label to the raw image. Could the team consider a more native way to support Asian language in the visualizer?

Thanks and regards, Huaiyu

Attachment:

orange

Will you implement it?

Ezra-Yu commented 1 year ago
import matplotlib.pyplot as plt
plt.rcParams["font.sans-serif"]=["SimHei"] #设置字体
plt.rcParams["axes.unicode_minus"]=False #正常显示负号

Try to add these two lines before showing the pictures.

lb-hit commented 1 year ago

@Ezra-Yu hi, I met the same question too,when I use the command:python tools/test.py ${CONFIG_FILE} ${CHECKPOINT_FILE} --show. Which file and where should I modify?