diff --git a/doc/doc_ch/inference.md b/doc/doc_ch/inference.md
index 431cdb5a4a9f24cf5862c159d51be2a07e9d4047..709a07515c316cdfd60b74f0b090d4baeeb290a7 100644
--- a/doc/doc_ch/inference.md
+++ b/doc/doc_ch/inference.md
@@ -24,6 +24,7 @@ inference 模型(`fluid.io.save_inference_model`保存的模型)
- [2. 基于CTC损失的识别模型推理](#基于CTC损失的识别模型推理)
- [3. 基于Attention损失的识别模型推理](#基于Attention损失的识别模型推理)
- [4. 自定义文本识别字典的推理](#自定义文本识别字典的推理)
+ - [5. 多语言模型的推理](#多语言模型的推理)
- [四、方向分类模型推理](#方向识别模型推理)
- [1. 方向分类模型推理](#方向分类模型推理)
@@ -305,6 +306,22 @@ dict_character = list(self.character_str)
python3 tools/infer/predict_rec.py --image_dir="./doc/imgs_words_en/word_336.png" --rec_model_dir="./your inference model" --rec_image_shape="3, 32, 100" --rec_char_type="en" --rec_char_dict_path="your text dict path"
```
+
+### 5. 多语言模型的推理
+如果您需要预测的是其他语言模型,在使用inference模型预测时,需要通过`--rec_char_dict_path`指定使用的字典路径, 同时为了得到正确的可视化结果,
+需要通过 `--vis_font_path` 指定可视化的字体路径,`doc/` 路径下有默认提供的小语种字体,例如韩文识别:
+
+```
+python3 tools/infer/predict_rec.py --image_dir="./doc/imgs_words/korean/1.jpg" --rec_model_dir="./your inference model" --rec_char_type="korean" --rec_char_dict_path="ppocr/utils/korean_dict.txt" --vis_font_path="doc/korean.ttf"
+```
+![](../imgs_words/korean/1.jpg)
+
+执行命令后,上图的预测结果为:
+``` text
+2020-09-19 16:15:05,076-INFO: index: [205 206 38 39]
+2020-09-19 16:15:05,077-INFO: word : 바탕으로
+2020-09-19 16:15:05,077-INFO: score: 0.9171358942985535
+```
## 四、方向分类模型推理
diff --git a/doc/doc_ch/recognition.md b/doc/doc_ch/recognition.md
index 1920be56d1a05bb2f7ade944fd225e690fb484a4..0f4173bef6fbe80e1a14d993e560308a84dcd387 100644
--- a/doc/doc_ch/recognition.md
+++ b/doc/doc_ch/recognition.md
@@ -201,7 +201,19 @@ Optimizer:
```
**注意,预测/评估时的配置文件请务必与训练一致。**
+- 小语种
+PaddleOCR也提供了多语言的, `configs/rec/multi_languages` 路径下的提供了多语言的配置文件,目前PaddleOCR支持的多语言算法有:
+
+| 配置文件 | 算法名称 | backbone | trans | seq | pred | language |
+| :--------: | :-------: | :-------: | :-------: | :-----: | :-----: | :-----: |
+| rec_en_lite_train.yml | CRNN | Mobilenet_v3 small 0.5 | None | BiLSTM | ctc | 英语 |
+| rec_french_lite_train.yml | CRNN | Mobilenet_v3 small 0.5 | None | BiLSTM | ctc | 法语 |
+| rec_ger_lite_train.yml | CRNN | Mobilenet_v3 small 0.5 | None | BiLSTM | ctc | 德语 |
+| rec_japan_lite_train.yml | CRNN | Mobilenet_v3 small 0.5 | None | BiLSTM | ctc | 日语 |
+| rec_korean_lite_train.yml | CRNN | Mobilenet_v3 small 0.5 | None | BiLSTM | ctc | 韩语 |
+
+多语言模型训练方式与中文模型一致,训练数据集均为100w的合成数据,少量的字体和测试数据可以在[百度网盘]()上下载。
### 评估
diff --git a/doc/french.ttf b/doc/french.ttf
new file mode 100644
index 0000000000000000000000000000000000000000..ab68fb197d4479b3b6dec6e85bd5cbaf433a87c5
Binary files /dev/null and b/doc/french.ttf differ
diff --git a/doc/german.ttf b/doc/german.ttf
new file mode 100644
index 0000000000000000000000000000000000000000..ab68fb197d4479b3b6dec6e85bd5cbaf433a87c5
Binary files /dev/null and b/doc/german.ttf differ
diff --git a/doc/imgs_words/french/1.jpg b/doc/imgs_words/french/1.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..077ca28e70b74ed07fa637011c80219aecc448d5
Binary files /dev/null and b/doc/imgs_words/french/1.jpg differ
diff --git a/doc/imgs_words/french/2.jpg b/doc/imgs_words/french/2.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..38a73caa621710a7eb7378603e0152ba9c14dd41
Binary files /dev/null and b/doc/imgs_words/french/2.jpg differ
diff --git a/doc/imgs_words/german/1.jpg b/doc/imgs_words/german/1.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..d26ec9ed14de65c2d27e37693ff0da133e774b94
Binary files /dev/null and b/doc/imgs_words/german/1.jpg differ
diff --git a/doc/imgs_words/japan/1.jpg b/doc/imgs_words/japan/1.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..684879749764a1b6063da32d7910bff911e855f4
Binary files /dev/null and b/doc/imgs_words/japan/1.jpg differ
diff --git a/doc/imgs_words/korean/1.jpg b/doc/imgs_words/korean/1.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..48a89389ae880783a39a13e9b06a861b88948fba
Binary files /dev/null and b/doc/imgs_words/korean/1.jpg differ
diff --git a/doc/imgs_words/korean/2.jpg b/doc/imgs_words/korean/2.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..b24f28914d574be44e147943d906f8634f149ed5
Binary files /dev/null and b/doc/imgs_words/korean/2.jpg differ
diff --git a/doc/japan.ttc b/doc/japan.ttc
new file mode 100644
index 0000000000000000000000000000000000000000..ad68243b968fc87b207928594c585039859b75a9
Binary files /dev/null and b/doc/japan.ttc differ
diff --git a/doc/korean.ttf b/doc/korean.ttf
new file mode 100644
index 0000000000000000000000000000000000000000..e638ce37f67ff1cd9babf73387786eaeb5c52968
Binary files /dev/null and b/doc/korean.ttf differ
diff --git a/tools/infer/predict_system.py b/tools/infer/predict_system.py
index 3e6be234c68dcd82f0f9e844f3ad2859000cec88..29c4d7e8e35ceda3966dfcadcca5f0ae985d1bb1 100755
--- a/tools/infer/predict_system.py
+++ b/tools/infer/predict_system.py
@@ -133,6 +133,7 @@ def main(args):
image_file_list = get_image_file_list(args.image_dir)
text_sys = TextSystem(args)
is_visualize = True
+ font_path = args.vis_font_path
for image_file in image_file_list:
img, flag = check_and_read_gif(image_file)
if not flag:
@@ -160,7 +161,7 @@ def main(args):
scores = [rec_res[i][1] for i in range(len(rec_res))]
draw_img = draw_ocr(
- image, boxes, txts, scores, drop_score=drop_score)
+ image, boxes, txts, scores, drop_score=drop_score, font_path=font_path)
draw_img_save = "./inference_results/"
if not os.path.exists(draw_img_save):
os.makedirs(draw_img_save)
diff --git a/tools/infer/utility.py b/tools/infer/utility.py
index e844a0ae67480e94ef1b9286d3d59e7373e75a5c..a1c7c205bdc6621d7395004bf45cb443d273d9c0 100755
--- a/tools/infer/utility.py
+++ b/tools/infer/utility.py
@@ -71,6 +71,10 @@ def parse_args():
type=str,
default="./ppocr/utils/ppocr_keys_v1.txt")
parser.add_argument("--use_space_char", type=str2bool, default=True)
+ parser.add_argument(
+ "--vis_font_path",
+ type=str,
+ default="./doc/simfang.ttf")
# params for text classifier
parser.add_argument("--use_angle_cls", type=str2bool, default=False)
@@ -198,7 +202,7 @@ def draw_ocr(image,
return image
-def draw_ocr_box_txt(image, boxes, txts):
+def draw_ocr_box_txt(image, boxes, txts, font_path="./doc/simfang.ttf"):
h, w = image.height, image.width
img_left = image.copy()
img_right = Image.new('RGB', (w, h), (255, 255, 255))
@@ -225,7 +229,7 @@ def draw_ocr_box_txt(image, boxes, txts):
if box_height > 2 * box_width:
font_size = max(int(box_width * 0.9), 10)
font = ImageFont.truetype(
- "./doc/simfang.ttf", font_size, encoding="utf-8")
+ font_path, font_size, encoding="utf-8")
cur_y = box[0][1]
for c in txt:
char_size = font.getsize(c)
@@ -235,7 +239,7 @@ def draw_ocr_box_txt(image, boxes, txts):
else:
font_size = max(int(box_height * 0.8), 10)
font = ImageFont.truetype(
- "./doc/simfang.ttf", font_size, encoding="utf-8")
+ font_path, font_size, encoding="utf-8")
draw_right.text(
[box[0][0], box[0][1]], txt, fill=(0, 0, 0), font=font)
img_left = Image.blend(image, img_left, 0.5)