Merge branch 'release/2.0' into faq_2.0
commit
7bffc58e89
|
@ -49,7 +49,7 @@ python3 PPOCRLabel.py
|
||||||
```
|
```
|
||||||
pip3 install pyqt5
|
pip3 install pyqt5
|
||||||
pip3 uninstall opencv-python # Uninstall opencv manually as it conflicts with pyqt
|
pip3 uninstall opencv-python # Uninstall opencv manually as it conflicts with pyqt
|
||||||
pip3 install opencv-contrib-python-headless # Install the headless version of opencv
|
pip3 install opencv-contrib-python-headless==4.2.0.32 # Install the headless version of opencv
|
||||||
cd ./PPOCRLabel # Change the directory to the PPOCRLabel folder
|
cd ./PPOCRLabel # Change the directory to the PPOCRLabel folder
|
||||||
python3 PPOCRLabel.py
|
python3 PPOCRLabel.py
|
||||||
```
|
```
|
||||||
|
@ -160,9 +160,9 @@ For some data that are difficult to recognize, the recognition results will not
|
||||||
```
|
```
|
||||||
pyrcc5 -o libs/resources.py resources.qrc
|
pyrcc5 -o libs/resources.py resources.qrc
|
||||||
```
|
```
|
||||||
- If you get an error ``` module 'cv2' has no attribute 'INTER_NEAREST'```, you need to delete all opencv related packages first, and then reinstall the headless version of opencv
|
- If you get an error ``` module 'cv2' has no attribute 'INTER_NEAREST'```, you need to delete all opencv related packages first, and then reinstall the 4.2.0.32 version of headless opencv
|
||||||
```
|
```
|
||||||
pip install opencv-contrib-python-headless
|
pip install opencv-contrib-python-headless==4.2.0.32
|
||||||
```
|
```
|
||||||
|
|
||||||
### Related
|
### Related
|
||||||
|
|
|
@ -49,7 +49,7 @@ python3 PPOCRLabel.py --lang ch
|
||||||
```
|
```
|
||||||
pip3 install pyqt5
|
pip3 install pyqt5
|
||||||
pip3 uninstall opencv-python # 由于mac版本的opencv与pyqt有冲突,需先手动卸载opencv
|
pip3 uninstall opencv-python # 由于mac版本的opencv与pyqt有冲突,需先手动卸载opencv
|
||||||
pip3 install opencv-contrib-python-headless # 安装headless版本的open-cv
|
pip3 install opencv-contrib-python-headless==4.2.0.32 # 安装headless版本的open-cv
|
||||||
cd ./PPOCRLabel # 将目录切换到PPOCRLabel文件夹下
|
cd ./PPOCRLabel # 将目录切换到PPOCRLabel文件夹下
|
||||||
python3 PPOCRLabel.py --lang ch
|
python3 PPOCRLabel.py --lang ch
|
||||||
```
|
```
|
||||||
|
@ -145,9 +145,9 @@ PPOCRLabel支持三种保存方式:
|
||||||
pyrcc5 -o libs/resources.py resources.qrc
|
pyrcc5 -o libs/resources.py resources.qrc
|
||||||
```
|
```
|
||||||
|
|
||||||
- 如果出现``` module 'cv2' has no attribute 'INTER_NEAREST'```错误,需要首先删除所有opencv相关包,然后重新安装headless版本的opencv
|
- 如果出现``` module 'cv2' has no attribute 'INTER_NEAREST'```错误,需要首先删除所有opencv相关包,然后重新安装4.2.0.32版本的headless opencv
|
||||||
```
|
```
|
||||||
pip install opencv-contrib-python-headless
|
pip install opencv-contrib-python-headless==4.2.0.32
|
||||||
```
|
```
|
||||||
|
|
||||||
### 参考资料
|
### 参考资料
|
||||||
|
|
|
@ -9,6 +9,7 @@ PaddleOCR supports both dynamic graph and static graph programming paradigm
|
||||||
- Static graph: develop branch
|
- Static graph: develop branch
|
||||||
|
|
||||||
**Recent updates**
|
**Recent updates**
|
||||||
|
- 2021.2.8 Release PaddleOCRv2.0(branch release/2.0) and set as default branch. Check release note here: https://github.com/PaddlePaddle/PaddleOCR/releases/tag/v2.0.0
|
||||||
- 2021.1.21 update more than 25+ multilingual recognition models [models list](./doc/doc_en/models_list_en.md), including:English, Chinese, German, French, Japanese,Spanish,Portuguese Russia Arabic and so on. Models for more languages will continue to be updated [Develop Plan](https://github.com/PaddlePaddle/PaddleOCR/issues/1048).
|
- 2021.1.21 update more than 25+ multilingual recognition models [models list](./doc/doc_en/models_list_en.md), including:English, Chinese, German, French, Japanese,Spanish,Portuguese Russia Arabic and so on. Models for more languages will continue to be updated [Develop Plan](https://github.com/PaddlePaddle/PaddleOCR/issues/1048).
|
||||||
- 2020.12.15 update Data synthesis tool, i.e., [Style-Text](./StyleText/README.md),easy to synthesize a large number of images which are similar to the target scene image.
|
- 2020.12.15 update Data synthesis tool, i.e., [Style-Text](./StyleText/README.md),easy to synthesize a large number of images which are similar to the target scene image.
|
||||||
- 2020.11.25 Update a new data annotation tool, i.e., [PPOCRLabel](./PPOCRLabel/README.md), which is helpful to improve the labeling efficiency. Moreover, the labeling results can be used in training of the PP-OCR system directly.
|
- 2020.11.25 Update a new data annotation tool, i.e., [PPOCRLabel](./PPOCRLabel/README.md), which is helpful to improve the labeling efficiency. Moreover, the labeling results can be used in training of the PP-OCR system directly.
|
||||||
|
|
|
@ -8,6 +8,7 @@ PaddleOCR同时支持动态图与静态图两种编程范式
|
||||||
- 静态图版本:develop分支
|
- 静态图版本:develop分支
|
||||||
|
|
||||||
**近期更新**
|
**近期更新**
|
||||||
|
- 2021.2.8 正式发布PaddleOCRv2.0(branch release/2.0)并设置为推荐用户使用的默认分支. 发布的详细内容,请参考: https://github.com/PaddlePaddle/PaddleOCR/releases/tag/v2.0.0
|
||||||
- 2021.2.8 [FAQ](./doc/doc_ch/FAQ.md)新增5个高频问题,总数167个,每周一都会更新,欢迎大家持续关注。
|
- 2021.2.8 [FAQ](./doc/doc_ch/FAQ.md)新增5个高频问题,总数167个,每周一都会更新,欢迎大家持续关注。
|
||||||
- 2021.1.26,28,29 PaddleOCR官方研发团队带来技术深入解读三日直播课,1月26日、28日、29日晚上19:30,[直播地址](https://live.bilibili.com/21689802)
|
- 2021.1.26,28,29 PaddleOCR官方研发团队带来技术深入解读三日直播课,1月26日、28日、29日晚上19:30,[直播地址](https://live.bilibili.com/21689802)
|
||||||
- 2021.1.21 更新多语言识别模型,目前支持语种超过27种,[多语言模型下载](./doc/doc_ch/models_list.md),包括中文简体、中文繁体、英文、法文、德文、韩文、日文、意大利文、西班牙文、葡萄牙文、俄罗斯文、阿拉伯文等,后续计划可以参考[多语言研发计划](https://github.com/PaddlePaddle/PaddleOCR/issues/1048)
|
- 2021.1.21 更新多语言识别模型,目前支持语种超过27种,[多语言模型下载](./doc/doc_ch/models_list.md),包括中文简体、中文繁体、英文、法文、德文、韩文、日文、意大利文、西班牙文、葡萄牙文、俄罗斯文、阿拉伯文等,后续计划可以参考[多语言研发计划](https://github.com/PaddlePaddle/PaddleOCR/issues/1048)
|
||||||
|
|
|
@ -66,7 +66,7 @@ Metric:
|
||||||
Train:
|
Train:
|
||||||
dataset:
|
dataset:
|
||||||
name: LMDBDataSet
|
name: LMDBDataSet
|
||||||
data_dir: ../training/
|
data_dir: ./train_data/data_lmdb_release/training/
|
||||||
transforms:
|
transforms:
|
||||||
- DecodeImage: # load image
|
- DecodeImage: # load image
|
||||||
img_mode: BGR
|
img_mode: BGR
|
||||||
|
@ -85,7 +85,7 @@ Train:
|
||||||
Eval:
|
Eval:
|
||||||
dataset:
|
dataset:
|
||||||
name: LMDBDataSet
|
name: LMDBDataSet
|
||||||
data_dir: ../validation/
|
data_dir: ./train_data/data_lmdb_release/validation/
|
||||||
transforms:
|
transforms:
|
||||||
- DecodeImage: # load image
|
- DecodeImage: # load image
|
||||||
img_mode: BGR
|
img_mode: BGR
|
||||||
|
|
|
@ -65,7 +65,7 @@ Metric:
|
||||||
Train:
|
Train:
|
||||||
dataset:
|
dataset:
|
||||||
name: LMDBDataSet
|
name: LMDBDataSet
|
||||||
data_dir: ../training/
|
data_dir: ./train_data/data_lmdb_release/training/
|
||||||
transforms:
|
transforms:
|
||||||
- DecodeImage: # load image
|
- DecodeImage: # load image
|
||||||
img_mode: BGR
|
img_mode: BGR
|
||||||
|
@ -84,7 +84,7 @@ Train:
|
||||||
Eval:
|
Eval:
|
||||||
dataset:
|
dataset:
|
||||||
name: LMDBDataSet
|
name: LMDBDataSet
|
||||||
data_dir: ../validation/
|
data_dir: ./train_data/data_lmdb_release/validation/
|
||||||
transforms:
|
transforms:
|
||||||
- DecodeImage: # load image
|
- DecodeImage: # load image
|
||||||
img_mode: BGR
|
img_mode: BGR
|
||||||
|
|
|
@ -59,7 +59,7 @@ Metric:
|
||||||
Train:
|
Train:
|
||||||
dataset:
|
dataset:
|
||||||
name: LMDBDataSet
|
name: LMDBDataSet
|
||||||
data_dir: ./train_data/srn_train_data_duiqi
|
data_dir: ./train_data/data_lmdb_release/training/
|
||||||
transforms:
|
transforms:
|
||||||
- DecodeImage: # load image
|
- DecodeImage: # load image
|
||||||
img_mode: BGR
|
img_mode: BGR
|
||||||
|
@ -84,7 +84,7 @@ Train:
|
||||||
Eval:
|
Eval:
|
||||||
dataset:
|
dataset:
|
||||||
name: LMDBDataSet
|
name: LMDBDataSet
|
||||||
data_dir: ./train_data/data_lmdb_release/evaluation
|
data_dir: ./train_data/data_lmdb_release/validation/
|
||||||
transforms:
|
transforms:
|
||||||
- DecodeImage: # load image
|
- DecodeImage: # load image
|
||||||
img_mode: BGR
|
img_mode: BGR
|
||||||
|
|
BIN
doc/joinus.PNG
BIN
doc/joinus.PNG
Binary file not shown.
Before Width: | Height: | Size: 104 KiB After Width: | Height: | Size: 109 KiB |
|
@ -215,7 +215,7 @@ class AttnLabelEncode(BaseRecLabelEncode):
|
||||||
return None
|
return None
|
||||||
data['length'] = np.array(len(text))
|
data['length'] = np.array(len(text))
|
||||||
text = [0] + text + [len(self.character) - 1] + [0] * (self.max_text_len
|
text = [0] + text + [len(self.character) - 1] + [0] * (self.max_text_len
|
||||||
- len(text) - 1)
|
- len(text) - 2)
|
||||||
data['label'] = np.array(text)
|
data['label'] = np.array(text)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
@ -261,7 +261,7 @@ class SRNLabelEncode(BaseRecLabelEncode):
|
||||||
if len(text) > self.max_text_len:
|
if len(text) > self.max_text_len:
|
||||||
return None
|
return None
|
||||||
data['length'] = np.array(len(text))
|
data['length'] = np.array(len(text))
|
||||||
text = text + [char_num] * (self.max_text_len - len(text))
|
text = text + [char_num - 1] * (self.max_text_len - len(text))
|
||||||
data['label'] = np.array(text)
|
data['label'] = np.array(text)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,9 @@ class AttentionHead(nn.Layer):
|
||||||
else:
|
else:
|
||||||
targets = paddle.zeros(shape=[batch_size], dtype="int32")
|
targets = paddle.zeros(shape=[batch_size], dtype="int32")
|
||||||
probs = None
|
probs = None
|
||||||
|
char_onehots = None
|
||||||
|
outputs = None
|
||||||
|
alpha = None
|
||||||
|
|
||||||
for i in range(num_steps):
|
for i in range(num_steps):
|
||||||
char_onehots = self._char_to_onehot(
|
char_onehots = self._char_to_onehot(
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
shapely
|
shapely
|
||||||
imgaug
|
scikit-image==0.17.2
|
||||||
|
imgaug==0.4.0
|
||||||
pyclipper
|
pyclipper
|
||||||
lmdb
|
lmdb
|
||||||
opencv-python==4.2.0.32
|
opencv-python==4.2.0.32
|
||||||
|
|
|
@ -47,6 +47,7 @@ def main():
|
||||||
config['Architecture']["Head"]['out_channels'] = len(
|
config['Architecture']["Head"]['out_channels'] = len(
|
||||||
getattr(post_process_class, 'character'))
|
getattr(post_process_class, 'character'))
|
||||||
model = build_model(config['Architecture'])
|
model = build_model(config['Architecture'])
|
||||||
|
use_srn = config['Architecture']['algorithm'] == "SRN"
|
||||||
|
|
||||||
best_model_dict = init_model(config, model, logger)
|
best_model_dict = init_model(config, model, logger)
|
||||||
if len(best_model_dict):
|
if len(best_model_dict):
|
||||||
|
@ -59,7 +60,7 @@ def main():
|
||||||
|
|
||||||
# start eval
|
# start eval
|
||||||
metirc = program.eval(model, valid_dataloader, post_process_class,
|
metirc = program.eval(model, valid_dataloader, post_process_class,
|
||||||
eval_class)
|
eval_class, use_srn)
|
||||||
logger.info('metric eval ***************')
|
logger.info('metric eval ***************')
|
||||||
for k, v in metirc.items():
|
for k, v in metirc.items():
|
||||||
logger.info('{}:{}'.format(k, v))
|
logger.info('{}:{}'.format(k, v))
|
||||||
|
|
|
@ -54,6 +54,13 @@ class TextRecognizer(object):
|
||||||
"character_dict_path": args.rec_char_dict_path,
|
"character_dict_path": args.rec_char_dict_path,
|
||||||
"use_space_char": args.use_space_char
|
"use_space_char": args.use_space_char
|
||||||
}
|
}
|
||||||
|
elif self.rec_algorithm == "RARE":
|
||||||
|
postprocess_params = {
|
||||||
|
'name': 'AttnLabelDecode',
|
||||||
|
"character_type": args.rec_char_type,
|
||||||
|
"character_dict_path": args.rec_char_dict_path,
|
||||||
|
"use_space_char": args.use_space_char
|
||||||
|
}
|
||||||
self.postprocess_op = build_post_process(postprocess_params)
|
self.postprocess_op = build_post_process(postprocess_params)
|
||||||
self.predictor, self.input_tensor, self.output_tensors = \
|
self.predictor, self.input_tensor, self.output_tensors = \
|
||||||
utility.create_predictor(args, 'rec', logger)
|
utility.create_predictor(args, 'rec', logger)
|
||||||
|
|
|
@ -182,6 +182,8 @@ def train(config,
|
||||||
model_average = False
|
model_average = False
|
||||||
model.train()
|
model.train()
|
||||||
|
|
||||||
|
use_srn = config['Architecture']['algorithm'] == "SRN"
|
||||||
|
|
||||||
if 'start_epoch' in best_model_dict:
|
if 'start_epoch' in best_model_dict:
|
||||||
start_epoch = best_model_dict['start_epoch']
|
start_epoch = best_model_dict['start_epoch']
|
||||||
else:
|
else:
|
||||||
|
@ -200,7 +202,7 @@ def train(config,
|
||||||
break
|
break
|
||||||
lr = optimizer.get_lr()
|
lr = optimizer.get_lr()
|
||||||
images = batch[0]
|
images = batch[0]
|
||||||
if config['Architecture']['algorithm'] == "SRN":
|
if use_srn:
|
||||||
others = batch[-4:]
|
others = batch[-4:]
|
||||||
preds = model(images, others)
|
preds = model(images, others)
|
||||||
model_average = True
|
model_average = True
|
||||||
|
@ -256,8 +258,12 @@ def train(config,
|
||||||
min_average_window=10000,
|
min_average_window=10000,
|
||||||
max_average_window=15625)
|
max_average_window=15625)
|
||||||
Model_Average.apply()
|
Model_Average.apply()
|
||||||
cur_metric = eval(model, valid_dataloader, post_process_class,
|
cur_metric = eval(
|
||||||
eval_class)
|
model,
|
||||||
|
valid_dataloader,
|
||||||
|
post_process_class,
|
||||||
|
eval_class,
|
||||||
|
use_srn=use_srn)
|
||||||
cur_metric_str = 'cur metric, {}'.format(', '.join(
|
cur_metric_str = 'cur metric, {}'.format(', '.join(
|
||||||
['{}: {}'.format(k, v) for k, v in cur_metric.items()]))
|
['{}: {}'.format(k, v) for k, v in cur_metric.items()]))
|
||||||
logger.info(cur_metric_str)
|
logger.info(cur_metric_str)
|
||||||
|
@ -321,7 +327,8 @@ def train(config,
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
def eval(model, valid_dataloader, post_process_class, eval_class):
|
def eval(model, valid_dataloader, post_process_class, eval_class,
|
||||||
|
use_srn=False):
|
||||||
model.eval()
|
model.eval()
|
||||||
with paddle.no_grad():
|
with paddle.no_grad():
|
||||||
total_frame = 0.0
|
total_frame = 0.0
|
||||||
|
@ -332,7 +339,8 @@ def eval(model, valid_dataloader, post_process_class, eval_class):
|
||||||
break
|
break
|
||||||
images = batch[0]
|
images = batch[0]
|
||||||
start = time.time()
|
start = time.time()
|
||||||
if "SRN" in str(model.head):
|
|
||||||
|
if use_srn:
|
||||||
others = batch[-4:]
|
others = batch[-4:]
|
||||||
preds = model(images, others)
|
preds = model(images, others)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue