Merge pull request #1113 from LDOUBLEV/fixocr
TestReader.infer_img to Global.infer_img
This commit is contained in:
commit
ad7f65f70a
|
@ -15,7 +15,6 @@ EvalReader:
|
||||||
TestReader:
|
TestReader:
|
||||||
reader_function: ppocr.data.det.dataset_traversal,EvalTestReader
|
reader_function: ppocr.data.det.dataset_traversal,EvalTestReader
|
||||||
process_function: ppocr.data.det.db_process,DBProcessTest
|
process_function: ppocr.data.det.db_process,DBProcessTest
|
||||||
infer_img:
|
|
||||||
img_set_dir: ./train_data/icdar2015/text_localization/
|
img_set_dir: ./train_data/icdar2015/text_localization/
|
||||||
label_file_path: ./train_data/icdar2015/text_localization/test_icdar2015_label.txt
|
label_file_path: ./train_data/icdar2015/text_localization/test_icdar2015_label.txt
|
||||||
do_eval: True
|
do_eval: True
|
||||||
|
|
|
@ -17,7 +17,6 @@ EvalReader:
|
||||||
TestReader:
|
TestReader:
|
||||||
reader_function: ppocr.data.det.dataset_traversal,EvalTestReader
|
reader_function: ppocr.data.det.dataset_traversal,EvalTestReader
|
||||||
process_function: ppocr.data.det.east_process,EASTProcessTest
|
process_function: ppocr.data.det.east_process,EASTProcessTest
|
||||||
infer_img:
|
|
||||||
img_set_dir: ./train_data/icdar2015/text_localization/
|
img_set_dir: ./train_data/icdar2015/text_localization/
|
||||||
label_file_path: ./train_data/icdar2015/text_localization/test_icdar2015_label.txt
|
label_file_path: ./train_data/icdar2015/text_localization/test_icdar2015_label.txt
|
||||||
do_eval: True
|
do_eval: True
|
||||||
|
|
|
@ -16,6 +16,7 @@ Global:
|
||||||
checkpoints:
|
checkpoints:
|
||||||
save_res_path: ./output/det_db/predicts_db.txt
|
save_res_path: ./output/det_db/predicts_db.txt
|
||||||
save_inference_dir:
|
save_inference_dir:
|
||||||
|
infer_img:
|
||||||
|
|
||||||
Architecture:
|
Architecture:
|
||||||
function: ppocr.modeling.architectures.det_model,DetModel
|
function: ppocr.modeling.architectures.det_model,DetModel
|
||||||
|
|
|
@ -16,6 +16,7 @@ Global:
|
||||||
checkpoints:
|
checkpoints:
|
||||||
save_res_path: ./output/det_db/predicts_db.txt
|
save_res_path: ./output/det_db/predicts_db.txt
|
||||||
save_inference_dir:
|
save_inference_dir:
|
||||||
|
infer_img:
|
||||||
|
|
||||||
Architecture:
|
Architecture:
|
||||||
function: ppocr.modeling.architectures.det_model,DetModel
|
function: ppocr.modeling.architectures.det_model,DetModel
|
||||||
|
|
|
@ -15,6 +15,7 @@ Global:
|
||||||
checkpoints:
|
checkpoints:
|
||||||
save_res_path: ./output/det_east/predicts_east.txt
|
save_res_path: ./output/det_east/predicts_east.txt
|
||||||
save_inference_dir:
|
save_inference_dir:
|
||||||
|
infer_img:
|
||||||
|
|
||||||
Architecture:
|
Architecture:
|
||||||
function: ppocr.modeling.architectures.det_model,DetModel
|
function: ppocr.modeling.architectures.det_model,DetModel
|
||||||
|
|
|
@ -15,6 +15,7 @@ Global:
|
||||||
save_res_path: ./output/det_r18_vd_db/predicts_db.txt
|
save_res_path: ./output/det_r18_vd_db/predicts_db.txt
|
||||||
checkpoints:
|
checkpoints:
|
||||||
save_inference_dir:
|
save_inference_dir:
|
||||||
|
infer_img:
|
||||||
|
|
||||||
Architecture:
|
Architecture:
|
||||||
function: ppocr.modeling.architectures.det_model,DetModel
|
function: ppocr.modeling.architectures.det_model,DetModel
|
||||||
|
|
|
@ -15,6 +15,7 @@ Global:
|
||||||
save_res_path: ./output/det_db/predicts_db.txt
|
save_res_path: ./output/det_db/predicts_db.txt
|
||||||
checkpoints:
|
checkpoints:
|
||||||
save_inference_dir:
|
save_inference_dir:
|
||||||
|
infer_img:
|
||||||
|
|
||||||
Architecture:
|
Architecture:
|
||||||
function: ppocr.modeling.architectures.det_model,DetModel
|
function: ppocr.modeling.architectures.det_model,DetModel
|
||||||
|
|
|
@ -15,6 +15,7 @@ Global:
|
||||||
save_res_path: ./output/det_east/predicts_east.txt
|
save_res_path: ./output/det_east/predicts_east.txt
|
||||||
checkpoints:
|
checkpoints:
|
||||||
save_inference_dir:
|
save_inference_dir:
|
||||||
|
infer_img:
|
||||||
|
|
||||||
Architecture:
|
Architecture:
|
||||||
function: ppocr.modeling.architectures.det_model,DetModel
|
function: ppocr.modeling.architectures.det_model,DetModel
|
||||||
|
|
|
@ -15,6 +15,7 @@ Global:
|
||||||
save_res_path: ./output/det_sast/predicts_sast.txt
|
save_res_path: ./output/det_sast/predicts_sast.txt
|
||||||
checkpoints:
|
checkpoints:
|
||||||
save_inference_dir:
|
save_inference_dir:
|
||||||
|
infer_img:
|
||||||
|
|
||||||
Architecture:
|
Architecture:
|
||||||
function: ppocr.modeling.architectures.det_model,DetModel
|
function: ppocr.modeling.architectures.det_model,DetModel
|
||||||
|
|
|
@ -15,6 +15,7 @@ Global:
|
||||||
save_res_path: ./output/det_sast/predicts_sast.txt
|
save_res_path: ./output/det_sast/predicts_sast.txt
|
||||||
checkpoints:
|
checkpoints:
|
||||||
save_inference_dir:
|
save_inference_dir:
|
||||||
|
infer_img:
|
||||||
|
|
||||||
Architecture:
|
Architecture:
|
||||||
function: ppocr.modeling.architectures.det_model,DetModel
|
function: ppocr.modeling.architectures.det_model,DetModel
|
||||||
|
|
|
@ -20,5 +20,4 @@ EvalReader:
|
||||||
TestReader:
|
TestReader:
|
||||||
reader_function: ppocr.data.det.dataset_traversal,EvalTestReader
|
reader_function: ppocr.data.det.dataset_traversal,EvalTestReader
|
||||||
process_function: ppocr.data.det.sast_process,SASTProcessTest
|
process_function: ppocr.data.det.sast_process,SASTProcessTest
|
||||||
infer_img: ./train_data/icdar2015/text_localization/ch4_test_images/img_11.jpg
|
|
||||||
max_side_len: 1536
|
max_side_len: 1536
|
||||||
|
|
|
@ -20,5 +20,4 @@ EvalReader:
|
||||||
TestReader:
|
TestReader:
|
||||||
reader_function: ppocr.data.det.dataset_traversal,EvalTestReader
|
reader_function: ppocr.data.det.dataset_traversal,EvalTestReader
|
||||||
process_function: ppocr.data.det.sast_process,SASTProcessTest
|
process_function: ppocr.data.det.sast_process,SASTProcessTest
|
||||||
infer_img: ./train_data/afs/total_text/Images/Test/img623.jpg
|
|
||||||
max_side_len: 768
|
max_side_len: 768
|
||||||
|
|
|
@ -119,16 +119,16 @@ python3 tools/eval.py -c configs/det/det_mv3_db_v1.1.yml -o Global.checkpoints=
|
||||||
|
|
||||||
测试单张图像的检测效果
|
测试单张图像的检测效果
|
||||||
```shell
|
```shell
|
||||||
python3 tools/infer_det.py -c configs/det/det_mv3_db_v1.1.yml -o TestReader.infer_img="./doc/imgs_en/img_10.jpg" Global.checkpoints="./output/det_db/best_accuracy"
|
python3 tools/infer_det.py -c configs/det/det_mv3_db_v1.1.yml -o Global.infer_img="./doc/imgs_en/img_10.jpg" Global.checkpoints="./output/det_db/best_accuracy"
|
||||||
```
|
```
|
||||||
|
|
||||||
测试DB模型时,调整后处理阈值,
|
测试DB模型时,调整后处理阈值,
|
||||||
```shell
|
```shell
|
||||||
python3 tools/infer_det.py -c configs/det/det_mv3_db_v1.1.yml -o TestReader.infer_img="./doc/imgs_en/img_10.jpg" Global.checkpoints="./output/det_db/best_accuracy" PostProcess.box_thresh=0.6 PostProcess.unclip_ratio=1.5
|
python3 tools/infer_det.py -c configs/det/det_mv3_db_v1.1.yml -o Global.infer_img="./doc/imgs_en/img_10.jpg" Global.checkpoints="./output/det_db/best_accuracy" PostProcess.box_thresh=0.6 PostProcess.unclip_ratio=1.5
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
测试文件夹下所有图像的检测效果
|
测试文件夹下所有图像的检测效果
|
||||||
```shell
|
```shell
|
||||||
python3 tools/infer_det.py -c configs/det/det_mv3_db_v1.1.yml -o TestReader.infer_img="./doc/imgs_en/" Global.checkpoints="./output/det_db/best_accuracy"
|
python3 tools/infer_det.py -c configs/det/det_mv3_db_v1.1.yml -o Global.infer_img="./doc/imgs_en/" Global.checkpoints="./output/det_db/best_accuracy"
|
||||||
```
|
```
|
||||||
|
|
|
@ -110,16 +110,16 @@ python3 tools/eval.py -c configs/det/det_mv3_db_v1.1.yml -o Global.checkpoints=
|
||||||
|
|
||||||
Test the detection result on a single image:
|
Test the detection result on a single image:
|
||||||
```shell
|
```shell
|
||||||
python3 tools/infer_det.py -c configs/det/det_mv3_db_v1.1.yml -o TestReader.infer_img="./doc/imgs_en/img_10.jpg" Global.checkpoints="./output/det_db/best_accuracy"
|
python3 tools/infer_det.py -c configs/det/det_mv3_db_v1.1.yml -o Global.infer_img="./doc/imgs_en/img_10.jpg" Global.checkpoints="./output/det_db/best_accuracy"
|
||||||
```
|
```
|
||||||
|
|
||||||
When testing the DB model, adjust the post-processing threshold:
|
When testing the DB model, adjust the post-processing threshold:
|
||||||
```shell
|
```shell
|
||||||
python3 tools/infer_det.py -c configs/det/det_mv3_db_v1.1.yml -o TestReader.infer_img="./doc/imgs_en/img_10.jpg" Global.checkpoints="./output/det_db/best_accuracy" PostProcess.box_thresh=0.6 PostProcess.unclip_ratio=1.5
|
python3 tools/infer_det.py -c configs/det/det_mv3_db_v1.1.yml -o Global.infer_img="./doc/imgs_en/img_10.jpg" Global.checkpoints="./output/det_db/best_accuracy" PostProcess.box_thresh=0.6 PostProcess.unclip_ratio=1.5
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
Test the detection result on all images in the folder:
|
Test the detection result on all images in the folder:
|
||||||
```shell
|
```shell
|
||||||
python3 tools/infer_det.py -c configs/det/det_mv3_db_v1.1.yml -o TestReader.infer_img="./doc/imgs_en/" Global.checkpoints="./output/det_db/best_accuracy"
|
python3 tools/infer_det.py -c configs/det/det_mv3_db_v1.1.yml -o Global.infer_img="./doc/imgs_en/" Global.checkpoints="./output/det_db/best_accuracy"
|
||||||
```
|
```
|
||||||
|
|
|
@ -294,7 +294,7 @@ The default prediction picture is stored in `infer_img`, and the weight is speci
|
||||||
|
|
||||||
```
|
```
|
||||||
# Predict English results
|
# Predict English results
|
||||||
python3 tools/infer_rec.py -c configs/rec/ch_ppocr_v1.1/rec_chinese_lite_train_v1.1.yml -o Global.checkpoints={path/to/weights}/best_accuracy TestReader.infer_img=doc/imgs_words/en/word_1.jpg
|
python3 tools/infer_rec.py -c configs/rec/ch_ppocr_v1.1/rec_chinese_lite_train_v1.1.yml -o Global.checkpoints={path/to/weights}/best_accuracy Global.infer_img=doc/imgs_words/en/word_1.jpg
|
||||||
```
|
```
|
||||||
|
|
||||||
Input image:
|
Input image:
|
||||||
|
@ -313,7 +313,7 @@ The configuration file used for prediction must be consistent with the training.
|
||||||
|
|
||||||
```
|
```
|
||||||
# Predict Chinese results
|
# Predict Chinese results
|
||||||
python3 tools/infer_rec.py -c configs/rec/ch_ppocr_v1.1/rec_chinese_lite_train_v1.1.yml -o Global.checkpoints={path/to/weights}/best_accuracy TestReader.infer_img=doc/imgs_words/ch/word_1.jpg
|
python3 tools/infer_rec.py -c configs/rec/ch_ppocr_v1.1/rec_chinese_lite_train_v1.1.yml -o Global.checkpoints={path/to/weights}/best_accuracy Global.infer_img=doc/imgs_words/ch/word_1.jpg
|
||||||
```
|
```
|
||||||
|
|
||||||
Input image:
|
Input image:
|
||||||
|
|
|
@ -104,8 +104,8 @@ def main():
|
||||||
save_res_path = config['Global']['save_res_path']
|
save_res_path = config['Global']['save_res_path']
|
||||||
if not os.path.exists(os.path.dirname(save_res_path)):
|
if not os.path.exists(os.path.dirname(save_res_path)):
|
||||||
os.makedirs(os.path.dirname(save_res_path))
|
os.makedirs(os.path.dirname(save_res_path))
|
||||||
with open(save_res_path, "wb") as fout:
|
|
||||||
|
|
||||||
|
with open(save_res_path, "wb") as fout:
|
||||||
test_reader = reader_main(config=config, mode='test')
|
test_reader = reader_main(config=config, mode='test')
|
||||||
tackling_num = 0
|
tackling_num = 0
|
||||||
for data in test_reader():
|
for data in test_reader():
|
||||||
|
@ -135,9 +135,15 @@ def main():
|
||||||
elif config['Global']['algorithm'] == 'DB':
|
elif config['Global']['algorithm'] == 'DB':
|
||||||
dic = {'maps': outs[0]}
|
dic = {'maps': outs[0]}
|
||||||
elif config['Global']['algorithm'] == 'SAST':
|
elif config['Global']['algorithm'] == 'SAST':
|
||||||
dic = {'f_score': outs[0], 'f_border': outs[1], 'f_tvo': outs[2], 'f_tco': outs[3]}
|
dic = {
|
||||||
|
'f_score': outs[0],
|
||||||
|
'f_border': outs[1],
|
||||||
|
'f_tvo': outs[2],
|
||||||
|
'f_tco': outs[3]
|
||||||
|
}
|
||||||
else:
|
else:
|
||||||
raise Exception("only support algorithm: ['EAST', 'DB', 'SAST']")
|
raise Exception(
|
||||||
|
"only support algorithm: ['EAST', 'DB', 'SAST']")
|
||||||
dt_boxes_list = postprocess(dic, ratio_list)
|
dt_boxes_list = postprocess(dic, ratio_list)
|
||||||
for ino in range(img_num):
|
for ino in range(img_num):
|
||||||
dt_boxes = dt_boxes_list[ino]
|
dt_boxes = dt_boxes_list[ino]
|
||||||
|
|
|
@ -121,7 +121,10 @@ def merge_config(config):
|
||||||
global_config.keys(), sub_keys[0])
|
global_config.keys(), sub_keys[0])
|
||||||
cur = global_config[sub_keys[0]]
|
cur = global_config[sub_keys[0]]
|
||||||
for idx, sub_key in enumerate(sub_keys[1:]):
|
for idx, sub_key in enumerate(sub_keys[1:]):
|
||||||
assert (sub_key in cur)
|
assert (
|
||||||
|
sub_key in cur
|
||||||
|
), "key {} not in sub_keys: {}, please check your running command.".format(
|
||||||
|
sub_key, cur)
|
||||||
if idx == len(sub_keys) - 2:
|
if idx == len(sub_keys) - 2:
|
||||||
cur[sub_key] = value
|
cur[sub_key] = value
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue