Skip to content

📄 Awesome OCR multiple programing languages toolkits based on ONNX Runtime, OpenVINO, MNN, PaddlePaddle, TensorRT and PyTorch.

Update ocrweb

SWHL9f9f8434be19
diff --git a/ocrweb/README.md b/ocrweb/README.md
index e4934c5..eec0ccd 100755
--- a/ocrweb/README.md
+++ b/ocrweb/README.md
@@ -1,49 +1,55 @@
+## RapidOCR Web Demo
+
### 相关问题
-1. 各个阶段使用的模型有哪些?
- 可以从`task.py`中看到
- ```python
- det_model_path = 'resources/models/ch_PP-OCRv2_det_infer.onnx'
- cls_model_path = 'resources/models/ch_ppocr_mobile_v2.0_cls_infer.onnx'
- rec_model_path = 'resources/models/ch_ppocr_mobile_v2.0_rec_infer.onnx'
- ```
+1. 各个阶段使用的模型以及配置参数有哪些?
+ - 所有相关参数配置参见当前目录下的`config.yaml`文件
+ - 其中给出了使用模型,以及具体参数,参数具体介绍参见:[Link](https://github.com/RapidAI/RapidOCR/blob/main/python/README.md#configyaml%E4%B8%AD%E5%B8%B8%E7%94%A8%E5%8F%82%E6%95%B0%E4%BB%8B%E7%BB%8D)
2. 网页上显示的推理时间可以具体解释一下吗?
<div align="center">
<img src="../assets/ocrweb_time.jpg" width="100%" height="100%">
</div>
-3. OCR各个阶段的参数值都从哪里可以看到?
- - 从各个阶段的目录下对应类的初始化函数可以看到
### 运行
1. 安装`requirements.txt`下相关包
```shell
pip install -r requirements.txt
```
-2. 相关模型
- - 下载链接:[提取码:30jv](https://pan.baidu.com/s/1qkqWK4wRdMjqGGbzR-FyWg)
- - 将模型放到`models`目录即可
+2. 下载`resources`目录
+ - 下载链接:[百度网盘](https://pan.baidu.com/s/1PTcgXG2zEgQU6A_A3kGJ3Q?pwd=jhai) | [Google Drive](https://drive.google.com/drive/folders/1x_a9KpCo_1blxH1xFOfgKVkw1HYRVywY?usp=sharing)
+ - 最终目录结构如下:
+ ```text
+ ocrweb
+ ├── README.md
+ ├── config.yaml
+ ├── main.py
+ ├── requirements.txt
+ ├── task.py
+ ├── rapidocr_onnxruntime
+ │   ├── __init__.py
+ │   ├── ch_ppocr_v2_cls
+ │   ├── ch_ppocr_v2_det
+ │   ├── ch_ppocr_v2_rec
+ │   ├── ch_ppocr_v3_rec
+ │   └── rapid_ocr_api.py
+ ├── resources
+ │   ├── models
+ │ │   ├── ch_PP-OCRv2_det_infer.onnx
+ │ │   ├── ch_ppocr_mobile_v2.0_cls_infer.onnx
+ │ │   └── ch_ppocr_mobile_v2.0_rec_infer.onnx
+ │   └── rec_dict
+ │ ├── en_dict.txt
+ │ ├── japan_dict.txt
+ │ ├── korean_dict.txt
+ │ └── ppocr_keys_v1.txt
+ ├── static
+ │   ├── css
+ │   └── js
+ └── templates
+ └── index.html
+ ```
3. 运行`main.py`
```shell
python main.py
```
-4. 打开`http://127.0.0.1:9003/`,即可
-
-### 目录结构
-```text
-.
-├── main.py
-├── README.md
-├── resources
-│ ├── rapidOCR.py
-│ ├── ch_ppocr_mobile_v2_cls
-│ ├── ch_ppocr_mobile_v2_det
-│ ├── ch_ppocr_mobile_v2_rec
-│ ├── __init__.py
-│ └── models
-├── static
-│ ├── css
-│ └── js
-├── task.py
-└── templates
- └── index.html
-```
\ No newline at end of file
+4. 打开`http://127.0.0.1:9003/`,即可, enjoy this.
diff --git a/ocrweb/config.yaml b/ocrweb/config.yaml
new file mode 100644
index 0000000..0c59831
--- /dev/null
+++ b/ocrweb/config.yaml
@@ -0,0 +1,48 @@
+Global:
+ text_score: 0.5
+ use_angle_cls: true
+ print_verbose: true
+
+Det:
+ module_name: ch_ppocr_v2_det
+ class_name: TextDetector
+ model_path: resources/models/ch_PP-OCRv2_det_infer.onnx
+
+ pre_process:
+ DetResizeForTest:
+ limit_side_len: 736
+ limit_type: min
+ NormalizeImage:
+ std: [0.229, 0.224, 0.225]
+ mean: [0.485, 0.456, 0.406]
+ scale: 1./255.
+ order: hwc
+ ToCHWImage:
+ KeepKeys:
+ keep_keys: ['image', 'shape']
+
+ post_process:
+ thresh: 0.3
+ box_thresh: 0.5
+ max_candidates: 1000
+ unclip_ratio: 1.6
+ use_dilation: true
+
+Cls:
+ module_name: ch_ppocr_v2_cls
+ class_name: TextClassifier
+ model_path: resources/models/ch_ppocr_mobile_v2.0_cls_infer.onnx
+
+ cls_image_shape: [3, 48, 192]
+ cls_batch_num: 6
+ cls_thresh: 0.9
+ label_list: ['0', '180']
+
+Rec:
+ module_name: ch_ppocr_v2_rec
+ class_name: TextRecognizer
+ model_path: resources/models/ch_ppocr_mobile_v2.0_rec_infer.onnx
+
+ rec_img_shape: [3, 32, 320]
+ rec_batch_num: 6
+ keys_path: resources/rec_dict/ppocr_keys_v1.txt
diff --git a/ocrweb/rapidocr_onnxruntime/__init__.py b/ocrweb/rapidocr_onnxruntime/__init__.py
new file mode 100644
index 0000000..90121b5
--- /dev/null
+++ b/ocrweb/rapidocr_onnxruntime/__init__.py
@@ -0,0 +1,4 @@
+# -*- encoding: utf-8 -*-
+# @Author: SWHL
+# @Contact: [email protected]
+from .rapid_ocr_api import TextSystem
\ No newline at end of file
diff --git a/ocrweb/rapidocr_onnxruntime/ch_ppocr_v2_cls/__init__.py b/ocrweb/rapidocr_onnxruntime/ch_ppocr_v2_cls/__init__.py
new file mode 100644
index 0000000..c5a5e1f
--- /dev/null
+++ b/ocrweb/rapidocr_onnxruntime/ch_ppocr_v2_cls/__init__.py
@@ -0,0 +1,4 @@
+# -*- encoding: utf-8 -*-
+# @Author: SWHL
+# @Contact: [email protected]
+from .text_cls import TextClassifier
\ No newline at end of file
diff --git a/ocrweb/rapidocr_onnxruntime/ch_ppocr_v2_cls/config.yaml b/ocrweb/rapidocr_onnxruntime/ch_ppocr_v2_cls/config.yaml
new file mode 100644
index 0000000..e6fa00e
--- /dev/null
+++ b/ocrweb/rapidocr_onnxruntime/ch_ppocr_v2_cls/config.yaml
@@ -0,0 +1,6 @@
+model_path: resources/models/ch_ppocr_mobile_v2.0_cls_infer.onnx
+
+cls_image_shape: [3, 48, 192]
+cls_batch_num: 6
+cls_thresh: 0.9
+label_list: ['0', '180']
\ No newline at end of file
diff --git a/ocrweb/resources/ch_ppocr_mobile_v2_cls/text_cls.py b/ocrweb/rapidocr_onnxruntime/ch_ppocr_v2_cls/text_cls.py
similarity index 57%
rename from ocrweb/resources/ch_ppocr_mobile_v2_cls/text_cls.py
rename to ocrweb/rapidocr_onnxruntime/ch_ppocr_v2_cls/text_cls.py
index c283561..fc06ac1 100644
--- a/ocrweb/resources/ch_ppocr_mobile_v2_cls/text_cls.py
+++ b/ocrweb/rapidocr_onnxruntime/ch_ppocr_v2_cls/text_cls.py
@@ -15,105 +15,91 @@ import argparse
import copy
import math
import time
+from typing import List
import cv2
import numpy as np
-import onnxruntime
+import onnxruntime as ort
try:
- from .utils import ClsPostProcess, check_and_read_gif, get_image_file_list
+ from .utils import ClsPostProcess, read_yaml
except:
- from utils import ClsPostProcess, check_and_read_gif, get_image_file_list
+ from utils import ClsPostProcess, read_yaml
class TextClassifier(object):
- def __init__(self, cls_model_path):
- self.cls_image_shape = [3, 48, 192]
- self.cls_batch_num = 6
- self.cls_thresh = 0.9
- self.postprocess_op = ClsPostProcess(label_list=['0', '180'])
+ def __init__(self, config):
+ self.cls_image_shape = config['cls_image_shape']
+ self.cls_batch_num = config['cls_batch_num']
+ self.cls_thresh = config['cls_thresh']
+ self.postprocess_op = ClsPostProcess(config['label_list'])
- sess_opt = onnxruntime.SessionOptions()
+ sess_opt = ort.SessionOptions()
sess_opt.log_severity_level = 4
sess_opt.enable_cpu_mem_arena = False
- self.session = onnxruntime.InferenceSession(cls_model_path, sess_opt)
+ self.session = ort.InferenceSession(config['model_path'], sess_opt)
+ self.input_name = self.session.get_inputs()[0].name
def resize_norm_img(self, img):
- imgC, imgH, imgW = self.cls_image_shape
- h = img.shape[0]
- w = img.shape[1]
+ img_c, img_h, img_w = self.cls_image_shape
+ h, w = img.shape[:2]
ratio = w / float(h)
- if math.ceil(imgH * ratio) > imgW:
- resized_w = imgW
+ if math.ceil(img_h * ratio) > img_w:
+ resized_w = img_w
else:
- resized_w = int(math.ceil(imgH * ratio))
- resized_image = cv2.resize(img, (resized_w, imgH))
+ resized_w = int(math.ceil(img_h * ratio))
+
+ resized_image = cv2.resize(img, (resized_w, img_h))
resized_image = resized_image.astype('float32')
- if self.cls_image_shape[0] == 1:
+ if img_c == 1:
resized_image = resized_image / 255
resized_image = resized_image[np.newaxis, :]
else:
resized_image = resized_image.transpose((2, 0, 1)) / 255
+
resized_image -= 0.5
resized_image /= 0.5
- padding_im = np.zeros((imgC, imgH, imgW), dtype=np.float32)
- padding_im[:, :, 0:resized_w] = resized_image
+ padding_im = np.zeros((img_c, img_h, img_w), dtype=np.float32)
+ padding_im[:, :, :resized_w] = resized_image
return padding_im
- def load_image(self, image_dir):
- image_file_list = get_image_file_list(image_dir)
- valid_image_file_list = []
- img_list = []
- for image_file in image_file_list:
- img, flag = check_and_read_gif(image_file)
- if not flag:
- img = cv2.imread(image_file)
- if img is None:
- print(f"error in loading image:{image_file}")
- continue
- valid_image_file_list.append(image_file)
- img_list.append(img)
- return img_list
-
- def __call__(self, image_dir):
- elapse = 0
- if isinstance(image_dir[0], (list, str)):
- img_list = self.load_image(image_dir)
- else:
- img_list = image_dir
+
+ def __call__(self, img_list: List[np.ndarray]):
+ if isinstance(img_list, np.ndarray):
+ img_list = [img_list]
img_list = copy.deepcopy(img_list)
- img_num = len(img_list)
# Calculate the aspect ratio of all text bars
- width_list = []
- for img in img_list:
- width_list.append(img.shape[1] / float(img.shape[0]))
+ width_list = [img.shape[1] / float(img.shape[0]) for img in img_list]
# Sorting can speed up the cls process
indices = np.argsort(np.array(width_list))
+ img_num = len(img_list)
cls_res = [['', 0.0]] * img_num
batch_num = self.cls_batch_num
+ elapse = 0
for beg_img_no in range(0, img_num, batch_num):
end_img_no = min(img_num, beg_img_no + batch_num)
- norm_img_batch = []
max_wh_ratio = 0
for ino in range(beg_img_no, end_img_no):
h, w = img_list[indices[ino]].shape[0:2]
wh_ratio = w * 1.0 / h
max_wh_ratio = max(max_wh_ratio, wh_ratio)
+
+ norm_img_batch = []
for ino in range(beg_img_no, end_img_no):
norm_img = self.resize_norm_img(img_list[indices[ino]])
norm_img = norm_img[np.newaxis, :]
norm_img_batch.append(norm_img)
- norm_img_batch = np.concatenate(norm_img_batch)
- onnx_inputs = {self.session.get_inputs()[0].name: norm_img_batch}
+ norm_img_batch = np.concatenate(norm_img_batch).astype(np.float32)
starttime = time.time()
+ onnx_inputs = {self.input_name: norm_img_batch}
prob_out = self.session.run(None, onnx_inputs)[0]
-
cls_result = self.postprocess_op(prob_out)
+ elapse += time.time() - starttime
for rno in range(len(cls_result)):
label, score = cls_result[rno]
@@ -121,19 +107,20 @@ class TextClassifier(object):
if '180' in label and score > self.cls_thresh:
img_list[indices[beg_img_no + rno]] = cv2.rotate(
img_list[indices[beg_img_no + rno]], 1)
-
- elapse += time.time() - starttime
return img_list, cls_res, elapse
if __name__ == "__main__":
parser = argparse.ArgumentParser()
- parser.add_argument('--image_dir', type=str, help='image_dir|image_path')
- parser.add_argument('--cls_model_dir', type=str, help='cls_model_dir')
+ parser.add_argument('--image_path', type=str, help='image_dir|image_path')
+ parser.add_argument('--config_path', type=str, default='config.yaml')
args = parser.parse_args()
- text_classifier = TextClassifier(args.cls_model_dir)
+ config = read_yaml(args.config_path)
+
+ text_classifier = TextClassifier(config)
- img_list, cls_res, predict_time = text_classifier(args.image_dir)
+ img = cv2.imread(args.image_path)
+ img_list, cls_res, predict_time = text_classifier(img)
for ino in range(len(img_list)):
print(f"分类结果:{cls_res[ino]}")
diff --git a/ocrweb/rapidocr_onnxruntime/ch_ppocr_v2_cls/utils.py b/ocrweb/rapidocr_onnxruntime/ch_ppocr_v2_cls/utils.py
new file mode 100644
index 0000000..dae9175
--- /dev/null
+++ b/ocrweb/rapidocr_onnxruntime/ch_ppocr_v2_cls/utils.py
@@ -0,0 +1,38 @@
+# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+import yaml
+
+
+def read_yaml(yaml_path):
+ with open(yaml_path, 'rb') as f:
+ data = yaml.load(f, Loader=yaml.Loader)
+ return data
+
+
+class ClsPostProcess(object):
+ """ Convert between text-label and text-index """
+
+ def __init__(self, label_list):
+ super(ClsPostProcess, self).__init__()
+ self.label_list = label_list
+
+ def __call__(self, preds, label=None):
+ pred_idxs = preds.argmax(axis=1)
+ decode_out = [(self.label_list[idx], preds[i, idx])
+ for i, idx in enumerate(pred_idxs)]
+ if label is None:
+ return decode_out
+
+ label = [(self.label_list[idx], 1.0) for idx in label]
+ return decode_out, label
\ No newline at end of file
diff --git a/ocrweb/rapidocr_onnxruntime/ch_ppocr_v2_det/__init__.py b/ocrweb/rapidocr_onnxruntime/ch_ppocr_v2_det/__init__.py
new file mode 100644
index 0000000..dd23c8b
--- /dev/null
+++ b/ocrweb/rapidocr_onnxruntime/ch_ppocr_v2_det/__init__.py
@@ -0,0 +1,4 @@
+# -*- encoding: utf-8 -*-
+# @Author: SWHL
+# @Contact: [email protected]
+from .text_detect import TextDetector
\ No newline at end of file
diff --git a/ocrweb/rapidocr_onnxruntime/ch_ppocr_v2_det/config.yaml b/ocrweb/rapidocr_onnxruntime/ch_ppocr_v2_det/config.yaml
new file mode 100644
index 0000000..0f08b09
--- /dev/null
+++ b/ocrweb/rapidocr_onnxruntime/ch_ppocr_v2_det/config.yaml
@@ -0,0 +1,21 @@
+model_path: resources/models/ch_ppocr_server_v2.0_det_infer.onnx
+
+pre_process:
+ DetResizeForTest:
+ limit_side_len: 736
+ limit_type: min
+ NormalizeImage:
+ std: [0.229, 0.224, 0.225]
+ mean: [0.485, 0.456, 0.406]
+ scale: 1./255.
+ order: hwc
+ ToCHWImage:
+ KeepKeys:
+ keep_keys: ['image', 'shape']
+
+post_process:
+ thresh: 0.3
+ box_thresh: 0.5
+ max_candidates: 1000
+ unclip_ratio: 1.6
+ use_dilation: true
diff --git a/ocrweb/resources/ch_ppocr_mobile_v2_det/text_detect.py b/ocrweb/rapidocr_onnxruntime/ch_ppocr_v2_det/text_detect.py
similarity index 65%
rename from ocrweb/resources/ch_ppocr_mobile_v2_det/text_detect.py
rename to ocrweb/rapidocr_onnxruntime/ch_ppocr_v2_det/text_detect.py
index bb29e38..30af2e3 100644
--- a/ocrweb/resources/ch_ppocr_mobile_v2_det/text_detect.py
+++ b/ocrweb/rapidocr_onnxruntime/ch_ppocr_v2_det/text_detect.py
@@ -20,45 +20,23 @@ import numpy as np
import onnxruntime
try:
- from .utils import (DBPostProcess, check_and_read_gif, create_operators,
- draw_text_det_res, transform)
+ from .utils import (DBPostProcess, create_operators,
+ draw_text_det_res, transform, read_yaml)
except:
- from utils import (DBPostProcess, check_and_read_gif, create_operators,
- draw_text_det_res, transform)
+ from utils import (DBPostProcess, create_operators,
+ draw_text_det_res, transform, read_yaml)
class TextDetector(object):
- def __init__(self, det_model_path):
- pre_process_list = [{
- 'DetResizeForTest': {
- 'limit_side_len': 736,
- 'limit_type': 'min'
- }
- }, {
- 'NormalizeImage': {
- 'std': [0.229, 0.224, 0.225],
- 'mean': [0.485, 0.456, 0.406],
- 'scale': '1./255.',
- 'order': 'hwc'
- }
- }, {
- 'ToCHWImage': None
- }, {
- 'KeepKeys': {
- 'keep_keys': ['image', 'shape']
- }
- }]
-
- self.preprocess_op = create_operators(pre_process_list)
- self.postprocess_op = DBPostProcess(thresh=0.3,
- box_thresh=0.5,
- max_candidates=1000,
- unclip_ratio=2.0,
- use_dilation=True)
+ def __init__(self, config):
+ self.preprocess_op = create_operators(config['pre_process'])
+ self.postprocess_op = DBPostProcess(**config['post_process'])
+
sess_opt = onnxruntime.SessionOptions()
sess_opt.log_severity_level = 4
sess_opt.enable_cpu_mem_arena = False
- self.session = onnxruntime.InferenceSession(det_model_path, sess_opt)
+ self.session = onnxruntime.InferenceSession(config['model_path'],
+ sess_opt)
self.input_name = self.session.get_inputs()[0].name
self.output_name = self.session.get_outputs()[0].name
@@ -107,48 +85,40 @@ class TextDetector(object):
return dt_boxes
def __call__(self, img):
- starttime = time.time()
-
- ori_shape = img.shape[:2]
-
+ ori_im = img.copy()
data = {'image': img}
data = transform(data, self.preprocess_op)
img, shape_list = data
if img is None:
return None, 0
- img = np.expand_dims(img, axis=0)
- img = img.astype(np.float32)
+
+ img = np.expand_dims(img, axis=0).astype(np.float32)
shape_list = np.expand_dims(shape_list, axis=0)
+ starttime = time.time()
preds = self.session.run([self.output_name],
{self.input_name: img})
post_result = self.postprocess_op(preds[0], shape_list)
- dt_boxes = post_result[0]['points']
- dt_boxes = self.filter_tag_det_res(dt_boxes, ori_shape)
+ dt_boxes = post_result[0]['points']
+ dt_boxes = self.filter_tag_det_res(dt_boxes, ori_im.shape)
elapse = time.time() - starttime
return dt_boxes, elapse
if __name__ == "__main__":
parser = argparse.ArgumentParser()
- parser.add_argument('--image_path', type=str, default=None,
- help='image_path|image_dir')
- parser.add_argument('--model_path', type=str, default=None,
- help='model_path')
+ parser.add_argument('--config_path', type=str, default='config.yaml')
+ parser.add_argument('--image_path', type=str, default=None)
args = parser.parse_args()
- text_detector = TextDetector(args.model_path)
+ config = read_yaml(args.config_path)
- img, flag = check_and_read_gif(args.image_path)
- if not flag:
- img = cv2.imread(args.image_path)
- if img is None:
- raise ValueError(f"error in loading image:{args.image_path}")
+ text_detector = TextDetector(config)
+ img = cv2.imread(args.image_path)
dt_boxes, elapse = text_detector(img)
-
src_im = draw_text_det_res(dt_boxes, args.image_path)
cv2.imwrite('det_results.jpg', src_im)
print('图像已经保存为det_results.jpg了')
diff --git a/ocrweb/resources/ch_ppocr_mobile_v2_det/utils.py b/ocrweb/rapidocr_onnxruntime/ch_ppocr_v2_det/utils.py
similarity index 83%
rename from ocrweb/resources/ch_ppocr_mobile_v2_det/utils.py
rename to ocrweb/rapidocr_onnxruntime/ch_ppocr_v2_det/utils.py
index 1235d2b..ffbd17f 100644
--- a/ocrweb/resources/ch_ppocr_mobile_v2_det/utils.py
+++ b/ocrweb/rapidocr_onnxruntime/ch_ppocr_v2_det/utils.py
@@ -25,47 +25,50 @@ import numpy as np
import pyclipper
import six
from shapely.geometry import Polygon
-from PIL import Image
+import yaml
+
+
+def read_yaml(yaml_path):
+ with open(yaml_path, 'rb') as f:
+ data = yaml.load(f, Loader=yaml.Loader)
+ return data
class DecodeImage(object):
""" decode image """
- def __init__(self, img_mode='RGB', channel_first=False, **kwargs):
+ def __init__(self, img_mode='RGB', channel_first=False):
self.img_mode = img_mode
self.channel_first = channel_first
def __call__(self, data):
img = data['image']
if six.PY2:
- assert type(img) is str and len(
- img) > 0, "invalid input 'img' in DecodeImage"
+ assert type(img) is str and len(img) > 0, "invalid input 'img' in DecodeImage"
else:
- assert type(img) is bytes and len(
- img) > 0, "invalid input 'img' in DecodeImage"
+ assert type(img) is bytes and len(img) > 0, "invalid input 'img' in DecodeImage"
+
img = np.frombuffer(img, dtype='uint8')
img = cv2.imdecode(img, 1)
if img is None:
return None
+
if self.img_mode == 'GRAY':
img = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR)
elif self.img_mode == 'RGB':
- assert img.shape[2] == 3, 'invalid shape of image[%s]' % (
- img.shape)
+ assert img.shape[2] == 3, f'invalid shape of image[{img.shape}]'
img = img[:, :, ::-1]
if self.channel_first:
img = img.transpose((2, 0, 1))
-
data['image'] = img
return data
class NormalizeImage(object):
- """ normalize image such as substract mean, divide std
- """
+ """ normalize image such as substract mean, divide std"""
- def __init__(self, scale=None, mean=None, std=None, order='chw', **kwargs):
+ def __init__(self, scale=None, mean=None, std=None, order='chw'):
if isinstance(scale, str):
scale = eval(scale)
self.scale = np.float32(scale if scale is not None else 1.0 / 255.0)
@@ -77,22 +80,14 @@ class NormalizeImage(object):
self.std = np.array(std).reshape(shape).astype('float32')
def __call__(self, data):
- img = data['image']
- if isinstance(img, Image.Image):
- img = np.array(img)
-
- assert isinstance(img,
- np.ndarray), "invalid input 'img' in NormalizeImage"
- data['image'] = (
- img.astype('float32') * self.scale - self.mean) / self.std
+ img = np.array(data['image']).astype(np.float32)
+ data['image'] = (img * self.scale - self.mean) / self.std
return data
class ToCHWImage(object):
- """ convert hwc image to chw image
- """
-
- def __init__(self, **kwargs):
+ """ convert hwc image to chw image"""
+ def __init__(self):
pass
def __call__(self, data):
@@ -105,7 +100,7 @@ class ToCHWImage(object):
class KeepKeys(object):
- def __init__(self, keep_keys, **kwargs):
+ def __init__(self, keep_keys):
self.keep_keys = keep_keys
def __call__(self, data):
@@ -239,37 +234,14 @@ def transform(data, ops=None):
return data
-def check_and_read_gif(img_path):
- if os.path.basename(img_path)[-3:] in ['gif', 'GIF']:
- gif = cv2.VideoCapture(img_path)
- ret, frame = gif.read()
- if not ret:
- print("Cannot read {}. This gif image maybe corrupted.")
- return None, False
- if len(frame.shape) == 2 or frame.shape[-1] == 1:
- frame = cv2.cvtColor(frame, cv2.COLOR_GRAY2RGB)
- imgvalue = frame[:, :, ::-1]
- return imgvalue, True
- return None, False
-
-
-def create_operators(op_param_list, global_config=None):
+def create_operators(op_param_dict):
"""
create operators based on the config
-
- Args:
- params(list): a dict list, used to create some operators
"""
- assert isinstance(
- op_param_list, list), ('operator config should be a list')
ops = []
- for operator in op_param_list:
- assert isinstance(operator,
- dict) and len(operator) == 1, "yaml format error"
- op_name = list(operator)[0]
- param = {} if operator[op_name] is None else operator[op_name]
- if global_config is not None:
- param.update(global_config)
+ for op_name, param in op_param_dict.items():
+ if param is None:
+ param = {}
op = eval(op_name)(**param)
ops.append(op)
return ops
@@ -285,24 +257,24 @@ def draw_text_det_res(dt_boxes, img_path):
class DBPostProcess(object):
- """
- The post process for Differentiable Binarization (DB).
- """
+ """The post process for Differentiable Binarization (DB)."""
def __init__(self,
thresh=0.3,
box_thresh=0.7,
max_candidates=1000,
unclip_ratio=2.0,
- use_dilation=False,
- **kwargs):
+ use_dilation=False):
self.thresh = thresh
self.box_thresh = box_thresh
self.max_candidates = max_candidates
self.unclip_ratio = unclip_ratio
self.min_size = 3
- self.dilation_kernel = None if not use_dilation else np.array(
- [[1, 1], [1, 1]])
+
+ if use_dilation:
+ self.dilation_kernel = np.array([[1, 1], [1, 1]])
+ else:
+ self.dilation_kernel = None
def boxes_from_bitmap(self, pred, _bitmap, dest_width, dest_height):
'''
diff --git a/ocrweb/resources/ch_ppocr_mobile_v2_rec/__init__.py b/ocrweb/rapidocr_onnxruntime/ch_ppocr_v2_rec/__init__.py
similarity index 100%
rename from ocrweb/resources/ch_ppocr_mobile_v2_rec/__init__.py
rename to ocrweb/rapidocr_onnxruntime/ch_ppocr_v2_rec/__init__.py
diff --git a/ocrweb/rapidocr_onnxruntime/ch_ppocr_v2_rec/config.yaml b/ocrweb/rapidocr_onnxruntime/ch_ppocr_v2_rec/config.yaml
new file mode 100644
index 0000000..3c3c9df
--- /dev/null
+++ b/ocrweb/rapidocr_onnxruntime/ch_ppocr_v2_rec/config.yaml
@@ -0,0 +1,5 @@
+model_path: resources/models/ch_ppocr_server_v2.0_rec_infer.onnx
+
+rec_img_shape: [3, 32, 320]
+rec_batch_num: 6
+keys_path: resources/rec_dict/ppocr_keys_v1.txt
diff --git a/ocrweb/resources/ch_ppocr_mobile_v2_rec/text_recognize.py b/ocrweb/rapidocr_onnxruntime/ch_ppocr_v2_rec/text_recognize.py
similarity index 58%
rename from ocrweb/resources/ch_ppocr_mobile_v2_rec/text_recognize.py
rename to ocrweb/rapidocr_onnxruntime/ch_ppocr_v2_rec/text_recognize.py
index fa827e9..2753ea7 100644
--- a/ocrweb/resources/ch_ppocr_mobile_v2_rec/text_recognize.py
+++ b/ocrweb/rapidocr_onnxruntime/ch_ppocr_v2_rec/text_recognize.py
@@ -15,116 +15,92 @@ import argparse
import math
import time
from pathlib import Path
+from typing import List
import cv2
import numpy as np
import onnxruntime
try:
- from .utils import CTCLabelDecode, check_and_read_gif, get_image_file_list
+ from .utils import CTCLabelDecode, read_yaml
except:
- from utils import CTCLabelDecode, check_and_read_gif, get_image_file_list
-
-
-root_path = Path(__file__).parent
+ from utils import CTCLabelDecode, read_yaml
class TextRecognizer(object):
- def __init__(self, rec_model_path):
- self.rec_image_shape = [3, 32, 320]
- self.character_type = 'ch'
- self.rec_batch_num = 6
- self.rec_algorithm = 'CRNN'
-
- self.character_dict_path = str(root_path / 'ppocr_keys_v1.txt')
- self.use_space_char = True
- self.postprocess_op = CTCLabelDecode(self.character_dict_path,
- self.character_type,
- self.use_space_char)
+ def __init__(self, config):
+ self.rec_image_shape = config['rec_img_shape']
+ self.rec_batch_num = config['rec_batch_num']
+ self.character_dict_path = config['keys_path']
+ self.postprocess_op = CTCLabelDecode(self.character_dict_path)
sess_opt = onnxruntime.SessionOptions()
sess_opt.log_severity_level = 4
sess_opt.enable_cpu_mem_arena = False
- self.session = onnxruntime.InferenceSession(rec_model_path, sess_opt)
+ self.session = onnxruntime.InferenceSession(config['model_path'],
+ sess_opt)
+ self.input_name = self.session.get_inputs()[0].name
def resize_norm_img(self, img, max_wh_ratio):
img_channel, img_height, img_width = self.rec_image_shape
assert img_channel == img.shape[2]
- if self.character_type == "ch":
- img_width = int((32 * max_wh_ratio))
- max_wh_ratio = 1
+
+ img_width = int((32 * max_wh_ratio))
+ max_wh_ratio = 1
+
h, w = img.shape[:2]
ratio = w / float(h)
if math.ceil(img_height * ratio) > img_width:
resized_w = img_width
else:
resized_w = int(math.ceil(img_height * ratio))
+
resized_image = cv2.resize(img, (resized_w, img_height))
resized_image = resized_image.astype('float32')
resized_image = resized_image.transpose((2, 0, 1)) / 255
resized_image -= 0.5
resized_image /= 0.5
+
padding_im = np.zeros((img_channel, img_height, img_width),
dtype=np.float32)
padding_im[:, :, 0:resized_w] = resized_image
return padding_im
- @staticmethod
- def load_image(image_dir):
- image_file_list = get_image_file_list(image_dir)
- valid_image_file_list = []
- img_list = []
- for image_file in image_file_list:
- img, flag = check_and_read_gif(image_file)
- if not flag:
- img = cv2.imread(image_file)
- if img is None:
- print(f"error in loading image:{image_file}")
- continue
- valid_image_file_list.append(image_file)
- img_list.append(img)
- return img_list
-
- def __call__(self, image_dir):
- elapse = 0
- if not isinstance(image_dir, list):
- img_list = self.load_image(image_dir)
- else:
- img_list = image_dir
- img_num = len(img_list)
+ def __call__(self, img_list: List[np.ndarray]):
+ if isinstance(img_list, np.ndarray):
+ img_list = [img_list]
# Calculate the aspect ratio of all text bars
- width_list = []
- for img in img_list:
- width_list.append(img.shape[1] / float(img.shape[0]))
+ width_list = [img.shape[1] / float(img.shape[0]) for img in img_list]
# Sorting can speed up the recognition process
indices = np.argsort(np.array(width_list))
+ img_num = len(img_list)
rec_res = [['', 0.0]] * img_num
+
batch_num = self.rec_batch_num
+ elapse = 0
for beg_img_no in range(0, img_num, batch_num):
end_img_no = min(img_num, beg_img_no + batch_num)
- norm_img_batch = []
max_wh_ratio = 0
for ino in range(beg_img_no, end_img_no):
h, w = img_list[indices[ino]].shape[0:2]
wh_ratio = w * 1.0 / h
max_wh_ratio = max(max_wh_ratio, wh_ratio)
+
+ norm_img_batch = []
for ino in range(beg_img_no, end_img_no):
norm_img = self.resize_norm_img(img_list[indices[ino]],
max_wh_ratio)
- norm_img = norm_img[np.newaxis, :]
- norm_img_batch.append(norm_img)
- norm_img_batch = np.concatenate(norm_img_batch)
- norm_img_batch = norm_img_batch.astype(np.float32)
+ norm_img_batch.append(norm_img[np.newaxis, :])
+ norm_img_batch = np.concatenate(norm_img_batch).astype(np.float32)
- # onnx模型推理
starttime = time.time()
- onnx_inputs = {self.session.get_inputs()[0].name: norm_img_batch}
+ onnx_inputs = {self.input_name: norm_img_batch}
preds = self.session.run(None, onnx_inputs)[0]
-
rec_result = self.postprocess_op(preds)
+
for rno in range(len(rec_result)):
rec_res[indices[beg_img_no + rno]] = rec_result[rno]
elapse += time.time() - starttime
@@ -133,10 +109,13 @@ class TextRecognizer(object):
if __name__ == "__main__":
parser = argparse.ArgumentParser()
- parser.add_argument('image_dir', type=str, help='image_dir|image_path')
- parser.add_argument('model_path', type=str, help='rec_model_path')
+ parser.add_argument('--image_path', type=str, help='image_dir|image_path')
+ parser.add_argument('--config_path', type=str, default='config.yaml')
args = parser.parse_args()
- text_recognizer = TextRecognizer(args.model_path)
- rec_res, predict_time = text_recognizer(args.image_dir)
+ config = read_yaml(args.config_path)
+ text_recognizer = TextRecognizer(config)
+
+ img = cv2.imread(args.image_path)
+ rec_res, predict_time = text_recognizer(img)
print(f'识别结果: {rec_res}\t cost: {predict_time}s')
diff --git a/ocrweb/rapidocr_onnxruntime/ch_ppocr_v2_rec/utils.py b/ocrweb/rapidocr_onnxruntime/ch_ppocr_v2_rec/utils.py
new file mode 100644
index 0000000..c6edeb6
--- /dev/null
+++ b/ocrweb/rapidocr_onnxruntime/ch_ppocr_v2_rec/utils.py
@@ -0,0 +1,79 @@
+# -*- encoding: utf-8 -*-
+# @Author: SWHL
+# @Contact: [email protected]
+import numpy as np
+import yaml
+
+
+def read_yaml(yaml_path):
+ with open(yaml_path, 'rb') as f:
+ data = yaml.load(f, Loader=yaml.Loader)
+ return data
+
+
+class CTCLabelDecode(object):
+ """ Convert between text-label and text-index """
+
+ def __init__(self, character_dict_path):
+ super(CTCLabelDecode, self).__init__()
+
+ self.character_str = []
+ assert character_dict_path is not None, "character_dict_path should not be None"
+ with open(character_dict_path, "rb") as fin:
+ lines = fin.readlines()
+ for line in lines:
+ line = line.decode('utf-8').strip("\n").strip("\r\n")
+ self.character_str.append(line)
+ self.character_str.append(' ')
+
+ dict_character = self.add_special_char(self.character_str)
+ self.character = dict_character
+
+ self.dict = {}
+ for i, char in enumerate(dict_character):
+ self.dict[char] = i
+
+ def __call__(self, preds, label=None):
+ preds_idx = preds.argmax(axis=2)
+ preds_prob = preds.max(axis=2)
+ text = self.decode(preds_idx, preds_prob,
+ is_remove_duplicate=True)
+ if label is None:
+ return text
+ label = self.decode(label)
+ return text, label
+
+ def add_special_char(self, dict_character):
+ dict_character = ['blank'] + dict_character
+ return dict_character
+
+ def get_ignored_tokens(self):
+ return [0] # for ctc blank
+
+ def decode(self, text_index, text_prob=None, is_remove_duplicate=False):
+ """ convert text-index into text-label. """
+
+ result_list = []
+ ignored_tokens = self.get_ignored_tokens()
+ batch_size = len(text_index)
+ for batch_idx in range(batch_size):
+ char_list = []
+ conf_list = []
+ for idx in range(len(text_index[batch_idx])):
+ if text_index[batch_idx][idx] in ignored_tokens:
+ continue
+ if is_remove_duplicate:
+ # only for predict
+ if idx > 0 and text_index[batch_idx][idx - 1] == text_index[
+ batch_idx][idx]:
+ continue
+ char_list.append(self.character[int(text_index[batch_idx][
+ idx])])
+ if text_prob is not None:
+ conf_list.append(text_prob[batch_idx][idx])
+ else:
+ conf_list.append(1)
+ text = ''.join(char_list)
+ result_list.append((text, np.mean(conf_list)))
+ return result_list
+
diff --git a/ocrweb/rapidocr_onnxruntime/ch_ppocr_v2_rec/word_1.jpg b/ocrweb/rapidocr_onnxruntime/ch_ppocr_v2_rec/word_1.jpg
new file mode 100644
index 0000000..934cc1c
Binary files /dev/null and b/ocrweb/rapidocr_onnxruntime/ch_ppocr_v2_rec/word_1.jpg differ
diff --git a/ocrweb/rapidocr_onnxruntime/ch_ppocr_v3_rec/README.md b/ocrweb/rapidocr_onnxruntime/ch_ppocr_v3_rec/README.md
new file mode 100644
index 0000000..cfef298
--- /dev/null
+++ b/ocrweb/rapidocr_onnxruntime/ch_ppocr_v3_rec/README.md
@@ -0,0 +1,9 @@
+
+#### 简单对比
+
+|输入尺寸|前处理函数|模型|测试集|Score|Exact_Match|Char_Match|Rec_Speed(s/条)|
+|---|---|---|---|---|---|---|---|
+|48 |resize_norm_img_svtr |ch_PP-OCRv3_rec_infer.onnx|中英印刷体|0.5011|0.3571|0.6450|0.0203|
+|48 |resize_norm_img |ch_PP-OCRv3_rec_infer.onnx|中英印刷体|0.7248|0.5417|0.9079|0.0209|
+|32 | resize_norm_img_svtr |ch_PP-OCRv3_rec_infer.onnx|中英印刷体|0.3019|0.1607|0.4431|0.0161|
+|32| resize_norm_img |ch_PP-OCRv3_rec_infer.onnx|中英印刷体|0.5537|0.3274|0.7800|0.0152|
diff --git a/ocrweb/rapidocr_onnxruntime/ch_ppocr_v3_rec/__init__.py b/ocrweb/rapidocr_onnxruntime/ch_ppocr_v3_rec/__init__.py
new file mode 100644
index 0000000..ea54cd3
--- /dev/null
+++ b/ocrweb/rapidocr_onnxruntime/ch_ppocr_v3_rec/__init__.py
@@ -0,0 +1,4 @@
+# -*- encoding: utf-8 -*-
+# @Author: SWHL
+# @Contact: [email protected]
+from .text_recognize import TextRecognizer
\ No newline at end of file
diff --git a/ocrweb/rapidocr_onnxruntime/ch_ppocr_v3_rec/config.yaml b/ocrweb/rapidocr_onnxruntime/ch_ppocr_v3_rec/config.yaml
new file mode 100644
index 0000000..4f903d6
--- /dev/null
+++ b/ocrweb/rapidocr_onnxruntime/ch_ppocr_v3_rec/config.yaml
@@ -0,0 +1,5 @@
+model_path: resources/models/PPOCRv3/ch_PP-OCRv3_rec_infer.onnx
+
+rec_img_shape: [3, 48, 320]
+rec_batch_num: 6
+keys_path: resources/rec_dict/ppocr_keys_v1.txt
diff --git a/ocrweb/rapidocr_onnxruntime/ch_ppocr_v3_rec/text_recognize.py b/ocrweb/rapidocr_onnxruntime/ch_ppocr_v3_rec/text_recognize.py
new file mode 100644
index 0000000..ca88ce5
--- /dev/null
+++ b/ocrweb/rapidocr_onnxruntime/ch_ppocr_v3_rec/text_recognize.py
@@ -0,0 +1,133 @@
+# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+import argparse
+import math
+import time
+from pathlib import Path
+from typing import List
+
+import cv2
+import numpy as np
+import onnxruntime
+
+try:
+ from .utils import CTCLabelDecode, read_yaml
+except:
+ from utils import CTCLabelDecode, read_yaml
+
+root_path = Path(__file__).parent
+
+
+class TextRecognizer(object):
+ def __init__(self, config):
+ self.rec_image_shape = config['rec_img_shape']
+ self.rec_batch_num = config['rec_batch_num']
+ self.character_dict_path = config['keys_path']
+ self.postprocess_op = CTCLabelDecode(self.character_dict_path)
+
+ sess_opt = onnxruntime.SessionOptions()
+ sess_opt.log_severity_level = 4
+ sess_opt.enable_cpu_mem_arena = False
+ self.session = onnxruntime.InferenceSession(config['model_path'],
+ sess_opt)
+ self.input_name = self.session.get_inputs()[0].name
+
+ def resize_norm_img(self, img, max_wh_ratio):
+ img_channel, img_height, img_width = self.rec_image_shape
+ assert img_channel == img.shape[2]
+
+ img_width = int((32 * max_wh_ratio))
+ max_wh_ratio = 1
+
+ h, w = img.shape[:2]
+ ratio = w / float(h)
+ if math.ceil(img_height * ratio) > img_width:
+ resized_w = img_width
+ else:
+ resized_w = int(math.ceil(img_height * ratio))
+
+ resized_image = cv2.resize(img, (resized_w, img_height))
+ resized_image = resized_image.astype('float32')
+ resized_image = resized_image.transpose((2, 0, 1)) / 255
+ resized_image -= 0.5
+ resized_image /= 0.5
+
+ padding_im = np.zeros((img_channel, img_height, img_width),
+ dtype=np.float32)
+ padding_im[:, :, 0:resized_w] = resized_image
+ return padding_im
+
+ def resize_norm_img_svtr(self, img, max_wh_ratio=None):
+ img_c, img_h, img_w = self.rec_image_shape
+ resized_image = cv2.resize(img, (img_w, img_h),
+ interpolation=cv2.INTER_LINEAR)
+
+ resized_image = resized_image.astype('float32')
+ resized_image = resized_image.transpose((2, 0, 1)) / 255
+ resized_image -= 0.5
+ resized_image /= 0.5
+ return resized_image
+
+ def __call__(self, img_list: List[np.ndarray]):
+ if isinstance(img_list, np.ndarray):
+ img_list = [img_list]
+
+ # Calculate the aspect ratio of all text bars
+ width_list = [img.shape[1] / float(img.shape[0]) for img in img_list]
+
+ # Sorting can speed up the recognition process
+ indices = np.argsort(np.array(width_list))
+
+ img_num = len(img_list)
+ rec_res = [['', 0.0]] * img_num
+
+ batch_num = self.rec_batch_num
+ elapse = 0
+ for beg_img_no in range(0, img_num, batch_num):
+ end_img_no = min(img_num, beg_img_no + batch_num)
+ max_wh_ratio = 0
+ for ino in range(beg_img_no, end_img_no):
+ h, w = img_list[indices[ino]].shape[0:2]
+ wh_ratio = w * 1.0 / h
+ max_wh_ratio = max(max_wh_ratio, wh_ratio)
+
+ norm_img_batch = []
+ for ino in range(beg_img_no, end_img_no):
+ norm_img = self.resize_norm_img_svtr(img_list[indices[ino]])
+ norm_img_batch.append(norm_img[np.newaxis, :])
+ norm_img_batch = np.concatenate(norm_img_batch).astype(np.float32)
+
+ starttime = time.time()
+ onnx_inputs = {self.input_name: norm_img_batch}
+ preds = self.session.run(None, onnx_inputs)[0]
+ rec_result = self.postprocess_op(preds)
+
+ for rno in range(len(rec_result)):
+ rec_res[indices[beg_img_no + rno]] = rec_result[rno]
+ elapse += time.time() - starttime
+ return rec_res, elapse
+
+
+if __name__ == "__main__":
+ parser = argparse.ArgumentParser()
+ parser.add_argument('--image_path', type=str, help='image_dir|image_path')
+ parser.add_argument('--config_path', type=str, default='config.yaml')
+ args = parser.parse_args()
+
+ config = read_yaml(args.config_path)
+ text_recognizer = TextRecognizer(config)
+
+ img = cv2.imread(args.image_path)
+ rec_res, predict_time = text_recognizer(img)
+ print(f'识别结果: {rec_res}\t cost: {predict_time}s')
diff --git a/ocrweb/rapidocr_onnxruntime/ch_ppocr_v3_rec/utils.py b/ocrweb/rapidocr_onnxruntime/ch_ppocr_v3_rec/utils.py
new file mode 100644
index 0000000..c6edeb6
--- /dev/null
+++ b/ocrweb/rapidocr_onnxruntime/ch_ppocr_v3_rec/utils.py
@@ -0,0 +1,79 @@
+# -*- encoding: utf-8 -*-
+# @Author: SWHL
+# @Contact: [email protected]
+import numpy as np
+import yaml
+
+
+def read_yaml(yaml_path):
+ with open(yaml_path, 'rb') as f:
+ data = yaml.load(f, Loader=yaml.Loader)
+ return data
+
+
+class CTCLabelDecode(object):
+ """ Convert between text-label and text-index """
+
+ def __init__(self, character_dict_path):
+ super(CTCLabelDecode, self).__init__()
+
+ self.character_str = []
+ assert character_dict_path is not None, "character_dict_path should not be None"
+ with open(character_dict_path, "rb") as fin:
+ lines = fin.readlines()
+ for line in lines:
+ line = line.decode('utf-8').strip("\n").strip("\r\n")
+ self.character_str.append(line)
+ self.character_str.append(' ')
+
+ dict_character = self.add_special_char(self.character_str)
+ self.character = dict_character
+
+ self.dict = {}
+ for i, char in enumerate(dict_character):
+ self.dict[char] = i
+
+ def __call__(self, preds, label=None):
+ preds_idx = preds.argmax(axis=2)
+ preds_prob = preds.max(axis=2)
+ text = self.decode(preds_idx, preds_prob,
+ is_remove_duplicate=True)
+ if label is None:
+ return text
+ label = self.decode(label)
+ return text, label
+
+ def add_special_char(self, dict_character):
+ dict_character = ['blank'] + dict_character
+ return dict_character
+
+ def get_ignored_tokens(self):
+ return [0] # for ctc blank
+
+ def decode(self, text_index, text_prob=None, is_remove_duplicate=False):
+ """ convert text-index into text-label. """
+
+ result_list = []
+ ignored_tokens = self.get_ignored_tokens()
+ batch_size = len(text_index)
+ for batch_idx in range(batch_size):
+ char_list = []
+ conf_list = []
+ for idx in range(len(text_index[batch_idx])):
+ if text_index[batch_idx][idx] in ignored_tokens:
+ continue
+ if is_remove_duplicate:
+ # only for predict
+ if idx > 0 and text_index[batch_idx][idx - 1] == text_index[
+ batch_idx][idx]:
+ continue
+ char_list.append(self.character[int(text_index[batch_idx][
+ idx])])
+ if text_prob is not None:
+ conf_list.append(text_prob[batch_idx][idx])
+ else:
+ conf_list.append(1)
+ text = ''.join(char_list)
+ result_list.append((text, np.mean(conf_list)))
+ return result_list
+
diff --git a/ocrweb/resources/rapidOCR.py b/ocrweb/rapidocr_onnxruntime/rapid_ocr_api.py
similarity index 61%
rename from ocrweb/resources/rapidOCR.py
rename to ocrweb/rapidocr_onnxruntime/rapid_ocr_api.py
index cc396f0..518bd3e 100644
--- a/ocrweb/resources/rapidOCR.py
+++ b/ocrweb/rapidocr_onnxruntime/rapid_ocr_api.py
@@ -1,58 +1,51 @@
# !/usr/bin/env python
# -*- encoding: utf-8 -*-
import copy
-from pathlib import Path
+import importlib
import time
+import sys
+from pathlib import Path
import cv2
import numpy as np
+import yaml
-drop_score = 0.5
-
-from .ch_ppocr_mobile_v2_cls import TextClassifier
-from .ch_ppocr_mobile_v2_det import TextDetector
-from .ch_ppocr_mobile_v2_rec import TextRecognizer
+root_dir = Path(__file__).resolve().parent
+sys.path.append(str(root_dir))
-def check_and_read_gif(img_path):
- if Path(img_path).name[-3:] in ['gif', 'GIF']:
- gif = cv2.VideoCapture(img_path)
- ret, frame = gif.read()
- if not ret:
- print("Cannot read {}. This gif image maybe corrupted.")
- return None, False
- if len(frame.shape) == 2 or frame.shape[-1] == 1:
- frame = cv2.cvtColor(frame, cv2.COLOR_GRAY2RGB)
- imgvalue = frame[:, :, ::-1]
- return imgvalue, True
- return None, False
+class TextSystem(object):
+ def __init__(self, config_path=str(root_dir / 'config.yaml')):
+ super(TextSystem).__init__()
+ config = self.read_yaml(config_path)
+ self.print_verbose = config['Global']['print_verbose']
+ self.text_score = config['Global']['text_score']
-def draw_text_det_res(dt_boxes, raw_im):
- src_im = copy.deepcopy(raw_im)
- for i, box in enumerate(dt_boxes):
- box = np.array(box).astype(np.int32).reshape(-1, 2)
- cv2.polylines(src_im, [box], True,
- color=(0, 0, 255),
- thickness=1)
- cv2.putText(src_im, str(i), (int(box[0][0]), int(box[0][1])),
- cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 0), 2)
- return src_im
+ TextDetector = self.init_module(config['Det']['module_name'],
+ config['Det']['class_name'])
+ self.text_detector = TextDetector(config['Det'])
+ TextRecognizer = self.init_module(config['Rec']['module_name'],
+ config['Rec']['class_name'])
+ self.text_recognizer = TextRecognizer(config['Rec'])
-class TextSystem(object):
- def __init__(self, det_model_path,
- rec_model_path,
- use_angle_cls=False,
- cls_model_path=None) -> None:
- super(TextSystem).__init__()
- self.text_detector = TextDetector(det_model_path)
+ self.use_angle_cls = config['Global']['use_angle_cls']
+ if self.use_angle_cls:
+ TextClassifier = self.init_module(config['Cls']['module_name'],
+ config['Cls']['class_name'])
+ self.text_cls = TextClassifier(config['Cls'])
- self.text_recognizer = TextRecognizer(rec_model_path)
+ @staticmethod
+ def read_yaml(yaml_path):
+ with open(yaml_path, 'rb') as f:
+ data = yaml.load(f, Loader=yaml.Loader)
+ return data
- self.use_angle_cls = use_angle_cls
- if self.use_angle_cls:
- self.text_classifier = TextClassifier(cls_model_path)
+ @staticmethod
+ def init_module(module_name, class_name):
+ module_part = importlib.import_module(module_name)
+ return getattr(module_part, class_name)
def get_rotate_crop_image(self, img, points):
'''
@@ -108,11 +101,13 @@ class TextSystem(object):
_boxes[i + 1] = tmp
return _boxes
- def __call__(self, img):
+ def __call__(self, img: np.ndarray):
dt_boxes, det_elapse = self.text_detector(img)
- print(f"dt_boxes num: {len(dt_boxes)}, elapse: {det_elapse}")
- if dt_boxes is None or dt_boxes.size == 0:
- return None, None, img
+ if self.print_verbose:
+ print(f'dt_boxes num: { len(dt_boxes)}, elapse: {det_elapse}')
+
+ if dt_boxes is None or len(dt_boxes) < 1:
+ return None, None
start_time = time.time()
img_crop_list = []
@@ -124,23 +119,34 @@ class TextSystem(object):
crop_elapse = time.time() - start_time
if self.use_angle_cls:
- img_crop_list, _, cls_elapse = self.text_classifier(img_crop_list)
- print(f"cls num : {len(img_crop_list)}, elapse: {cls_elapse}")
+ img_crop_list, _, cls_elapse = self.text_cls(img_crop_list)
+ if self.print_verbose:
+ print(f'cls num: {len(img_crop_list)}, elapse: {cls_elapse}')
rec_res, rec_elapse = self.text_recognizer(img_crop_list)
- print(f"rec_res num: {len(rec_res)}, elapse: {rec_elapse}")
+ if self.print_verbose:
+ print(f'rec_res num: {len(rec_res)}, elapse: {rec_elapse}')
start_time = time.time()
filter_boxes, filter_rec_res = [], []
for box, rec_reuslt in zip(dt_boxes, rec_res):
text, score = rec_reuslt
- if score >= drop_score:
+ if score >= self.text_score:
filter_boxes.append(box)
filter_rec_res.append(rec_reuslt)
filter_elapse = time.time() - start_time
-
elapse_part = [f'{det_elapse:.4f}',
f'{(cls_elapse+crop_elapse):.4f}',
f'{(rec_elapse+filter_elapse):.4f}'
]
return filter_boxes, filter_rec_res, img, elapse_part
+
+
+if __name__ == '__main__':
+ text_sys = TextSystem('config.yaml')
+
+ import cv2
+ img = cv2.imread('resources/test_images/det_images/ch_en_num.jpg')
+
+ result = text_sys(img)
+ print(result)
diff --git a/ocrweb/requirements.txt b/ocrweb/requirements.txt
index 1cb4f6e..0909428 100644
--- a/ocrweb/requirements.txt
+++ b/ocrweb/requirements.txt
@@ -6,3 +6,4 @@ numpy>=1.19.1
Shapely>=1.7.1
Flask>=2.1.2
Pillow
+PyYAML
\ No newline at end of file
diff --git a/ocrweb/resources/__init__.py b/ocrweb/resources/__init__.py
deleted file mode 100644
index e1c5ae9..0000000
--- a/ocrweb/resources/__init__.py
+++ /dev/null
@@ -1,6 +0,0 @@
-# !/usr/bin/env python
-# -*- encoding: utf-8 -*-
-# @File: __init__.py
-# @Time: 2021/02/06 15:32:08
-# @Author: Max
-from .rapidOCR import TextSystem
\ No newline at end of file
diff --git a/ocrweb/resources/ch_ppocr_mobile_v2_cls/__init__.py b/ocrweb/resources/ch_ppocr_mobile_v2_cls/__init__.py
deleted file mode 100644
index 3ecae8d..0000000
--- a/ocrweb/resources/ch_ppocr_mobile_v2_cls/__init__.py
+++ /dev/null
@@ -1,6 +0,0 @@
-# !/usr/bin/env python
-# -*- encoding: utf-8 -*-
-# @File: __init__.py
-# @Time: 2021/01/31 11:02:53
-# @Author: Max
-from .text_cls import TextClassifier
\ No newline at end of file
diff --git a/ocrweb/resources/ch_ppocr_mobile_v2_cls/utils.py b/ocrweb/resources/ch_ppocr_mobile_v2_cls/utils.py
deleted file mode 100644
index edbd6a2..0000000
--- a/ocrweb/resources/ch_ppocr_mobile_v2_cls/utils.py
+++ /dev/null
@@ -1,65 +0,0 @@
-# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-import os
-import cv2
-import imghdr
-
-
-def get_image_file_list(img_file):
- imgs_lists = []
- if img_file is None or not os.path.exists(img_file):
- raise ValueError("not found any img file in {}".format(img_file))
-
- img_end = {'jpg', 'bmp', 'png', 'jpeg', 'rgb', 'tif', 'tiff', 'gif', 'GIF'}
- if os.path.isfile(img_file) and imghdr.what(img_file) in img_end:
- imgs_lists.append(img_file)
- elif os.path.isdir(img_file):
- for single_file in os.listdir(img_file):
- file_path = os.path.join(img_file, single_file)
- if os.path.isfile(file_path) and imghdr.what(file_path) in img_end:
- imgs_lists.append(file_path)
- if len(imgs_lists) == 0:
- raise ValueError("not found any img file in {}".format(img_file))
- return imgs_lists
-
-
-def check_and_read_gif(img_path):
- if os.path.basename(img_path)[-3:] in ['gif', 'GIF']:
- gif = cv2.VideoCapture(img_path)
- ret, frame = gif.read()
- if not ret:
- print("Cannot read {}. This gif image maybe corrupted.")
- return None, False
- if len(frame.shape) == 2 or frame.shape[-1] == 1:
- frame = cv2.cvtColor(frame, cv2.COLOR_GRAY2RGB)
- imgvalue = frame[:, :, ::-1]
- return imgvalue, True
- return None, False
-
-
-class ClsPostProcess(object):
- """ Convert between text-label and text-index """
-
- def __init__(self, label_list, **kwargs):
- super(ClsPostProcess, self).__init__()
- self.label_list = label_list
-
- def __call__(self, preds, label=None, *args, **kwargs):
- pred_idxs = preds.argmax(axis=1)
- decode_out = [(self.label_list[idx], preds[i, idx])
- for i, idx in enumerate(pred_idxs)]
- if label is None:
- return decode_out
- label = [(self.label_list[idx], 1.0) for idx in label]
- return decode_out, label
\ No newline at end of file
diff --git a/ocrweb/resources/ch_ppocr_mobile_v2_det/__init__.py b/ocrweb/resources/ch_ppocr_mobile_v2_det/__init__.py
deleted file mode 100644
index d7a3e0b..0000000
--- a/ocrweb/resources/ch_ppocr_mobile_v2_det/__init__.py
+++ /dev/null
@@ -1,6 +0,0 @@
-# !/usr/bin/env python
-# -*- encoding: utf-8 -*-
-# @File: __init__.py
-# @Time: 2021/01/23 15:24:27
-# @Author: Max
-from .text_detect import TextDetector
\ No newline at end of file
diff --git a/ocrweb/resources/ch_ppocr_mobile_v2_rec/utils.py b/ocrweb/resources/ch_ppocr_mobile_v2_rec/utils.py
deleted file mode 100644
index 8836d71..0000000
--- a/ocrweb/resources/ch_ppocr_mobile_v2_rec/utils.py
+++ /dev/null
@@ -1,124 +0,0 @@
-# !/usr/bin/env python
-# -*- encoding: utf-8 -*-
-# @File: PostProcess.py
-# @Time: 2021/01/19 14:12:35
-# @Author: Max
-import cv2
-import os
-import imghdr
-import numpy as np
-
-
-class BaseRecLabelDecode(object):
- """ Convert between text-label and text-index """
-
- def __init__(self,
- character_dict_path=None,
- character_type='ch',
- use_space_char=False):
- self.character_str = ""
- assert character_dict_path is not None, "character_dict_path should not be None when character_type is ch"
- with open(character_dict_path, "rb") as fin:
- lines = fin.readlines()
- for line in lines:
- line = line.decode('utf-8').strip("\n").strip("\r\n")
- self.character_str += line
- if use_space_char:
- self.character_str += " "
- dict_character = list(self.character_str)
-
- self.character_type = character_type
- dict_character = self.add_special_char(dict_character)
- self.dict = {}
- for i, char in enumerate(dict_character):
- self.dict[char] = i
- self.character = dict_character
-
- def add_special_char(self, dict_character):
- return dict_character
-
- def decode(self, text_index, text_prob=None, is_remove_duplicate=True):
- """ convert text-index into text-label. """
- result_list = []
- ignored_tokens = self.get_ignored_tokens()
- batch_size = len(text_index)
- for batch_idx in range(batch_size):
- char_list = []
- conf_list = []
- for idx in range(len(text_index[batch_idx])):
- if text_index[batch_idx][idx] in ignored_tokens:
- continue
- if is_remove_duplicate:
- # only for predict
- if idx > 0 and text_index[batch_idx][idx - 1] == text_index[
- batch_idx][idx]:
- continue
- char_list.append(self.character[int(text_index[batch_idx][
- idx])])
- if text_prob is not None:
- conf_list.append(text_prob[batch_idx][idx])
- else:
- conf_list.append(1)
- text = ''.join(char_list)
- result_list.append((text, np.mean(conf_list)))
- return result_list
-
- def get_ignored_tokens(self):
- return [0] # for ctc blank
-
-
-class CTCLabelDecode(BaseRecLabelDecode):
- """ Convert between text-label and text-index """
-
- def __init__(self,
- character_dict_path=None,
- character_type='ch',
- use_space_char=False,
- **kwargs):
- super(CTCLabelDecode, self).__init__(character_dict_path,
- character_type, use_space_char)
-
- def __call__(self, preds, label=None, *args, **kwargs):
- preds_idx = preds.argmax(axis=2)
- preds_prob = preds.max(axis=2)
- text = self.decode(preds_idx, preds_prob)
- if label is None:
- return text
- label = self.decode(label, is_remove_duplicate=False)
- return text, label
-
- def add_special_char(self, dict_character):
- dict_character = ['blank'] + dict_character
- return dict_character
-
-
-def get_image_file_list(img_file):
- imgs_lists = []
- if img_file is None or not os.path.exists(img_file):
- raise Exception("not found any img file in {}".format(img_file))
-
- img_end = {'jpg', 'bmp', 'png', 'jpeg', 'rgb', 'tif', 'tiff', 'gif', 'GIF'}
- if os.path.isfile(img_file) and imghdr.what(img_file) in img_end:
- imgs_lists.append(img_file)
- elif os.path.isdir(img_file):
- for single_file in os.listdir(img_file):
- file_path = os.path.join(img_file, single_file)
- if imghdr.what(file_path) in img_end:
- imgs_lists.append(file_path)
- if len(imgs_lists) == 0:
- raise Exception("not found any img file in {}".format(img_file))
- return imgs_lists
-
-
-def check_and_read_gif(img_path):
- if os.path.basename(img_path)[-3:] in ['gif', 'GIF']:
- gif = cv2.VideoCapture(img_path)
- ret, frame = gif.read()
- if not ret:
- print("Cannot read {}. This gif image maybe corrupted.")
- return None, False
- if len(frame.shape) == 2 or frame.shape[-1] == 1:
- frame = cv2.cvtColor(frame, cv2.COLOR_GRAY2RGB)
- imgvalue = frame[:, :, ::-1]
- return imgvalue, True
- return None, False
\ No newline at end of file
diff --git a/ocrweb/resources/models/.gitkeep b/ocrweb/resources/models/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/ocrweb/resources/models/model_places.md b/ocrweb/resources/models/model_places.md
deleted file mode 100644
index 49d8867..0000000
--- a/ocrweb/resources/models/model_places.md
+++ /dev/null
@@ -1,2 +0,0 @@
-- [链接](https://pan.baidu.com/s/1qkqWK4wRdMjqGGbzR-FyWg)
-- 提取码:30jv
\ No newline at end of file
diff --git a/ocrweb/resources/rec_dict/en_dict.txt b/ocrweb/resources/rec_dict/en_dict.txt
new file mode 100644
index 0000000..7677d31
--- /dev/null
+++ b/ocrweb/resources/rec_dict/en_dict.txt
@@ -0,0 +1,95 @@
+0
+1
+2
+3
+4
+5
+6
+7
+8
+9
+:
+;
+<
+=
+>
+?
+@
+A
+B
+C
+D
+E
+F
+G
+H
+I
+J
+K
+L
+M
+N
+O
+P
+Q
+R
+S
+T
+U
+V
+W
+X
+Y
+Z
+[
+\
+]
+^
+_
+`
+a
+b
+c
+d
+e
+f
+g
+h
+i
+j
+k
+l
+m
+n
+o
+p
+q
+r
+s
+t
+u
+v
+w
+x
+y
+z
+{
+|
+}
+~
+!
+"
+#
+$
+%
+&
+'
+(
+)
+*
++
+,
+-
+.
+/
+
diff --git a/ocrweb/resources/rec_dict/japan_dict.txt b/ocrweb/resources/rec_dict/japan_dict.txt
new file mode 100644
index 0000000..339d4b8
--- /dev/null
+++ b/ocrweb/resources/rec_dict/japan_dict.txt
@@ -0,0 +1,4399 @@
+!
+"
+#
+$
+%
+&
+'
+(
+)
+*
++
+,
+-
+.
+/
+0
+1
+2
+3
+4
+5
+6
+7
+8
+9
+:
+;
+<
+=
+>
+?
+A
+B
+C
+D
+E
+F
+G
+H
+I
+J
+K
+L
+M
+N
+O
+P
+Q
+R
+S
+T
+U
+V
+W
+X
+Y
+Z
+[
+]
+_
+`
+a
+b
+c
+d
+e
+f
+g
+h
+i
+j
+k
+l
+m
+n
+o
+p
+q
+r
+s
+t
+u
+v
+w
+x
+y
+z
+©
+°
+²
+´
+½
+Á
+Ä
+Å
+Ç
+È
+É
+Í
+Ó
+Ö
+×
+Ü
+ß
+à
+á
+â
+ã
+ä
+å
+æ
+ç
+è
+é
+ê
+ë
+í
+ð
+ñ
+ò
+ó
+ô
+õ
+ö
+ø
+ú
+û
+ü
+ý
+ā
+ă
+ą
+ć
+Č
+č
+đ
+ē
+ė
+ę
+ğ
+ī
+ı
+Ł
+ł
+ń
+ň
+ō
+ř
+Ş
+ş
+Š
+š
+ţ
+ū
+ż
+Ž
+ž
+Ș
+ș
+ț
+Δ
+α
+λ
+μ
+φ
+Г
+О
+а
+в
+л
+о
+р
+с
+т
+я
+ồ
+​
+—
+―
+’
+“
+”
+…
+℃
+→
+∇
+−
+■
+☆
+ 
+、
+。
+々
+〆
+〈
+〉
+「
+」
+『
+』
+〔
+〕
+〜
+ぁ
+あ
+ぃ
+い
+う
+ぇ
+え
+ぉ
+お
+か
+が
+き
+ぎ
+く
+ぐ
+け
+げ
+こ
+ご
+さ
+ざ
+し
+じ
+す
+ず
+せ
+ぜ
+そ
+ぞ
+た
+だ
+ち
+ぢ
+っ
+つ
+づ
+て
+で
+と
+ど
+な
+に
+ぬ
+ね
+の
+は
+ば
+ぱ
+ひ
+び
+ぴ
+ふ
+ぶ
+ぷ
+へ
+べ
+ぺ
+ほ
+ぼ
+ぽ
+ま
+み
+む
+め
+も
+ゃ
+や
+ゅ
+ゆ
+ょ
+よ
+ら
+り
+る
+れ
+ろ
+わ
+ゑ
+を
+ん
+ゝ
+ゞ
+ァ
+ア
+ィ
+イ
+ゥ
+ウ
+ェ
+エ
+ォ
+オ
+カ
+ガ
+キ
+ギ
+ク
+グ
+ケ
+ゲ
+コ
+ゴ
+サ
+ザ
+シ
+ジ
+ス
+ズ
+セ
+ゼ
+ソ
+ゾ
+タ
+ダ
+チ
+ヂ
+ッ
+ツ
+ヅ
+テ
+デ
+ト
+ド
+ナ
+ニ
+ヌ
+ネ
+ノ
+ハ
+バ
+パ
+ヒ
+ビ
+ピ
+フ
+ブ
+プ
+ヘ
+ベ
+ペ
+ホ
+ボ
+ポ
+マ
+ミ
+ム
+メ
+モ
+ャ
+ヤ
+ュ
+ユ
+ョ
+ヨ
+ラ
+リ
+ル
+レ
+ロ
+ワ
+ヰ
+ン
+ヴ
+ヵ
+ヶ
+・
+ー
+㈱
+一
+丁
+七
+万
+丈
+三
+上
+下
+不
+与
+丑
+且
+世
+丘
+丙
+丞
+両
+並
+中
+串
+丸
+丹
+主
+丼
+丿
+乃
+久
+之
+乎
+乏
+乗
+乘
+乙
+九
+乞
+也
+乱
+乳
+乾
+亀
+了
+予
+争
+事
+二
+于
+互
+五
+井
+亘
+亙
+些
+亜
+亟
+亡
+交
+亥
+亦
+亨
+享
+京
+亭
+亮
+人
+什
+仁
+仇
+今
+介
+仍
+仏
+仔
+仕
+他
+仗
+付
+仙
+代
+令
+以
+仮
+仰
+仲
+件
+任
+企
+伊
+伍
+伎
+伏
+伐
+休
+会
+伝
+伯
+估
+伴
+伶
+伸
+伺
+似
+伽
+佃
+但
+位
+低
+住
+佐
+佑
+体
+何
+余
+佚
+佛
+作
+佩
+佳
+併
+佶
+使
+侈
+例
+侍
+侏
+侑
+侘
+供
+依
+侠
+価
+侮
+侯
+侵
+侶
+便
+係
+促
+俄
+俊
+俔
+俗
+俘
+保
+信
+俣
+俤
+修
+俯
+俳
+俵
+俸
+俺
+倉
+個
+倍
+倒
+候
+借
+倣
+値
+倫
+倭
+倶
+倹
+偃
+假
+偈
+偉
+偏
+偐
+偕
+停
+健
+側
+偵
+偶
+偽
+傀
+傅
+傍
+傑
+傘
+備
+催
+傭
+傲
+傳
+債
+傷
+傾
+僊
+働
+像
+僑
+僕
+僚
+僧
+僭
+僮
+儀
+億
+儇
+儒
+儛
+償
+儡
+優
+儲
+儺
+儼
+兀
+允
+元
+兄
+充
+兆
+先
+光
+克
+兌
+免
+兎
+児
+党
+兜
+入
+全
+八
+公
+六
+共
+兵
+其
+具
+典
+兼
+内
+円
+冊
+再
+冑
+冒
+冗
+写
+冠
+冤
+冥
+冨
+冬
+冲
+决
+冶
+冷
+准
+凉
+凋
+凌
+凍
+凛
+凝
+凞
+几
+凡
+処
+凪
+凰
+凱
+凶
+凸
+凹
+出
+函
+刀
+刃
+分
+切
+刈
+刊
+刎
+刑
+列
+初
+判
+別
+利
+刪
+到
+制
+刷
+券
+刹
+刺
+刻
+剃
+則
+削
+剋
+前
+剖
+剛
+剣
+剤
+剥
+剪
+副
+剰
+割
+創
+剽
+劇
+劉
+劔
+力
+功
+加
+劣
+助
+努
+劫
+劭
+励
+労
+効
+劾
+勃
+勅
+勇
+勉
+勒
+動
+勘
+務
+勝
+募
+勢
+勤
+勧
+勲
+勺
+勾
+勿
+匁
+匂
+包
+匏
+化
+北
+匙
+匝
+匠
+匡
+匣
+匯
+匲
+匹
+区
+医
+匿
+十
+千
+升
+午
+卉
+半
+卍
+卑
+卒
+卓
+協
+南
+単
+博
+卜
+占
+卦
+卯
+印
+危
+即
+却
+卵
+卸
+卿
+厄
+厚
+原
+厠
+厨
+厩
+厭
+厳
+去
+参
+又
+叉
+及
+友
+双
+反
+収
+叔
+取
+受
+叙
+叛
+叟
+叡
+叢
+口
+古
+句
+叩
+只
+叫
+召
+可
+台
+叱
+史
+右
+叶
+号
+司
+吃
+各
+合
+吉
+吊
+同
+名
+后
+吏
+吐
+向
+君
+吝
+吟
+吠
+否
+含
+吸
+吹
+吻
+吽
+吾
+呂
+呆
+呈
+呉
+告
+呑
+周
+呪
+呰
+味
+呼
+命
+咀
+咄
+咋
+和
+咒
+咫
+咲
+咳
+咸
+哀
+品
+哇
+哉
+員
+哨
+哩
+哭
+哲
+哺
+唄
+唆
+唇
+唐
+唖
+唯
+唱
+唳
+唸
+唾
+啄
+商
+問
+啓
+啼
+善
+喋
+喚
+喜
+喝
+喧
+喩
+喪
+喫
+喬
+單
+喰
+営
+嗅
+嗇
+嗔
+嗚
+嗜
+嗣
+嘆
+嘉
+嘗
+嘘
+嘩
+嘯
+嘱
+嘲
+嘴
+噂
+噌
+噛
+器
+噴
+噺
+嚆
+嚢
+囀
+囃
+囉
+囚
+四
+回
+因
+団
+困
+囲
+図
+固
+国
+圀
+圃
+國
+圏
+園
+圓
+團
+圜
+土
+圧
+在
+圭
+地
+址
+坂
+均
+坊
+坐
+坑
+坡
+坤
+坦
+坪
+垂
+型
+垢
+垣
+埃
+埋
+城
+埒
+埔
+域
+埠
+埴
+埵
+執
+培
+基
+埼
+堀
+堂
+堅
+堆
+堕
+堤
+堪
+堯
+堰
+報
+場
+堵
+堺
+塀
+塁
+塊
+塑
+塔
+塗
+塘
+塙
+塚
+塞
+塩
+填
+塵
+塾
+境
+墉
+墓
+増
+墜
+墟
+墨
+墳
+墺
+墻
+墾
+壁
+壇
+壊
+壌
+壕
+士
+壬
+壮
+声
+壱
+売
+壷
+壹
+壺
+壽
+変
+夏
+夕
+外
+夙
+多
+夜
+夢
+夥
+大
+天
+太
+夫
+夬
+夭
+央
+失
+夷
+夾
+奄
+奇
+奈
+奉
+奎
+奏
+契
+奔
+奕
+套
+奘
+奠
+奢
+奥
+奨
+奪
+奮
+女
+奴
+奸
+好
+如
+妃
+妄
+妊
+妍
+妓
+妖
+妙
+妥
+妨
+妬
+妲
+妹
+妻
+妾
+姉
+始
+姐
+姓
+委
+姚
+姜
+姞
+姥
+姦
+姨
+姪
+姫
+姶
+姻
+姿
+威
+娑
+娘
+娟
+娠
+娩
+娯
+娼
+婆
+婉
+婚
+婢
+婦
+婬
+婿
+媄
+媒
+媓
+媚
+媛
+媞
+媽
+嫁
+嫄
+嫉
+嫌
+嫐
+嫗
+嫡
+嬉
+嬌
+嬢
+嬪
+嬬
+嬾
+孁
+子
+孔
+字
+存
+孚
+孝
+孟
+季
+孤
+学
+孫
+孵
+學
+宅
+宇
+守
+安
+宋
+完
+宍
+宏
+宕
+宗
+官
+宙
+定
+宛
+宜
+宝
+実
+客
+宣
+室
+宥
+宮
+宰
+害
+宴
+宵
+家
+宸
+容
+宿
+寂
+寄
+寅
+密
+寇
+富
+寒
+寓
+寔
+寛
+寝
+察
+寡
+實
+寧
+審
+寮
+寵
+寶
+寸
+寺
+対
+寿
+封
+専
+射
+将
+尉
+尊
+尋
+對
+導
+小
+少
+尖
+尚
+尤
+尪
+尭
+就
+尹
+尺
+尻
+尼
+尽
+尾
+尿
+局
+居
+屈
+届
+屋
+屍
+屎
+屏
+屑
+屓
+展
+属
+屠
+層
+履
+屯
+山
+岐
+岑
+岡
+岩
+岫
+岬
+岳
+岷
+岸
+峠
+峡
+峨
+峯
+峰
+島
+峻
+崇
+崋
+崎
+崑
+崖
+崗
+崛
+崩
+嵌
+嵐
+嵩
+嵯
+嶂
+嶋
+嶠
+嶺
+嶼
+嶽
+巀
+巌
+巒
+巖
+川
+州
+巡
+巣
+工
+左
+巧
+巨
+巫
+差
+己
+巳
+巴
+巷
+巻
+巽
+巾
+市
+布
+帆
+希
+帖
+帚
+帛
+帝
+帥
+師
+席
+帯
+帰
+帳
+帷
+常
+帽
+幄
+幅
+幇
+幌
+幔
+幕
+幟
+幡
+幢
+幣
+干
+平
+年
+并
+幸
+幹
+幻
+幼
+幽
+幾
+庁
+広
+庄
+庇
+床
+序
+底
+庖
+店
+庚
+府
+度
+座
+庫
+庭
+庵
+庶
+康
+庸
+廂
+廃
+廉
+廊
+廓
+廟
+廠
+廣
+廬
+延
+廷
+建
+廻
+廼
+廿
+弁
+弄
+弉
+弊
+弌
+式
+弐
+弓
+弔
+引
+弖
+弗
+弘
+弛
+弟
+弥
+弦
+弧
+弱
+張
+強
+弼
+弾
+彈
+彊
+彌
+彎
+当
+彗
+彙
+彝
+形
+彦
+彩
+彫
+彬
+彭
+彰
+影
+彷
+役
+彼
+往
+征
+徂
+径
+待
+律
+後
+徐
+徑
+徒
+従
+得
+徠
+御
+徧
+徨
+復
+循
+徭
+微
+徳
+徴
+德
+徹
+徽
+心
+必
+忉
+忌
+忍
+志
+忘
+忙
+応
+忠
+快
+忯
+念
+忻
+忽
+忿
+怒
+怖
+思
+怠
+怡
+急
+性
+怨
+怪
+怯
+恂
+恋
+恐
+恒
+恕
+恣
+恤
+恥
+恨
+恩
+恬
+恭
+息
+恵
+悉
+悌
+悍
+悔
+悟
+悠
+患
+悦
+悩
+悪
+悲
+悼
+情
+惇
+惑
+惚
+惜
+惟
+惠
+惣
+惧
+惨
+惰
+想
+惹
+惺
+愈
+愉
+愍
+意
+愔
+愚
+愛
+感
+愷
+愿
+慈
+態
+慌
+慎
+慕
+慢
+慣
+慧
+慨
+慮
+慰
+慶
+憂
+憎
+憐
+憑
+憙
+憤
+憧
+憩
+憬
+憲
+憶
+憾
+懇
+應
+懌
+懐
+懲
+懸
+懺
+懽
+懿
+戈
+戊
+戌
+戎
+成
+我
+戒
+戔
+或
+戚
+戟
+戦
+截
+戮
+戯
+戴
+戸
+戻
+房
+所
+扁
+扇
+扈
+扉
+手
+才
+打
+払
+托
+扮
+扱
+扶
+批
+承
+技
+抄
+把
+抑
+抓
+投
+抗
+折
+抜
+択
+披
+抱
+抵
+抹
+押
+抽
+担
+拇
+拈
+拉
+拍
+拏
+拐
+拒
+拓
+拘
+拙
+招
+拝
+拠
+拡
+括
+拭
+拳
+拵
+拶
+拾
+拿
+持
+挂
+指
+按
+挑
+挙
+挟
+挨
+振
+挺
+挽
+挿
+捉
+捕
+捗
+捜
+捧
+捨
+据
+捺
+捻
+掃
+掄
+授
+掌
+排
+掖
+掘
+掛
+掟
+採
+探
+掣
+接
+控
+推
+掩
+措
+掬
+掲
+掴
+掻
+掾
+揃
+揄
+揆
+揉
+描
+提
+揖
+揚
+換
+握
+揮
+援
+揶
+揺
+損
+搦
+搬
+搭
+携
+搾
+摂
+摘
+摩
+摸
+摺
+撃
+撒
+撞
+撤
+撥
+撫
+播
+撮
+撰
+撲
+撹
+擁
+操
+擔
+擦
+擬
+擾
+攘
+攝
+攣
+支
+收
+改
+攻
+放
+政
+故
+敏
+救
+敗
+教
+敢
+散
+敦
+敬
+数
+整
+敵
+敷
+斂
+文
+斉
+斎
+斐
+斑
+斗
+料
+斜
+斟
+斤
+斥
+斧
+斬
+断
+斯
+新
+方
+於
+施
+旁
+旅
+旋
+旌
+族
+旗
+旛
+无
+旡
+既
+日
+旦
+旧
+旨
+早
+旬
+旭
+旺
+旻
+昂
+昆
+昇
+昉
+昌
+明
+昏
+易
+昔
+星
+映
+春
+昧
+昨
+昪
+昭
+是
+昵
+昼
+晁
+時
+晃
+晋
+晏
+晒
+晟
+晦
+晧
+晩
+普
+景
+晴
+晶
+智
+暁
+暇
+暈
+暉
+暑
+暖
+暗
+暘
+暢
+暦
+暫
+暮
+暲
+暴
+暹
+暾
+曄
+曇
+曉
+曖
+曙
+曜
+曝
+曠
+曰
+曲
+曳
+更
+書
+曹
+曼
+曽
+曾
+替
+最
+會
+月
+有
+朋
+服
+朏
+朔
+朕
+朗
+望
+朝
+期
+朧
+木
+未
+末
+本
+札
+朱
+朴
+机
+朽
+杁
+杉
+李
+杏
+材
+村
+杓
+杖
+杜
+杞
+束
+条
+杢
+杣
+来
+杭
+杮
+杯
+東
+杲
+杵
+杷
+杼
+松
+板
+枅
+枇
+析
+枓
+枕
+林
+枚
+果
+枝
+枠
+枡
+枢
+枯
+枳
+架
+柄
+柊
+柏
+某
+柑
+染
+柔
+柘
+柚
+柯
+柱
+柳
+柴
+柵
+査
+柾
+柿
+栂
+栃
+栄
+栖
+栗
+校
+株
+栲
+栴
+核
+根
+栻
+格
+栽
+桁
+桂
+桃
+框
+案
+桐
+桑
+桓
+桔
+桜
+桝
+桟
+桧
+桴
+桶
+桾
+梁
+梅
+梆
+梓
+梔
+梗
+梛
+條
+梟
+梢
+梧
+梨
+械
+梱
+梲
+梵
+梶
+棄
+棋
+棒
+棗
+棘
+棚
+棟
+棠
+森
+棲
+棹
+棺
+椀
+椅
+椋
+植
+椎
+椏
+椒
+椙
+検
+椥
+椹
+椿
+楊
+楓
+楕
+楚
+楞
+楠
+楡
+楢
+楨
+楪
+楫
+業
+楮
+楯
+楳
+極
+楷
+楼
+楽
+概
+榊
+榎
+榕
+榛
+榜
+榮
+榱
+榴
+槃
+槇
+槊
+構
+槌
+槍
+槐
+様
+槙
+槻
+槽
+槿
+樂
+樋
+樓
+樗
+標
+樟
+模
+権
+横
+樫
+樵
+樹
+樺
+樽
+橇
+橋
+橘
+機
+橿
+檀
+檄
+檎
+檐
+檗
+檜
+檣
+檥
+檬
+檮
+檸
+檻
+櫃
+櫓
+櫛
+櫟
+櫨
+櫻
+欄
+欅
+欠
+次
+欣
+欧
+欲
+欺
+欽
+款
+歌
+歎
+歓
+止
+正
+此
+武
+歩
+歪
+歯
+歳
+歴
+死
+殆
+殉
+殊
+残
+殖
+殯
+殴
+段
+殷
+殺
+殻
+殿
+毀
+毅
+母
+毎
+毒
+比
+毘
+毛
+毫
+毬
+氈
+氏
+民
+気
+水
+氷
+永
+氾
+汀
+汁
+求
+汎
+汐
+汗
+汚
+汝
+江
+池
+汪
+汰
+汲
+決
+汽
+沂
+沃
+沅
+沆
+沈
+沌
+沐
+沓
+沖
+沙
+没
+沢
+沱
+河
+沸
+油
+治
+沼
+沽
+沿
+況
+泉
+泊
+泌
+法
+泗
+泡
+波
+泣
+泥
+注
+泯
+泰
+泳
+洋
+洒
+洗
+洛
+洞
+津
+洩
+洪
+洲
+洸
+洹
+活
+洽
+派
+流
+浄
+浅
+浙
+浚
+浜
+浣
+浦
+浩
+浪
+浮
+浴
+海
+浸
+涅
+消
+涌
+涙
+涛
+涯
+液
+涵
+涼
+淀
+淄
+淆
+淇
+淋
+淑
+淘
+淡
+淤
+淨
+淫
+深
+淳
+淵
+混
+淹
+添
+清
+済
+渉
+渋
+渓
+渕
+渚
+減
+渟
+渠
+渡
+渤
+渥
+渦
+温
+渫
+測
+港
+游
+渾
+湊
+湖
+湘
+湛
+湧
+湫
+湯
+湾
+湿
+満
+源
+準
+溜
+溝
+溢
+溥
+溪
+溶
+溺
+滄
+滅
+滋
+滌
+滑
+滕
+滝
+滞
+滴
+滸
+滹
+滿
+漁
+漂
+漆
+漉
+漏
+漑
+演
+漕
+漠
+漢
+漣
+漫
+漬
+漱
+漸
+漿
+潅
+潔
+潙
+潜
+潟
+潤
+潭
+潮
+潰
+潴
+澁
+澂
+澄
+澎
+澗
+澤
+澪
+澱
+澳
+激
+濁
+濃
+濟
+濠
+濡
+濤
+濫
+濯
+濱
+濾
+瀉
+瀋
+瀑
+瀕
+瀞
+瀟
+瀧
+瀬
+瀾
+灌
+灑
+灘
+火
+灯
+灰
+灸
+災
+炉
+炊
+炎
+炒
+炭
+炮
+炷
+点
+為
+烈
+烏
+烙
+烝
+烹
+焔
+焙
+焚
+無
+焦
+然
+焼
+煇
+煉
+煌
+煎
+煕
+煙
+煤
+煥
+照
+煩
+煬
+煮
+煽
+熈
+熊
+熙
+熟
+熨
+熱
+熹
+熾
+燃
+燈
+燎
+燔
+燕
+燗
+燥
+燭
+燻
+爆
+爐
+爪
+爬
+爲
+爵
+父
+爺
+爼
+爽
+爾
+片
+版
+牌
+牒
+牘
+牙
+牛
+牝
+牟
+牡
+牢
+牧
+物
+牲
+特
+牽
+犂
+犠
+犬
+犯
+状
+狂
+狄
+狐
+狗
+狙
+狛
+狡
+狩
+独
+狭
+狷
+狸
+狼
+猊
+猛
+猟
+猥
+猨
+猩
+猪
+猫
+献
+猴
+猶
+猷
+猾
+猿
+獄
+獅
+獏
+獣
+獲
+玄
+玅
+率
+玉
+王
+玖
+玩
+玲
+珀
+珂
+珈
+珉
+珊
+珍
+珎
+珞
+珠
+珣
+珥
+珪
+班
+現
+球
+理
+琉
+琢
+琥
+琦
+琮
+琲
+琳
+琴
+琵
+琶
+瑁
+瑋
+瑙
+瑚
+瑛
+瑜
+瑞
+瑠
+瑤
+瑩
+瑪
+瑳
+瑾
+璃
+璋
+璜
+璞
+璧
+璨
+環
+璵
+璽
+璿
+瓊
+瓔
+瓜
+瓢
+瓦
+瓶
+甍
+甑
+甕
+甘
+甚
+甞
+生
+産
+甥
+用
+甫
+田
+由
+甲
+申
+男
+町
+画
+界
+畏
+畑
+畔
+留
+畜
+畝
+畠
+畢
+略
+番
+異
+畳
+當
+畷
+畸
+畺
+畿
+疆
+疇
+疋
+疎
+疏
+疑
+疫
+疱
+疲
+疹
+疼
+疾
+病
+症
+痒
+痔
+痕
+痘
+痙
+痛
+痢
+痩
+痴
+痺
+瘍
+瘡
+瘧
+療
+癇
+癌
+癒
+癖
+癡
+癪
+発
+登
+白
+百
+的
+皆
+皇
+皋
+皐
+皓
+皮
+皺
+皿
+盂
+盃
+盆
+盈
+益
+盒
+盗
+盛
+盞
+盟
+盡
+監
+盤
+盥
+盧
+目
+盲
+直
+相
+盾
+省
+眉
+看
+県
+眞
+真
+眠
+眷
+眺
+眼
+着
+睡
+督
+睦
+睨
+睿
+瞋
+瞑
+瞞
+瞬
+瞭
+瞰
+瞳
+瞻
+瞼
+瞿
+矍
+矛
+矜
+矢
+知
+矧
+矩
+短
+矮
+矯
+石
+砂
+砌
+研
+砕
+砥
+砦
+砧
+砲
+破
+砺
+硝
+硫
+硬
+硯
+碁
+碇
+碌
+碑
+碓
+碕
+碗
+碣
+碧
+碩
+確
+碾
+磁
+磐
+磔
+磧
+磨
+磬
+磯
+礁
+礎
+礒
+礙
+礫
+礬
+示
+礼
+社
+祀
+祁
+祇
+祈
+祉
+祐
+祓
+祕
+祖
+祗
+祚
+祝
+神
+祟
+祠
+祢
+祥
+票
+祭
+祷
+祺
+禁
+禄
+禅
+禊
+禍
+禎
+福
+禔
+禖
+禛
+禦
+禧
+禮
+禰
+禹
+禽
+禿
+秀
+私
+秋
+科
+秒
+秘
+租
+秤
+秦
+秩
+称
+移
+稀
+程
+税
+稔
+稗
+稙
+稚
+稜
+稠
+種
+稱
+稲
+稷
+稻
+稼
+稽
+稿
+穀
+穂
+穆
+積
+穎
+穏
+穗
+穜
+穢
+穣
+穫
+穴
+究
+空
+突
+窃
+窄
+窒
+窓
+窟
+窠
+窩
+窪
+窮
+窯
+竃
+竄
+竈
+立
+站
+竜
+竝
+竟
+章
+童
+竪
+竭
+端
+竴
+競
+竹
+竺
+竽
+竿
+笄
+笈
+笏
+笑
+笙
+笛
+笞
+笠
+笥
+符
+第
+笹
+筅
+筆
+筇
+筈
+等
+筋
+筌
+筍
+筏
+筐
+筑
+筒
+答
+策
+筝
+筥
+筧
+筬
+筮
+筯
+筰
+筵
+箆
+箇
+箋
+箏
+箒
+箔
+箕
+算
+箙
+箜
+管
+箪
+箭
+箱
+箸
+節
+篁
+範
+篆
+篇
+築
+篋
+篌
+篝
+篠
+篤
+篥
+篦
+篩
+篭
+篳
+篷
+簀
+簒
+簡
+簧
+簪
+簫
+簺
+簾
+簿
+籀
+籃
+籌
+籍
+籐
+籟
+籠
+籤
+籬
+米
+籾
+粂
+粉
+粋
+粒
+粕
+粗
+粘
+粛
+粟
+粥
+粧
+粮
+粳
+精
+糊
+糖
+糜
+糞
+糟
+糠
+糧
+糯
+糸
+糺
+系
+糾
+紀
+約
+紅
+紋
+納
+紐
+純
+紗
+紘
+紙
+級
+紛
+素
+紡
+索
+紫
+紬
+累
+細
+紳
+紵
+紹
+紺
+絁
+終
+絃
+組
+絅
+経
+結
+絖
+絞
+絡
+絣
+給
+統
+絲
+絵
+絶
+絹
+絽
+綏
+經
+継
+続
+綜
+綟
+綬
+維
+綱
+網
+綴
+綸
+綺
+綽
+綾
+綿
+緊
+緋
+総
+緑
+緒
+線
+締
+緥
+編
+緩
+緬
+緯
+練
+緻
+縁
+縄
+縅
+縒
+縛
+縞
+縢
+縣
+縦
+縫
+縮
+縹
+總
+績
+繁
+繊
+繋
+繍
+織
+繕
+繝
+繦
+繧
+繰
+繹
+繼
+纂
+纈
+纏
+纐
+纒
+纛
+缶
+罔
+罠
+罧
+罪
+置
+罰
+署
+罵
+罷
+罹
+羂
+羅
+羆
+羇
+羈
+羊
+羌
+美
+群
+羨
+義
+羯
+羲
+羹
+羽
+翁
+翅
+翌
+習
+翔
+翛
+翠
+翡
+翫
+翰
+翺
+翻
+翼
+耀
+老
+考
+者
+耆
+而
+耐
+耕
+耗
+耨
+耳
+耶
+耽
+聊
+聖
+聘
+聚
+聞
+聟
+聡
+聨
+聯
+聰
+聲
+聴
+職
+聾
+肄
+肆
+肇
+肉
+肋
+肌
+肖
+肘
+肛
+肝
+股
+肢
+肥
+肩
+肪
+肯
+肱
+育
+肴
+肺
+胃
+胆
+背
+胎
+胖
+胚
+胝
+胞
+胡
+胤
+胱
+胴
+胸
+能
+脂
+脅
+脆
+脇
+脈
+脊
+脚
+脛
+脩
+脱
+脳
+腋
+腎
+腐
+腑
+腔
+腕
+腫
+腰
+腱
+腸
+腹
+腺
+腿
+膀
+膏
+膚
+膜
+膝
+膠
+膣
+膨
+膩
+膳
+膵
+膾
+膿
+臂
+臆
+臈
+臍
+臓
+臘
+臚
+臣
+臥
+臨
+自
+臭
+至
+致
+臺
+臼
+舂
+舅
+與
+興
+舌
+舍
+舎
+舒
+舖
+舗
+舘
+舜
+舞
+舟
+舩
+航
+般
+舳
+舶
+船
+艇
+艘
+艦
+艮
+良
+色
+艶
+芋
+芒
+芙
+芝
+芥
+芦
+芬
+芭
+芯
+花
+芳
+芸
+芹
+芻
+芽
+芿
+苅
+苑
+苔
+苗
+苛
+苞
+苡
+若
+苦
+苧
+苫
+英
+苴
+苻
+茂
+范
+茄
+茅
+茎
+茗
+茘
+茜
+茨
+茲
+茵
+茶
+茸
+茹
+草
+荊
+荏
+荒
+荘
+荷
+荻
+荼
+莞
+莪
+莫
+莬
+莱
+莵
+莽
+菅
+菊
+菌
+菓
+菖
+菘
+菜
+菟
+菩
+菫
+華
+菱
+菴
+萄
+萊
+萌
+萍
+萎
+萠
+萩
+萬
+萱
+落
+葉
+著
+葛
+葡
+董
+葦
+葩
+葬
+葭
+葱
+葵
+葺
+蒋
+蒐
+蒔
+蒙
+蒟
+蒡
+蒲
+蒸
+蒻
+蒼
+蒿
+蓄
+蓆
+蓉
+蓋
+蓑
+蓬
+蓮
+蓼
+蔀
+蔑
+蔓
+蔚
+蔡
+蔦
+蔬
+蔭
+蔵
+蔽
+蕃
+蕉
+蕊
+蕎
+蕨
+蕩
+蕪
+蕭
+蕾
+薄
+薇
+薊
+薔
+薗
+薙
+薛
+薦
+薨
+薩
+薪
+薫
+薬
+薭
+薮
+藁
+藉
+藍
+藏
+藐
+藝
+藤
+藩
+藪
+藷
+藹
+藺
+藻
+蘂
+蘆
+蘇
+蘊
+蘭
+虎
+虐
+虔
+虚
+虜
+虞
+號
+虫
+虹
+虻
+蚊
+蚕
+蛇
+蛉
+蛍
+蛎
+蛙
+蛛
+蛟
+蛤
+蛭
+蛮
+蛸
+蛹
+蛾
+蜀
+蜂
+蜃
+蜆
+蜊
+蜘
+蜜
+蜷
+蜻
+蝉
+蝋
+蝕
+蝙
+蝠
+蝦
+蝶
+蝿
+螂
+融
+螣
+螺
+蟄
+蟇
+蟠
+蟷
+蟹
+蟻
+蠢
+蠣
+血
+衆
+行
+衍
+衒
+術
+街
+衙
+衛
+衝
+衞
+衡
+衢
+衣
+表
+衫
+衰
+衵
+衷
+衽
+衾
+衿
+袁
+袈
+袋
+袍
+袒
+袖
+袙
+袞
+袢
+被
+袰
+袱
+袴
+袷
+袿
+裁
+裂
+裃
+装
+裏
+裔
+裕
+裘
+裙
+補
+裟
+裡
+裲
+裳
+裴
+裸
+裹
+製
+裾
+褂
+褄
+複
+褌
+褐
+褒
+褥
+褪
+褶
+褻
+襄
+襖
+襞
+襟
+襠
+襦
+襪
+襲
+襴
+襷
+西
+要
+覆
+覇
+覈
+見
+規
+視
+覗
+覚
+覧
+親
+覲
+観
+覺
+觀
+角
+解
+触
+言
+訂
+計
+討
+訓
+託
+記
+訛
+訟
+訢
+訥
+訪
+設
+許
+訳
+訴
+訶
+診
+註
+証
+詐
+詔
+評
+詛
+詞
+詠
+詢
+詣
+試
+詩
+詫
+詮
+詰
+話
+該
+詳
+誄
+誅
+誇
+誉
+誌
+認
+誓
+誕
+誘
+語
+誠
+誡
+誣
+誤
+誥
+誦
+説
+読
+誰
+課
+誼
+誾
+調
+談
+請
+諌
+諍
+諏
+諒
+論
+諚
+諜
+諟
+諡
+諦
+諧
+諫
+諭
+諮
+諱
+諶
+諷
+諸
+諺
+諾
+謀
+謄
+謌
+謎
+謗
+謙
+謚
+講
+謝
+謡
+謫
+謬
+謹
+證
+識
+譚
+譛
+譜
+警
+譬
+譯
+議
+譲
+譴
+護
+讀
+讃
+讐
+讒
+谷
+谿
+豅
+豆
+豊
+豎
+豐
+豚
+象
+豪
+豫
+豹
+貌
+貝
+貞
+負
+財
+貢
+貧
+貨
+販
+貪
+貫
+責
+貯
+貰
+貴
+買
+貸
+費
+貼
+貿
+賀
+賁
+賂
+賃
+賄
+資
+賈
+賊
+賎
+賑
+賓
+賛
+賜
+賞
+賠
+賢
+賣
+賤
+賦
+質
+賭
+購
+賽
+贄
+贅
+贈
+贋
+贔
+贖
+赤
+赦
+走
+赴
+起
+超
+越
+趙
+趣
+足
+趺
+趾
+跋
+跏
+距
+跡
+跨
+跪
+路
+跳
+践
+踊
+踏
+踐
+踞
+踪
+踵
+蹄
+蹉
+蹊
+蹟
+蹲
+蹴
+躅
+躇
+躊
+躍
+躑
+躙
+躪
+身
+躬
+躯
+躰
+車
+軋
+軌
+軍
+軒
+軟
+転
+軸
+軻
+軽
+軾
+較
+載
+輌
+輔
+輜
+輝
+輦
+輩
+輪
+輯
+輸
+輿
+轄
+轍
+轟
+轢
+辛
+辞
+辟
+辥
+辦
+辨
+辰
+辱
+農
+辺
+辻
+込
+迂
+迅
+迎
+近
+返
+迢
+迦
+迪
+迫
+迭
+述
+迷
+迹
+追
+退
+送
+逃
+逅
+逆
+逍
+透
+逐
+逓
+途
+逕
+逗
+這
+通
+逝
+逞
+速
+造
+逢
+連
+逮
+週
+進
+逸
+逼
+遁
+遂
+遅
+遇
+遊
+運
+遍
+過
+遐
+道
+達
+違
+遙
+遜
+遠
+遡
+遣
+遥
+適
+遭
+遮
+遯
+遵
+遷
+選
+遺
+遼
+避
+邀
+邁
+邂
+邃
+還
+邇
+邉
+邊
+邑
+那
+邦
+邨
+邪
+邯
+邵
+邸
+郁
+郊
+郎
+郡
+郢
+部
+郭
+郴
+郵
+郷
+都
+鄂
+鄙
+鄭
+鄰
+鄲
+酉
+酋
+酌
+配
+酎
+酒
+酔
+酢
+酥
+酪
+酬
+酵
+酷
+酸
+醍
+醐
+醒
+醗
+醜
+醤
+醪
+醵
+醸
+采
+釈
+釉
+釋
+里
+重
+野
+量
+釐
+金
+釘
+釜
+針
+釣
+釧
+釿
+鈍
+鈎
+鈐
+鈔
+鈞
+鈦
+鈴
+鈷
+鈸
+鈿
+鉄
+鉇
+鉉
+鉋
+鉛
+鉢
+鉤
+鉦
+鉱
+鉾
+銀
+銃
+銅
+銈
+銑
+銕
+銘
+銚
+銜
+銭
+鋏
+鋒
+鋤
+鋭
+鋲
+鋳
+鋸
+鋺
+鋼
+錆
+錍
+錐
+錘
+錠
+錣
+錦
+錫
+錬
+錯
+録
+錵
+鍋
+鍍
+鍑
+鍔
+鍛
+鍬
+鍮
+鍵
+鍼
+鍾
+鎌
+鎖
+鎗
+鎚
+鎧
+鎬
+鎮
+鎰
+鎹
+鏃
+鏑
+鏡
+鐃
+鐇
+鐐
+鐔
+鐘
+鐙
+鐚
+鐡
+鐵
+鐸
+鑁
+鑊
+鑑
+鑒
+鑚
+鑠
+鑢
+鑰
+鑵
+鑷
+鑼
+鑽
+鑿
+長
+門
+閃
+閇
+閉
+開
+閏
+閑
+間
+閔
+閘
+関
+閣
+閤
+閥
+閦
+閨
+閬
+閲
+閻
+閼
+閾
+闇
+闍
+闔
+闕
+闘
+關
+闡
+闢
+闥
+阜
+阪
+阮
+阯
+防
+阻
+阿
+陀
+陂
+附
+陌
+降
+限
+陛
+陞
+院
+陣
+除
+陥
+陪
+陬
+陰
+陳
+陵
+陶
+陸
+険
+陽
+隅
+隆
+隈
+隊
+隋
+階
+随
+隔
+際
+障
+隠
+隣
+隧
+隷
+隻
+隼
+雀
+雁
+雄
+雅
+集
+雇
+雉
+雊
+雋
+雌
+雍
+雑
+雖
+雙
+雛
+離
+難
+雨
+雪
+雫
+雰
+雲
+零
+雷
+雹
+電
+需
+震
+霊
+霍
+霖
+霜
+霞
+霧
+霰
+露
+靈
+青
+靖
+静
+靜
+非
+面
+革
+靫
+靭
+靱
+靴
+靺
+鞁
+鞄
+鞆
+鞋
+鞍
+鞏
+鞘
+鞠
+鞨
+鞭
+韋
+韓
+韜
+韮
+音
+韶
+韻
+響
+頁
+頂
+頃
+項
+順
+須
+頌
+預
+頑
+頒
+頓
+領
+頚
+頬
+頭
+頴
+頸
+頻
+頼
+顆
+題
+額
+顎
+顔
+顕
+顗
+願
+顛
+類
+顧
+顯
+風
+飛
+食
+飢
+飩
+飫
+飯
+飲
+飴
+飼
+飽
+飾
+餃
+餅
+餉
+養
+餌
+餐
+餓
+餘
+餝
+餡
+館
+饂
+饅
+饉
+饋
+饌
+饒
+饗
+首
+馗
+香
+馨
+馬
+馳
+馴
+駄
+駅
+駆
+駈
+駐
+駒
+駕
+駝
+駿
+騁
+騎
+騏
+騒
+験
+騙
+騨
+騰
+驕
+驚
+驛
+驢
+骨
+骸
+髄
+體
+高
+髙
+髢
+髪
+髭
+髮
+髷
+髻
+鬘
+鬚
+鬢
+鬨
+鬯
+鬱
+鬼
+魁
+魂
+魄
+魅
+魏
+魔
+魚
+魯
+鮎
+鮑
+鮒
+鮪
+鮫
+鮭
+鮮
+鯉
+鯔
+鯖
+鯛
+鯨
+鯰
+鯱
+鰐
+鰒
+鰭
+鰯
+鰰
+鰹
+鰻
+鱈
+鱒
+鱗
+鱧
+鳥
+鳩
+鳰
+鳳
+鳴
+鳶
+鴈
+鴉
+鴎
+鴛
+鴟
+鴦
+鴨
+鴫
+鴻
+鵄
+鵜
+鵞
+鵡
+鵬
+鵲
+鵺
+鶉
+鶏
+鶯
+鶴
+鷄
+鷙
+鷲
+鷹
+鷺
+鸚
+鸞
+鹸
+鹽
+鹿
+麁
+麒
+麓
+麗
+麝
+麞
+麟
+麦
+麩
+麹
+麺
+麻
+麾
+麿
+黄
+黌
+黍
+黒
+黙
+黛
+黠
+鼈
+鼉
+鼎
+鼓
+鼠
+鼻
+齊
+齋
+齟
+齢
+齬
+龍
+龕
+龗
+!
+#
+%
+&
+(
+)
++
+,
+-
+.
+/
+0
+1
+2
+3
+4
+5
+6
+7
+8
+9
+:
+;
+=
+?
+@
+A
+B
+C
+D
+E
+F
+G
+H
+I
+J
+K
+L
+M
+N
+O
+P
+R
+S
+T
+U
+V
+W
+X
+Z
+a
+c
+d
+e
+f
+h
+i
+j
+k
+l
+m
+n
+o
+p
+r
+s
+t
+u
+y
+z
+~
+・
+
diff --git a/ocrweb/resources/rec_dict/korean_dict.txt b/ocrweb/resources/rec_dict/korean_dict.txt
new file mode 100644
index 0000000..a13899f
--- /dev/null
+++ b/ocrweb/resources/rec_dict/korean_dict.txt
@@ -0,0 +1,3688 @@
+!
+"
+#
+$
+%
+&
+'
+*
++
+-
+/
+0
+1
+2
+3
+4
+5
+6
+7
+8
+9
+:
+;
+<
+=
+>
+?
+A
+B
+C
+D
+E
+F
+G
+H
+I
+J
+K
+L
+M
+N
+O
+P
+Q
+R
+S
+T
+U
+V
+W
+X
+Y
+Z
+[
+\
+]
+^
+_
+`
+a
+b
+c
+d
+e
+f
+g
+h
+i
+j
+k
+l
+m
+n
+o
+p
+q
+r
+s
+t
+u
+v
+w
+x
+y
+z
+{
+|
+}
+~
+©
+°
+²
+½
+Á
+Ä
+Å
+Ç
+É
+Í
+Î
+Ó
+Ö
+×
+Ü
+ß
+à
+á
+â
+ã
+ä
+å
+æ
+ç
+è
+é
+ê
+ë
+ì
+í
+î
+ï
+ð
+ñ
+ò
+ó
+ô
+õ
+ö
+ø
+ú
+û
+ü
+ý
+ā
+ă
+ą
+ć
+Č
+č
+đ
+ē
+ė
+ę
+ě
+ğ
+ī
+İ
+ı
+Ł
+ł
+ń
+ň
+ō
+ř
+Ş
+ş
+Š
+š
+ţ
+ū
+ź
+ż
+Ž
+ž
+Ș
+ș
+Α
+Δ
+α
+λ
+φ
+Г
+О
+а
+в
+л
+о
+р
+с
+т
+я
+​
+’
+“
+”
+→
+∇
+∼
+「
+」
+ア
+カ
+グ
+ニ
+ラ
+ン
+ㄱ
+ㄴ
+ㄷ
+ㄸ
+ㄹ
+ㅂ
+ㅅ
+ㅆ
+ㅇ
+ㅈ
+ㅊ
+ㅋ
+ㅌ
+ㅎ
+ㅓ
+ㅜ
+ㅣ
+一
+丁
+七
+三
+上
+下
+不
+丑
+世
+丘
+丞
+中
+丸
+丹
+主
+乃
+久
+之
+乎
+乘
+九
+也
+乳
+乾
+事
+二
+云
+互
+五
+井
+亞
+亡
+交
+亥
+亨
+享
+京
+亭
+人
+仁
+今
+他
+仙
+代
+令
+以
+仰
+仲
+件
+任
+企
+伊
+伍
+伎
+伏
+伐
+休
+伯
+伴
+伸
+佃
+佈
+位
+低
+住
+佐
+何
+佛
+作
+使
+來
+供
+依
+侯
+侵
+侶
+便
+俗
+保
+俠
+信
+修
+俱
+俳
+倉
+個
+倍
+倒
+候
+借
+値
+倫
+倭
+假
+偈
+偉
+偏
+停
+偶
+傅
+傑
+傳
+傷
+傾
+像
+僞
+僥
+僧
+價
+儀
+儉
+儒
+優
+儼
+兀
+允
+元
+兆
+先
+光
+克
+兒
+入
+內
+全
+八
+公
+六
+共
+兵
+其
+具
+典
+兼
+再
+冠
+冥
+冶
+准
+凞
+凡
+凱
+出
+函
+刀
+分
+刊
+刑
+列
+初
+判
+別
+利
+到
+制
+券
+刺
+刻
+則
+前
+剛
+副
+創
+劃
+劑
+力
+功
+加
+劣
+助
+劫
+勇
+動
+務
+勝
+勢
+勳
+勸
+匈
+化
+北
+匠
+區
+十
+千
+午
+半
+卍
+卑
+卒
+卓
+南
+博
+卜
+占
+卦
+印
+危
+卵
+卷
+卽
+卿
+厄
+原
+厦
+去
+參
+又
+叉
+友
+反
+叔
+受
+口
+古
+句
+可
+台
+史
+右
+司
+各
+合
+吉
+同
+名
+后
+吏
+吐
+君
+吠
+吳
+呂
+告
+周
+味
+呵
+命
+和
+咳
+咸
+咽
+哀
+品
+哨
+哮
+哲
+唐
+唯
+唱
+商
+問
+啼
+善
+喆
+喉
+喜
+喩
+喪
+嘗
+器
+嚴
+囊
+四
+回
+因
+困
+固
+圈
+國
+圍
+園
+圓
+圖
+團
+土
+在
+地
+均
+坊
+坐
+坑
+坵
+型
+垢
+城
+域
+埴
+執
+培
+基
+堂
+堅
+堆
+堤
+堯
+報
+場
+塔
+塚
+塞
+塵
+境
+墜
+墟
+墨
+墳
+墾
+壁
+壇
+壓
+壤
+士
+壬
+壯
+壺
+壽
+夏
+夕
+外
+多
+夜
+夢
+大
+天
+太
+夫
+央
+失
+夷
+奄
+奇
+奉
+奎
+奏
+契
+奔
+奮
+女
+奴
+好
+如
+妄
+妊
+妖
+妙
+始
+姑
+姓
+姚
+姜
+威
+婆
+婚
+婦
+媒
+媚
+子
+孔
+字
+存
+孝
+孟
+季
+孤
+孫
+學
+孺
+宇
+守
+安
+宋
+宗
+官
+宙
+定
+客
+宣
+室
+宮
+害
+家
+容
+寂
+寃
+寄
+寅
+密
+寇
+富
+寒
+寓
+實
+審
+寫
+寬
+寶
+寸
+寺
+封
+將
+專
+尊
+對
+小
+少
+尙
+尹
+尼
+尿
+局
+居
+屈
+屋
+屍
+屎
+屛
+層
+屬
+山
+岐
+岡
+岩
+岳
+岸
+峙
+峰
+島
+峻
+峽
+崇
+崔
+崖
+崩
+嶋
+巖
+川
+州
+巢
+工
+左
+巧
+巨
+巫
+差
+己
+巷
+市
+布
+帝
+師
+帶
+常
+帽
+幕
+干
+平
+年
+幹
+幻
+幼
+幽
+庇
+序
+店
+府
+度
+座
+庫
+庭
+康
+廟
+廣
+廳
+延
+廷
+建
+廻
+弁
+式
+弑
+弓
+引
+弘
+弟
+弱
+張
+强
+弼
+彌
+彛
+形
+彬
+影
+役
+彼
+彿
+往
+征
+待
+律
+後
+徐
+徑
+得
+從
+循
+微
+德
+徹
+心
+必
+忌
+忍
+志
+忠
+思
+怡
+急
+性
+恐
+恒
+恨
+恩
+悅
+悖
+患
+悲
+情
+惑
+惟
+惠
+惡
+想
+惺
+愁
+意
+愚
+愛
+感
+愼
+慈
+態
+慕
+慣
+慧
+慾
+憂
+憤
+憺
+應
+懸
+戎
+成
+我
+戟
+戮
+戰
+戴
+戶
+房
+所
+手
+才
+打
+批
+承
+技
+抄
+把
+抗
+抱
+抽
+拇
+拓
+拘
+拙
+拜
+拾
+持
+指
+捌
+捨
+捿
+授
+掌
+排
+接
+推
+提
+揚
+揭
+援
+損
+搗
+摩
+播
+操
+擒
+擔
+擘
+據
+擧
+攘
+攝
+攬
+支
+改
+攻
+放
+政
+故
+敍
+敎
+救
+敗
+散
+敬
+整
+數
+文
+斗
+料
+斛
+斜
+斧
+斯
+新
+斷
+方
+於
+施
+旋
+族
+旗
+日
+旨
+早
+旱
+昌
+明
+易
+昔
+星
+春
+昧
+昭
+是
+時
+晉
+晋
+晩
+普
+景
+晴
+晶
+智
+暈
+暑
+暗
+暘
+曉
+曜
+曠
+曦
+曰
+曲
+書
+曹
+曼
+曾
+最
+會
+月
+有
+朋
+服
+望
+朝
+期
+木
+未
+末
+本
+朱
+朴
+李
+材
+村
+杖
+杜
+杞
+杭
+杯
+東
+松
+板
+林
+果
+枝
+枯
+枰
+枾
+柏
+柑
+柱
+栗
+校
+栢
+核
+根
+格
+桀
+桂
+案
+桎
+桑
+桓
+桔
+梁
+梏
+梓
+梗
+條
+梨
+梵
+棗
+棟
+森
+植
+椒
+楊
+楓
+楚
+業
+楮
+極
+榮
+槃
+槍
+樂
+樓
+樗
+樣
+樸
+樹
+樺
+樽
+橄
+橋
+橘
+機
+橡
+檀
+檎
+權
+欌
+欖
+次
+欲
+歌
+歐
+止
+正
+此
+步
+武
+歲
+歸
+死
+殖
+段
+殷
+殺
+殿
+毅
+母
+毒
+比
+毛
+氏
+民
+氣
+水
+永
+求
+汎
+汗
+江
+池
+沅
+沒
+沖
+沙
+沛
+河
+油
+治
+沼
+沿
+泉
+泊
+法
+泗
+泡
+波
+注
+泰
+洋
+洙
+洛
+洞
+津
+洲
+活
+派
+流
+浅
+浦
+浮
+浴
+海
+涅
+涇
+消
+涌
+液
+淑
+淡
+淨
+淫
+深
+淳
+淵
+淸
+渠
+渡
+游
+渾
+湖
+湯
+源
+溪
+溫
+溶
+滄
+滅
+滋
+滯
+滿
+漁
+漆
+漢
+漫
+漸
+潑
+潤
+潭
+澄
+澎
+澤
+澳
+澹
+濁
+濕
+濟
+濤
+濯
+瀋
+瀝
+灣
+火
+灰
+灸
+災
+炎
+炭
+点
+烈
+烏
+烙
+焚
+無
+焦
+然
+煌
+煎
+照
+煬
+煮
+熟
+熱
+燁
+燈
+燔
+燕
+燥
+燧
+燮
+爲
+爵
+父
+片
+版
+牌
+牛
+牝
+牟
+牡
+物
+特
+犧
+犬
+狀
+狗
+猥
+猩
+猪
+獨
+獵
+獸
+獻
+玄
+玉
+王
+玲
+珍
+珠
+珪
+班
+現
+球
+理
+琴
+瑞
+瑟
+瑪
+璃
+璋
+璽
+瓜
+瓦
+甑
+甘
+生
+産
+用
+甫
+田
+由
+甲
+申
+男
+界
+畏
+留
+畜
+畢
+略
+番
+異
+畵
+當
+畸
+疏
+疑
+疫
+疹
+疼
+病
+症
+痔
+痛
+痺
+瘀
+瘍
+瘡
+療
+癌
+癖
+登
+發
+白
+百
+的
+皆
+皇
+皮
+盂
+盆
+益
+盛
+盜
+盟
+盡
+盤
+盧
+目
+直
+相
+省
+看
+眞
+眼
+睡
+督
+瞋
+矢
+矣
+知
+短
+石
+破
+碍
+碑
+磁
+磨
+磬
+示
+社
+祇
+祖
+祝
+神
+祥
+祭
+祺
+禁
+禅
+禍
+福
+禦
+禪
+禮
+禹
+禽
+禾
+秀
+私
+秉
+秋
+科
+秘
+秤
+秦
+秩
+移
+稀
+稗
+種
+稱
+稷
+稼
+稽
+穀
+穆
+積
+空
+窮
+竅
+立
+章
+童
+竭
+端
+竹
+笑
+符
+第
+筆
+等
+筍
+答
+策
+箋
+箕
+管
+箱
+節
+篇
+簡
+米
+粉
+粘
+粥
+精
+糖
+糞
+系
+紀
+紂
+約
+紅
+紋
+純
+紙
+級
+素
+索
+紫
+紬
+累
+細
+紳
+終
+組
+結
+絡
+統
+絲
+絶
+絹
+經
+綠
+維
+綱
+網
+綸
+綽
+緖
+線
+緣
+緯
+縣
+縱
+總
+織
+繡
+繩
+繪
+繭
+纂
+續
+罕
+置
+罰
+羅
+羊
+美
+群
+義
+羽
+翁
+習
+翟
+老
+考
+者
+而
+耐
+耕
+耳
+聃
+聖
+聞
+聰
+聲
+職
+肇
+肉
+肖
+肝
+股
+肥
+育
+肺
+胃
+胎
+胚
+胞
+胡
+胥
+能
+脂
+脈
+脚
+脛
+脣
+脩
+脫
+脯
+脾
+腋
+腎
+腫
+腸
+腹
+膜
+膠
+膨
+膽
+臆
+臟
+臣
+臥
+臨
+自
+至
+致
+臺
+臼
+臾
+與
+興
+舊
+舌
+舍
+舒
+舜
+舟
+般
+船
+艦
+良
+色
+芋
+花
+芳
+芽
+苑
+苔
+苕
+苛
+苞
+若
+苦
+英
+茂
+茵
+茶
+茹
+荀
+荇
+草
+荒
+荷
+莊
+莫
+菊
+菌
+菜
+菩
+菫
+華
+菴
+菽
+萊
+萍
+萬
+落
+葉
+著
+葛
+董
+葬
+蒙
+蒜
+蒲
+蒸
+蒿
+蓮
+蔓
+蔘
+蔡
+蔬
+蕃
+蕉
+蕓
+薄
+薑
+薛
+薩
+薪
+薺
+藏
+藝
+藤
+藥
+藩
+藻
+蘆
+蘇
+蘊
+蘚
+蘭
+虎
+處
+虛
+虞
+虹
+蜀
+蜂
+蜜
+蝕
+蝶
+融
+蟬
+蟲
+蠶
+蠻
+血
+衆
+行
+術
+衛
+衡
+衣
+表
+袁
+裔
+裕
+裙
+補
+製
+複
+襄
+西
+要
+見
+視
+親
+覺
+觀
+角
+解
+言
+訂
+訊
+訓
+託
+記
+訣
+設
+診
+註
+評
+詩
+話
+詵
+誅
+誌
+認
+誕
+語
+誠
+誤
+誥
+誦
+說
+調
+談
+諍
+論
+諡
+諫
+諭
+諸
+謙
+講
+謝
+謠
+證
+識
+譚
+譜
+譯
+議
+護
+讀
+變
+谷
+豆
+豊
+豚
+象
+豪
+豫
+貝
+貞
+財
+貧
+貨
+貪
+貫
+貴
+貸
+費
+資
+賊
+賓
+賞
+賢
+賣
+賦
+質
+贍
+赤
+赫
+走
+起
+超
+越
+趙
+趣
+趨
+足
+趾
+跋
+跡
+路
+踏
+蹟
+身
+躬
+車
+軍
+軒
+軟
+載
+輓
+輕
+輪
+輯
+輸
+輻
+輿
+轅
+轉
+辨
+辭
+辯
+辰
+農
+近
+迦
+述
+追
+逆
+透
+逐
+通
+逝
+造
+逢
+連
+進
+逵
+遂
+遊
+運
+遍
+過
+道
+達
+遠
+遡
+適
+遷
+選
+遺
+遽
+還
+邊
+邑
+那
+邪
+郞
+郡
+部
+都
+鄒
+鄕
+鄭
+鄲
+配
+酒
+酸
+醉
+醫
+醯
+釋
+里
+重
+野
+量
+釐
+金
+針
+鈍
+鈴
+鉞
+銀
+銅
+銘
+鋼
+錄
+錢
+錦
+鎭
+鏡
+鐘
+鐵
+鑑
+鑛
+長
+門
+閃
+開
+間
+閔
+閣
+閥
+閭
+閻
+闕
+關
+阪
+防
+阿
+陀
+降
+限
+陝
+院
+陰
+陳
+陵
+陶
+陸
+陽
+隆
+隊
+隋
+階
+際
+障
+隣
+隨
+隱
+隷
+雀
+雄
+雅
+集
+雇
+雌
+雖
+雙
+雜
+離
+難
+雨
+雪
+雲
+電
+霜
+露
+靈
+靑
+靖
+靜
+非
+面
+革
+靴
+鞏
+韓
+音
+韶
+韻
+順
+須
+頊
+頌
+領
+頭
+顔
+願
+顚
+類
+顯
+風
+飛
+食
+飢
+飮
+飯
+飾
+養
+餓
+餘
+首
+香
+馨
+馬
+駒
+騫
+騷
+驕
+骨
+骸
+髓
+體
+高
+髥
+髮
+鬪
+鬱
+鬼
+魏
+魔
+魚
+魯
+鮮
+鰍
+鰐
+鳥
+鳧
+鳳
+鴨
+鵲
+鶴
+鷄
+鷹
+鹽
+鹿
+麗
+麥
+麻
+黃
+黑
+默
+點
+黨
+鼎
+齊
+齋
+齒
+龍
+龜
+가
+각
+간
+갇
+갈
+갉
+감
+갑
+값
+갓
+갔
+강
+갖
+갗
+같
+갚
+갛
+개
+객
+갠
+갤
+갬
+갭
+갯
+갰
+갱
+갸
+걀
+걔
+걘
+거
+걱
+건
+걷
+걸
+검
+겁
+것
+겄
+겅
+겆
+겉
+겊
+겋
+게
+겐
+겔
+겟
+겠
+겡
+겨
+격
+겪
+견
+결
+겸
+겹
+겻
+겼
+경
+곁
+계
+곕
+곗
+고
+곡
+곤
+곧
+골
+곪
+곬
+곯
+곰
+곱
+곳
+공
+곶
+과
+곽
+관
+괄
+괌
+광
+괘
+괜
+괭
+괴
+괸
+굉
+교
+구
+국
+군
+굳
+굴
+굵
+굶
+굼
+굽
+굿
+궁
+궂
+궈
+권
+궐
+궜
+궝
+궤
+귀
+귄
+귈
+귓
+규
+균
+귤
+그
+극
+근
+글
+긁
+금
+급
+긋
+긍
+기
+긴
+길
+김
+깁
+깃
+깅
+깊
+까
+깍
+깎
+깐
+깔
+깜
+깝
+깟
+깡
+깥
+깨
+깬
+깰
+깻
+깼
+깽
+꺄
+꺼
+꺽
+꺾
+껀
+껄
+껌
+껍
+껏
+껐
+껑
+께
+껴
+꼈
+꼍
+꼐
+꼬
+꼭
+꼴
+꼼
+꼽
+꼿
+꽁
+꽂
+꽃
+꽉
+꽝
+꽤
+꽥
+꾀
+꾜
+꾸
+꾹
+꾼
+꿀
+꿇
+꿈
+꿉
+꿋
+꿍
+꿎
+꿔
+꿨
+꿩
+꿰
+꿴
+뀄
+뀌
+뀐
+뀔
+뀜
+뀝
+끄
+끈
+끊
+끌
+끓
+끔
+끕
+끗
+끙
+끝
+끼
+끽
+낀
+낄
+낌
+낍
+낏
+낑
+나
+낙
+낚
+난
+낟
+날
+낡
+남
+납
+낫
+났
+낭
+낮
+낯
+낱
+낳
+내
+낵
+낸
+낼
+냄
+냅
+냇
+냈
+냉
+냐
+냔
+냘
+냥
+너
+넉
+넋
+넌
+널
+넓
+넘
+넙
+넛
+넜
+넝
+넣
+네
+넥
+넨
+넬
+넴
+넵
+넷
+넸
+넹
+녀
+녁
+년
+념
+녔
+녕
+녘
+녜
+노
+녹
+논
+놀
+놈
+놋
+농
+높
+놓
+놔
+놨
+뇌
+뇨
+뇩
+뇽
+누
+눅
+눈
+눌
+눔
+눕
+눗
+눠
+눴
+뉘
+뉜
+뉩
+뉴
+늄
+늅
+늉
+느
+늑
+는
+늘
+늙
+늠
+늡
+능
+늦
+늪
+늬
+니
+닉
+닌
+닐
+님
+닙
+닛
+닝
+닢
+다
+닥
+닦
+단
+닫
+달
+닭
+닮
+닯
+닳
+담
+답
+닷
+당
+닻
+닿
+대
+댁
+댄
+댈
+댐
+댑
+댓
+댔
+댕
+댜
+더
+덕
+덖
+던
+덜
+덟
+덤
+덥
+덧
+덩
+덫
+덮
+데
+덱
+덴
+델
+뎀
+뎃
+뎅
+뎌
+뎠
+뎨
+도
+독
+돈
+돋
+돌
+돔
+돕
+돗
+동
+돛
+돝
+돼
+됐
+되
+된
+될
+됨
+됩
+됴
+두
+둑
+둔
+둘
+둠
+둡
+둣
+둥
+둬
+뒀
+뒤
+뒬
+뒷
+뒹
+듀
+듈
+듐
+드
+득
+든
+듣
+들
+듦
+듬
+듭
+듯
+등
+듸
+디
+딕
+딘
+딛
+딜
+딤
+딥
+딧
+딨
+딩
+딪
+따
+딱
+딴
+딸
+땀
+땄
+땅
+때
+땐
+땔
+땜
+땝
+땠
+땡
+떠
+떡
+떤
+떨
+떫
+떰
+떱
+떳
+떴
+떵
+떻
+떼
+떽
+뗀
+뗄
+뗍
+뗏
+뗐
+뗑
+또
+똑
+똘
+똥
+뙤
+뚜
+뚝
+뚤
+뚫
+뚱
+뛰
+뛴
+뛸
+뜀
+뜁
+뜨
+뜩
+뜬
+뜯
+뜰
+뜸
+뜻
+띄
+띈
+띌
+띔
+띕
+띠
+띤
+띨
+띱
+띵
+라
+락
+란
+랄
+람
+랍
+랏
+랐
+랑
+랒
+랗
+래
+랙
+랜
+랠
+램
+랩
+랫
+랬
+랭
+랴
+략
+량
+러
+럭
+런
+럴
+럼
+럽
+럿
+렀
+렁
+렇
+레
+렉
+렌
+렐
+렘
+렙
+렛
+렝
+려
+력
+련
+렬
+렴
+렵
+렷
+렸
+령
+례
+로
+록
+론
+롤
+롬
+롭
+롯
+롱
+롸
+롹
+뢰
+뢴
+뢸
+룃
+료
+룐
+룡
+루
+룩
+룬
+룰
+룸
+룹
+룻
+룽
+뤄
+뤘
+뤼
+류
+륙
+륜
+률
+륨
+륭
+르
+륵
+른
+를
+름
+릅
+릇
+릉
+릎
+리
+릭
+린
+릴
+림
+립
+릿
+링
+마
+막
+만
+많
+맏
+말
+맑
+맘
+맙
+맛
+망
+맞
+맡
+맣
+매
+맥
+맨
+맬
+맴
+맵
+맷
+맸
+맹
+맺
+먀
+먁
+머
+먹
+먼
+멀
+멈
+멋
+멍
+멎
+메
+멕
+멘
+멜
+멤
+멥
+멧
+멩
+며
+멱
+면
+멸
+몄
+명
+몇
+모
+목
+몫
+몬
+몰
+몸
+몹
+못
+몽
+뫼
+묘
+무
+묵
+묶
+문
+묻
+물
+묽
+뭄
+뭅
+뭇
+뭉
+뭍
+뭏
+뭐
+뭔
+뭘
+뭡
+뭣
+뮈
+뮌
+뮐
+뮤
+뮬
+므
+믈
+믐
+미
+믹
+민
+믿
+밀
+밈
+밉
+밋
+밌
+밍
+및
+밑
+바
+박
+밖
+반
+받
+발
+밝
+밟
+밤
+밥
+밧
+방
+밭
+배
+백
+밴
+밸
+뱀
+뱁
+뱃
+뱄
+뱅
+뱉
+뱍
+뱐
+버
+벅
+번
+벌
+범
+법
+벗
+벙
+벚
+베
+벡
+벤
+벨
+벰
+벱
+벳
+벵
+벼
+벽
+변
+별
+볍
+볏
+볐
+병
+볕
+보
+복
+볶
+본
+볼
+봄
+봅
+봇
+봉
+봐
+봤
+뵈
+뵐
+뵙
+부
+북
+분
+붇
+불
+붉
+붐
+붓
+붕
+붙
+뷔
+뷰
+뷴
+뷸
+브
+븐
+블
+비
+빅
+빈
+빌
+빔
+빕
+빗
+빙
+빚
+빛
+빠
+빡
+빤
+빨
+빳
+빴
+빵
+빻
+빼
+빽
+뺀
+뺄
+뺌
+뺏
+뺐
+뺑
+뺨
+뻐
+뻑
+뻔
+뻗
+뻘
+뻣
+뻤
+뻥
+뻬
+뼈
+뼉
+뼘
+뽀
+뽈
+뽐
+뽑
+뽕
+뾰
+뿌
+뿍
+뿐
+뿔
+뿜
+쁘
+쁜
+쁠
+쁨
+삐
+삔
+삘
+사
+삭
+삯
+산
+살
+삵
+삶
+삼
+삽
+삿
+샀
+상
+샅
+새
+색
+샌
+샐
+샘
+샙
+샛
+샜
+생
+샤
+샨
+샬
+샴
+샵
+샷
+샹
+서
+석
+섞
+선
+섣
+설
+섬
+섭
+섯
+섰
+성
+섶
+세
+섹
+센
+셀
+셈
+셉
+셋
+셌
+셍
+셔
+션
+셜
+셨
+셰
+셴
+셸
+소
+속
+손
+솔
+솜
+솝
+솟
+송
+솥
+쇄
+쇠
+쇤
+쇳
+쇼
+숀
+숄
+숍
+수
+숙
+순
+숟
+술
+숨
+숩
+숫
+숭
+숯
+숱
+숲
+숴
+쉐
+쉘
+쉬
+쉭
+쉰
+쉴
+쉼
+쉽
+슈
+슐
+슘
+슛
+슝
+스
+슥
+슨
+슬
+슭
+슴
+습
+슷
+승
+시
+식
+신
+싣
+실
+싫
+심
+십
+싯
+싱
+싶
+싸
+싹
+싼
+쌀
+쌈
+쌉
+쌌
+쌍
+쌓
+쌔
+쌘
+쌩
+써
+썩
+썬
+썰
+썸
+썹
+썼
+썽
+쎄
+쎈
+쏘
+쏙
+쏜
+쏟
+쏠
+쏭
+쏴
+쐈
+쐐
+쐬
+쑤
+쑥
+쑨
+쒀
+쒔
+쓰
+쓱
+쓴
+쓸
+씀
+씁
+씌
+씨
+씩
+씬
+씰
+씸
+씹
+씻
+씽
+아
+악
+안
+앉
+않
+알
+앎
+앓
+암
+압
+앗
+았
+앙
+앞
+애
+액
+앤
+앨
+앰
+앱
+앳
+앴
+앵
+야
+약
+얀
+얄
+얇
+얌
+얍
+얏
+양
+얕
+얗
+얘
+얜
+어
+억
+언
+얹
+얻
+얼
+얽
+엄
+업
+없
+엇
+었
+엉
+엊
+엌
+엎
+에
+엑
+엔
+엘
+엠
+엡
+엣
+엥
+여
+역
+엮
+연
+열
+엷
+염
+엽
+엾
+엿
+였
+영
+옅
+옆
+옇
+예
+옌
+옐
+옙
+옛
+오
+옥
+온
+올
+옭
+옮
+옳
+옴
+옵
+옷
+옹
+옻
+와
+왁
+완
+왈
+왑
+왓
+왔
+왕
+왜
+왠
+왱
+외
+왼
+요
+욕
+욘
+욜
+욤
+용
+우
+욱
+운
+울
+움
+웁
+웃
+웅
+워
+웍
+원
+월
+웜
+웠
+웡
+웨
+웬
+웰
+웸
+웹
+위
+윅
+윈
+윌
+윔
+윗
+윙
+유
+육
+윤
+율
+윱
+윳
+융
+으
+윽
+은
+을
+읊
+음
+읍
+응
+의
+읜
+읠
+이
+익
+인
+일
+읽
+잃
+임
+입
+잇
+있
+잉
+잊
+잎
+자
+작
+잔
+잖
+잘
+잠
+잡
+잣
+잤
+장
+잦
+재
+잭
+잰
+잴
+잽
+잿
+쟀
+쟁
+쟈
+쟉
+쟤
+저
+적
+전
+절
+젊
+점
+접
+젓
+정
+젖
+제
+젝
+젠
+젤
+젬
+젭
+젯
+져
+젼
+졀
+졌
+졍
+조
+족
+존
+졸
+좀
+좁
+종
+좇
+좋
+좌
+좍
+좽
+죄
+죠
+죤
+주
+죽
+준
+줄
+줌
+줍
+줏
+중
+줘
+줬
+쥐
+쥔
+쥘
+쥬
+쥴
+즈
+즉
+즌
+즐
+즘
+즙
+증
+지
+직
+진
+짇
+질
+짊
+짐
+집
+짓
+징
+짖
+짙
+짚
+짜
+짝
+짠
+짢
+짤
+짧
+짬
+짭
+짰
+짱
+째
+짹
+짼
+쨀
+쨉
+쨋
+쨌
+쨍
+쩄
+쩌
+쩍
+쩐
+쩔
+쩜
+쩝
+쩡
+쩨
+쪄
+쪘
+쪼
+쪽
+쪾
+쫀
+쫄
+쫑
+쫓
+쫙
+쬐
+쭈
+쭉
+쭐
+쭙
+쯔
+쯤
+쯧
+찌
+찍
+찐
+찔
+찜
+찝
+찡
+찢
+찧
+차
+착
+찬
+찮
+찰
+참
+찹
+찻
+찼
+창
+찾
+채
+책
+챈
+챌
+챔
+챕
+챗
+챘
+챙
+챠
+챤
+처
+척
+천
+철
+첨
+첩
+첫
+청
+체
+첵
+첸
+첼
+쳄
+쳇
+쳉
+쳐
+쳔
+쳤
+초
+촉
+촌
+촘
+촛
+총
+촨
+촬
+최
+쵸
+추
+축
+춘
+출
+춤
+춥
+춧
+충
+춰
+췄
+췌
+취
+췬
+츄
+츠
+측
+츨
+츰
+층
+치
+칙
+친
+칠
+칡
+침
+칩
+칫
+칭
+카
+칵
+칸
+칼
+캄
+캅
+캇
+캉
+캐
+캔
+캘
+캠
+캡
+캣
+캤
+캥
+캬
+커
+컥
+컨
+컫
+컬
+컴
+컵
+컷
+컸
+컹
+케
+켄
+켈
+켐
+켓
+켕
+켜
+켠
+켤
+켭
+켯
+켰
+코
+콕
+콘
+콜
+콤
+콥
+콧
+콩
+콰
+콱
+콴
+콸
+쾅
+쾌
+쾡
+쾨
+쾰
+쿄
+쿠
+쿡
+쿤
+쿨
+쿰
+쿵
+쿼
+퀀
+퀄
+퀘
+퀭
+퀴
+퀵
+퀸
+퀼
+큐
+큘
+크
+큰
+클
+큼
+큽
+키
+킥
+킨
+킬
+킴
+킵
+킷
+킹
+타
+탁
+탄
+탈
+탉
+탐
+탑
+탓
+탔
+탕
+태
+택
+탠
+탤
+탬
+탭
+탯
+탰
+탱
+터
+턱
+턴
+털
+텀
+텁
+텃
+텄
+텅
+테
+텍
+텐
+텔
+템
+텝
+텡
+텨
+톈
+토
+톡
+톤
+톨
+톰
+톱
+톳
+통
+퇴
+툇
+투
+툭
+툰
+툴
+툼
+퉁
+퉈
+퉜
+튀
+튄
+튈
+튕
+튜
+튠
+튤
+튬
+트
+특
+튼
+튿
+틀
+틈
+틉
+틋
+틔
+티
+틱
+틴
+틸
+팀
+팁
+팅
+파
+팍
+팎
+판
+팔
+팜
+팝
+팟
+팠
+팡
+팥
+패
+팩
+팬
+팰
+팸
+팻
+팼
+팽
+퍼
+퍽
+펀
+펄
+펌
+펍
+펐
+펑
+페
+펙
+펜
+펠
+펨
+펩
+펫
+펭
+펴
+편
+펼
+폄
+폈
+평
+폐
+포
+폭
+폰
+폴
+폼
+폿
+퐁
+표
+푭
+푸
+푹
+푼
+풀
+품
+풋
+풍
+퓨
+퓬
+퓰
+퓸
+프
+픈
+플
+픔
+픕
+피
+픽
+핀
+필
+핌
+핍
+핏
+핑
+하
+학
+한
+할
+핥
+함
+합
+핫
+항
+해
+핵
+핸
+핼
+햄
+햅
+햇
+했
+행
+햐
+향
+헀
+허
+헉
+헌
+헐
+험
+헙
+헛
+헝
+헤
+헥
+헨
+헬
+헴
+헵
+헷
+헹
+혀
+혁
+현
+혈
+혐
+협
+혓
+혔
+형
+혜
+호
+혹
+혼
+홀
+홈
+홉
+홋
+홍
+홑
+화
+확
+환
+활
+홧
+황
+홰
+홱
+횃
+회
+획
+횝
+횟
+횡
+효
+후
+훅
+훈
+훌
+훑
+훔
+훗
+훤
+훨
+훼
+휄
+휑
+휘
+휙
+휜
+휠
+휩
+휭
+휴
+휼
+흄
+흉
+흐
+흑
+흔
+흘
+흙
+흠
+흡
+흣
+흥
+흩
+희
+흰
+흽
+히
+힉
+힌
+힐
+힘
+힙
+힝
+車
+滑
+金
+奈
+羅
+洛
+卵
+欄
+蘭
+郎
+來
+盧
+老
+魯
+綠
+鹿
+論
+雷
+樓
+縷
+凌
+樂
+不
+參
+葉
+沈
+若
+兩
+凉
+梁
+呂
+女
+廬
+麗
+黎
+曆
+歷
+戀
+蓮
+連
+列
+烈
+裂
+念
+獵
+靈
+領
+例
+禮
+醴
+惡
+尿
+料
+遼
+龍
+暈
+柳
+流
+類
+六
+陸
+倫
+律
+栗
+利
+李
+梨
+理
+離
+燐
+林
+臨
+立
+茶
+切
+宅
+
diff --git a/ocrweb/resources/ch_ppocr_mobile_v2_rec/ppocr_keys_v1.txt b/ocrweb/resources/rec_dict/ppocr_keys_v1.txt
similarity index 100%
rename from ocrweb/resources/ch_ppocr_mobile_v2_rec/ppocr_keys_v1.txt
rename to ocrweb/resources/rec_dict/ppocr_keys_v1.txt
diff --git a/ocrweb/static/css/main.css b/ocrweb/static/css/main.css
index 1ee07c6..a02bc77 100644
--- a/ocrweb/static/css/main.css
+++ b/ocrweb/static/css/main.css
@@ -8,7 +8,7 @@ body{
border-radius: 18px;
margin-top: 5px;
font-size: 15px;
- padding: 5px 5px;
+ padding: 5px 10px;
height: 20px;
width: 120px;
text-transform: uppercase;
@@ -61,17 +61,17 @@ body{
box-sizing: border-box;
}
.uplodNote{
- font-size: 14px;
- color:#000;
- font-style: italic;
+ font-size: 10px;
+ color:#A1A1A1;
}
+
a{
text-decoration:none;
}
/* wrapper */
.leftarea>#wrapper {
- position: absolute; top: 36px; left:0px;
+ position: absolute; top: 34px; left:0px;
width: 98%;
height: 100%;
background:
@@ -81,7 +81,7 @@ a{
linear-gradient(transparent, #1a98ca);
background-size:100% 1.5%, 10% 100%,100% 8%, 100% 100%;
background-repeat:no-repeat, repeat, repeat, no-repeat;
- background-position: 0% 0%, 0 0, 0 0, 0 0;
+ background-position: 0% 100%, 0 0, 0 0, 0 0;
/* 初始位置 */
clip-path: polygon(0% 0%, 100% 0%, 100% 1.5%, 0% 1.5%);
/* 添加动画效果 */
diff --git a/ocrweb/task.py b/ocrweb/task.py
index 4a43a2f..1e6582d 100644
--- a/ocrweb/task.py
+++ b/ocrweb/task.py
@@ -8,20 +8,14 @@ import base64
from functools import reduce
import json
import time
+import copy
import cv2
import numpy as np
-from resources.rapidOCR import TextSystem, draw_text_det_res, check_and_read_gif
+from rapidocr_onnxruntime import TextSystem
-det_model_path = 'resources/models/ch_PP-OCRv2_det_infer.onnx'
-cls_model_path = 'resources/models/ch_ppocr_mobile_v2.0_cls_infer.onnx'
-rec_model_path = 'resources/models/ch_ppocr_mobile_v2.0_rec_infer.onnx'
-
-text_sys = TextSystem(det_model_path,
- rec_model_path,
- use_angle_cls=True,
- cls_model_path=cls_model_path)
+text_sys = TextSystem('config.yaml')
def detect_recognize(image_path):
@@ -62,3 +56,29 @@ def detect_recognize(image_path):
'total_elapse': f'{elapse:.4f}',
'elapse_part': elapse_part,
'rec_res': rec_res_data})
+
+
+def check_and_read_gif(img_path):
+ if Path(img_path).name[-3:] in ['gif', 'GIF']:
+ gif = cv2.VideoCapture(img_path)
+ ret, frame = gif.read()
+ if not ret:
+ print("Cannot read {}. This gif image maybe corrupted.")
+ return None, False
+ if len(frame.shape) == 2 or frame.shape[-1] == 1:
+ frame = cv2.cvtColor(frame, cv2.COLOR_GRAY2RGB)
+ imgvalue = frame[:, :, ::-1]
+ return imgvalue, True
+ return None, False
+
+
+def draw_text_det_res(dt_boxes, raw_im):
+ src_im = copy.deepcopy(raw_im)
+ for i, box in enumerate(dt_boxes):
+ box = np.array(box).astype(np.int32).reshape(-1, 2)
+ cv2.polylines(src_im, [box], True,
+ color=(0, 0, 255),
+ thickness=1)
+ cv2.putText(src_im, str(i), (int(box[0][0]), int(box[0][1])),
+ cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 0), 2)
+ return src_im
\ No newline at end of file
diff --git a/ocrweb/templates/index.html b/ocrweb/templates/index.html
index f37d1e7..5bd4f25 100644
--- a/ocrweb/templates/index.html
+++ b/ocrweb/templates/index.html
@@ -13,9 +13,9 @@
<a href="https://github.com/RapidAI/RapidOCR/tree/main/ocrweb#readme" style="font-size:14px">了解Demo</a>
</h1>
<div class='area'>
- <span class="uplodNote">图片文件类型支持PNG、JPG、JPEG、BMP,图片大小不超过3M。</span>
- <span class="btn-gen" onclick="javascript:$('#rapid_ocr').click();">试试你的图片?</span>
+ <span class="btn-gen" onclick="javascript:$('#rapid_ocr').click();">试试你的图片?</span>
<input type="file" style="display: none;" name="pic" id="rapid_ocr"/>
+ <span class="uplodNote">支持PNG、JPG、JPEG、BMP,图片大小不超过3M。</span>
</div>
<br/>
<div class="area">
@@ -96,7 +96,7 @@
if (data["rec_res"]){
var rec_res = JSON.parse(data["rec_res"]);
- console.log(data['elapse_part']);
+ // console.log(data['elapse_part']);
if (data['elapse_part']){
var elapse_list = data['elapse_part'].split(',');
}else{