merge dygraph
This commit is contained in:
commit
0de15430fd
|
@ -10,7 +10,7 @@ Global:
|
|||
cal_metric_during_train: True
|
||||
pretrained_model:
|
||||
checkpoints:
|
||||
save_inference_dir:
|
||||
save_inference_dir: ./
|
||||
use_visualdl: False
|
||||
infer_img: doc/imgs_words_en/word_10.png
|
||||
# for data or label process
|
||||
|
@ -60,8 +60,8 @@ Metric:
|
|||
Train:
|
||||
dataset:
|
||||
name: SimpleDataSet
|
||||
data_dir: ./train_data/
|
||||
label_file_list: ["./train_data/train_list.txt"]
|
||||
data_dir: ./train_data/ic15_data/
|
||||
label_file_list: ["./train_data/ic15_data/rec_gt_train.txt"]
|
||||
transforms:
|
||||
- DecodeImage: # load image
|
||||
img_mode: BGR
|
||||
|
@ -81,8 +81,8 @@ Train:
|
|||
Eval:
|
||||
dataset:
|
||||
name: SimpleDataSet
|
||||
data_dir: ./train_data/
|
||||
label_file_list: ["./train_data/val_list.txt"]
|
||||
data_dir: ./train_data/ic15_data
|
||||
label_file_list: ["./train_data/ic15_data/rec_gt_test.txt"]
|
||||
transforms:
|
||||
- DecodeImage: # load image
|
||||
img_mode: BGR
|
||||
|
|
|
@ -37,10 +37,8 @@ endif()
|
|||
|
||||
|
||||
if (WIN32)
|
||||
include_directories("${PADDLE_LIB}/paddle/fluid/inference")
|
||||
include_directories("${PADDLE_LIB}/paddle/include")
|
||||
link_directories("${PADDLE_LIB}/paddle/lib")
|
||||
link_directories("${PADDLE_LIB}/paddle/fluid/inference")
|
||||
find_package(OpenCV REQUIRED PATHS ${OPENCV_DIR}/build/ NO_DEFAULT_PATH)
|
||||
|
||||
else ()
|
||||
|
|
|
@ -21,12 +21,18 @@ std::vector<std::string> OCRConfig::split(const std::string &str,
|
|||
std::vector<std::string> res;
|
||||
if ("" == str)
|
||||
return res;
|
||||
char strs[str.length() + 1];
|
||||
|
||||
int strlen = str.length() + 1;
|
||||
chars *strs = new char[strlen];
|
||||
std::strcpy(strs, str.c_str());
|
||||
|
||||
char d[delim.length() + 1];
|
||||
int delimlen = delim.length() + 1;
|
||||
char *d = new char[delimlen];
|
||||
std::strcpy(d, delim.c_str());
|
||||
|
||||
delete[] strs;
|
||||
delete[] d;
|
||||
|
||||
char *p = std::strtok(strs, d);
|
||||
while (p) {
|
||||
std::string s = p;
|
||||
|
|
BIN
doc/joinus.PNG
BIN
doc/joinus.PNG
Binary file not shown.
Before Width: | Height: | Size: 212 KiB After Width: | Height: | Size: 203 KiB |
|
@ -7,7 +7,7 @@ tqdm
|
|||
numpy
|
||||
visualdl
|
||||
python-Levenshtein
|
||||
opencv-contrib-python==4.2.0.32
|
||||
opencv-contrib-python==4.4.0.46
|
||||
lxml
|
||||
premailer
|
||||
openpyxl
|
|
@ -49,3 +49,4 @@ inference:tools/infer/predict_det.py
|
|||
--save_log_path:null
|
||||
--benchmark:True
|
||||
null:null
|
||||
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
===========================train_params===========================
|
||||
model_name:ocr_rec
|
||||
python:python3.7
|
||||
gpu_list:0|2,3
|
||||
Global.use_gpu:True|True
|
||||
Global.auto_cast:null
|
||||
Global.epoch_num:lite_train_infer=2|whole_train_infer=300
|
||||
Global.save_model_dir:./output/
|
||||
Train.loader.batch_size_per_card:lite_train_infer=128|whole_train_infer=128
|
||||
Global.pretrained_model:null
|
||||
train_model_name:latest
|
||||
train_infer_img_dir:./train_data/ic15_data/train
|
||||
null:null
|
||||
##
|
||||
trainer:norm_train|pact_train
|
||||
norm_train:tools/train.py -c configs/rec/rec_icdar15_train.yml -o
|
||||
pact_train:deploy/slim/quantization/quant.py -c configs/rec/rec_icdar15_train.yml -o
|
||||
fpgm_train:null
|
||||
distill_train:null
|
||||
null:null
|
||||
null:null
|
||||
##
|
||||
===========================eval_params===========================
|
||||
eval:tools/eval.py -c configs/rec/rec_icdar15_train.yml -o
|
||||
null:null
|
||||
##
|
||||
===========================infer_params===========================
|
||||
Global.save_inference_dir:./output/
|
||||
Global.pretrained_model:
|
||||
norm_export:tools/export_model.py -c configs/rec/rec_icdar15_train.yml -o
|
||||
quant_export:deploy/slim/quantization/export_model.py -c configs/rec/rec_icdar15_train.yml -o
|
||||
fpgm_export:null
|
||||
distill_export:null
|
||||
export1:null
|
||||
export2:null
|
||||
##
|
||||
infer_model:./inference/ch_ppocr_mobile_v2.0_rec_infer/
|
||||
infer_export:null
|
||||
infer_quant:False
|
||||
inference:tools/infer/predict_rec.py
|
||||
--use_gpu:True|False
|
||||
--enable_mkldnn:True|False
|
||||
--cpu_threads:1|6
|
||||
--rec_batch_num:1
|
||||
--use_tensorrt:True|False
|
||||
--precision:fp32|fp16|int8
|
||||
--rec_model_dir:
|
||||
--image_dir:./inference/rec_inference
|
||||
--save_log_path:./test/output/
|
||||
--benchmark:True
|
||||
null:null
|
|
@ -35,32 +35,42 @@ if [ ${MODE} = "lite_train_infer" ];then
|
|||
# pretrain lite train data
|
||||
wget -nc -P ./pretrain_models/ https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MobileNetV3_large_x0_5_pretrained.pdparams
|
||||
rm -rf ./train_data/icdar2015
|
||||
rm -rf ./train_data/ic15_data
|
||||
wget -nc -P ./train_data/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/icdar2015_lite.tar
|
||||
cd ./train_data/ && tar xf icdar2015_lite.tar
|
||||
wget -nc -P ./train_data/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/ic15_data.tar # todo change to bcebos
|
||||
|
||||
cd ./train_data/ && tar xf icdar2015_lite.tar && tar xf ic15_data.tar
|
||||
ln -s ./icdar2015_lite ./icdar2015
|
||||
cd ../
|
||||
elif [ ${MODE} = "whole_train_infer" ];then
|
||||
wget -nc -P ./pretrain_models/ https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MobileNetV3_large_x0_5_pretrained.pdparams
|
||||
rm -rf ./train_data/icdar2015
|
||||
rm -rf ./train_data/ic15_data
|
||||
wget -nc -P ./train_data/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/icdar2015.tar
|
||||
cd ./train_data/ && tar xf icdar2015.tar && cd ../
|
||||
wget -nc -P ./train_data/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/ic15_data.tar
|
||||
cd ./train_data/ && tar xf icdar2015.tar && tar xf ic15_data.tar && cd ../
|
||||
elif [ ${MODE} = "whole_infer" ];then
|
||||
wget -nc -P ./pretrain_models/ https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MobileNetV3_large_x0_5_pretrained.pdparams
|
||||
rm -rf ./train_data/icdar2015
|
||||
rm -rf ./train_data/ic15_data
|
||||
wget -nc -P ./train_data/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/icdar2015_infer.tar
|
||||
cd ./train_data/ && tar xf icdar2015_infer.tar
|
||||
wget -nc -P ./train_data/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/ic15_data.tar
|
||||
cd ./train_data/ && tar xf icdar2015_infer.tar && tar xf ic15_data.tar
|
||||
ln -s ./icdar2015_infer ./icdar2015
|
||||
cd ../
|
||||
else
|
||||
rm -rf ./train_data/icdar2015
|
||||
if [[ ${model_name} = "ocr_det" ]]; then
|
||||
wget -nc -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/ch_det_data_50.tar
|
||||
if [ ${model_name} = "ocr_det" ]; then
|
||||
eval_model_name="ch_ppocr_mobile_v2.0_det_infer"
|
||||
rm -rf ./train_data/icdar2015
|
||||
wget -nc -P ./train_data https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/ch_det_data_50.tar
|
||||
wget -nc -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_det_infer.tar
|
||||
cd ./inference && tar xf ${eval_model_name}.tar && tar xf ch_det_data_50.tar && cd ../
|
||||
else
|
||||
eval_model_name="ch_ppocr_mobile_v2.0_rec_train"
|
||||
wget -nc -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_rec_train.tar
|
||||
cd ./inference && tar xf ${eval_model_name}.tar && cd ../
|
||||
rm -rf ./train_data/ic15_data
|
||||
eval_model_name="ch_ppocr_mobile_v2.0_rec_infer"
|
||||
wget -nc -P ./train_data/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/ic15_data.tar
|
||||
wget -nc -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_rec_infer.tar
|
||||
cd ./inference && tar xf ${eval_model_name}.tar && tar xf ic15_data.tar && cd ../
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
|
@ -234,18 +234,21 @@ if [ ${MODE} = "infer" ]; then
|
|||
for infer_model in ${infer_model_dir_list[*]}; do
|
||||
# run export
|
||||
if [ ${infer_run_exports[Count]} != "null" ];then
|
||||
save_infer_dir=$(dirname $infer_model)
|
||||
set_export_weight=$(func_set_params "${export_weight}" "${infer_model}")
|
||||
set_save_infer_key=$(func_set_params "${save_infer_key}" "${infer_model}")
|
||||
set_save_infer_key=$(func_set_params "${save_infer_key}" "${save_infer_dir}")
|
||||
export_cmd="${python} ${norm_export} ${set_export_weight} ${set_save_infer_key}"
|
||||
eval $export_cmd
|
||||
status_export=$?
|
||||
if [ ${status_export} = 0 ];then
|
||||
status_check $status_export "${export_cmd}" "${status_log}"
|
||||
fi
|
||||
else
|
||||
save_infer_dir=${infer_model}
|
||||
fi
|
||||
#run inference
|
||||
is_quant=${infer_quant_flag[Count]}
|
||||
func_inference "${python}" "${inference_py}" "${infer_model}" "${LOG_PATH}" "${infer_img_dir}" ${is_quant}
|
||||
func_inference "${python}" "${inference_py}" "${save_infer_dir}" "${LOG_PATH}" "${infer_img_dir}" ${is_quant}
|
||||
Count=$(($Count + 1))
|
||||
done
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ def init_args():
|
|||
parser.add_argument("--det_db_box_thresh", type=float, default=0.6)
|
||||
parser.add_argument("--det_db_unclip_ratio", type=float, default=1.5)
|
||||
parser.add_argument("--max_batch_size", type=int, default=10)
|
||||
parser.add_argument("--use_dilation", type=bool, default=False)
|
||||
parser.add_argument("--use_dilation", type=str2bool, default=False)
|
||||
parser.add_argument("--det_db_score_mode", type=str, default="fast")
|
||||
# EAST parmas
|
||||
parser.add_argument("--det_east_score_thresh", type=float, default=0.8)
|
||||
|
@ -61,7 +61,7 @@ def init_args():
|
|||
# SAST parmas
|
||||
parser.add_argument("--det_sast_score_thresh", type=float, default=0.5)
|
||||
parser.add_argument("--det_sast_nms_thresh", type=float, default=0.2)
|
||||
parser.add_argument("--det_sast_polygon", type=bool, default=False)
|
||||
parser.add_argument("--det_sast_polygon", type=str2bool, default=False)
|
||||
|
||||
# params for text recognizer
|
||||
parser.add_argument("--rec_algorithm", type=str, default='CRNN')
|
||||
|
@ -90,7 +90,7 @@ def init_args():
|
|||
parser.add_argument(
|
||||
"--e2e_char_dict_path", type=str, default="./ppocr/utils/ic15_dict.txt")
|
||||
parser.add_argument("--e2e_pgnet_valid_set", type=str, default='totaltext')
|
||||
parser.add_argument("--e2e_pgnet_polygon", type=bool, default=True)
|
||||
parser.add_argument("--e2e_pgnet_polygon", type=str2bool, default=True)
|
||||
parser.add_argument("--e2e_pgnet_mode", type=str, default='fast')
|
||||
|
||||
# params for text classifier
|
||||
|
@ -111,7 +111,7 @@ def init_args():
|
|||
parser.add_argument("--total_process_num", type=int, default=1)
|
||||
parser.add_argument("--process_id", type=int, default=0)
|
||||
|
||||
parser.add_argument("--benchmark", type=bool, default=False)
|
||||
parser.add_argument("--benchmark", type=str2bool, default=False)
|
||||
parser.add_argument("--save_log_path", type=str, default="./log_output/")
|
||||
|
||||
parser.add_argument("--show_log", type=str2bool, default=True)
|
||||
|
@ -210,22 +210,22 @@ def create_predictor(args, mode, logger):
|
|||
"nearest_interp_v2_0.tmp_0": [1, 256, 40, 40]
|
||||
}
|
||||
min_pact_shape = {
|
||||
"nearest_interp_v2_26.tmp_0":[1,256,20,20],
|
||||
"nearest_interp_v2_27.tmp_0":[1,64,20,20],
|
||||
"nearest_interp_v2_28.tmp_0":[1,64,20,20],
|
||||
"nearest_interp_v2_29.tmp_0":[1,64,20,20]
|
||||
"nearest_interp_v2_26.tmp_0": [1, 256, 20, 20],
|
||||
"nearest_interp_v2_27.tmp_0": [1, 64, 20, 20],
|
||||
"nearest_interp_v2_28.tmp_0": [1, 64, 20, 20],
|
||||
"nearest_interp_v2_29.tmp_0": [1, 64, 20, 20]
|
||||
}
|
||||
max_pact_shape = {
|
||||
"nearest_interp_v2_26.tmp_0":[1,256,400,400],
|
||||
"nearest_interp_v2_27.tmp_0":[1,64,400,400],
|
||||
"nearest_interp_v2_28.tmp_0":[1,64,400,400],
|
||||
"nearest_interp_v2_29.tmp_0":[1,64,400,400]
|
||||
"nearest_interp_v2_26.tmp_0": [1, 256, 400, 400],
|
||||
"nearest_interp_v2_27.tmp_0": [1, 64, 400, 400],
|
||||
"nearest_interp_v2_28.tmp_0": [1, 64, 400, 400],
|
||||
"nearest_interp_v2_29.tmp_0": [1, 64, 400, 400]
|
||||
}
|
||||
opt_pact_shape = {
|
||||
"nearest_interp_v2_26.tmp_0":[1,256,160,160],
|
||||
"nearest_interp_v2_27.tmp_0":[1,64,160,160],
|
||||
"nearest_interp_v2_28.tmp_0":[1,64,160,160],
|
||||
"nearest_interp_v2_29.tmp_0":[1,64,160,160]
|
||||
"nearest_interp_v2_26.tmp_0": [1, 256, 160, 160],
|
||||
"nearest_interp_v2_27.tmp_0": [1, 64, 160, 160],
|
||||
"nearest_interp_v2_28.tmp_0": [1, 64, 160, 160],
|
||||
"nearest_interp_v2_29.tmp_0": [1, 64, 160, 160]
|
||||
}
|
||||
min_input_shape.update(min_pact_shape)
|
||||
max_input_shape.update(max_pact_shape)
|
||||
|
|
Loading…
Reference in New Issue