diff --git a/configs/rec/rec_mtb_nrtr.yml b/configs/rec/rec_mtb_nrtr.yml new file mode 100644 index 0000000000000000000000000000000000000000..635c392d705acd1fcfbf9f744a8d7167c448d74c --- /dev/null +++ b/configs/rec/rec_mtb_nrtr.yml @@ -0,0 +1,102 @@ +Global: + use_gpu: True + epoch_num: 21 + log_smooth_window: 20 + print_batch_step: 10 + save_model_dir: ./output/rec/nrtr/ + save_epoch_step: 1 + # evaluation is run every 2000 iterations + eval_batch_step: [0, 2000] + cal_metric_during_train: True + pretrained_model: + checkpoints: + save_inference_dir: + use_visualdl: False + infer_img: doc/imgs_words_en/word_10.png + # for data or label process + character_dict_path: + character_type: EN_symbol + max_text_length: 25 + infer_mode: False + use_space_char: True + save_res_path: ./output/rec/predicts_nrtr.txt + +Optimizer: + name: Adam + beta1: 0.9 + beta2: 0.99 + clip_norm: 5.0 + lr: + name: Cosine + learning_rate: 0.0005 + warmup_epoch: 2 + regularizer: + name: 'L2' + factor: 0. + +Architecture: + model_type: rec + algorithm: NRTR + in_channels: 1 + Transform: + Backbone: + name: MTB + cnn_num: 2 + Head: + name: Transformer + d_model: 512 + num_encoder_layers: 6 + beam_size: 10 # When Beam size is greater than 0, it means to use beam search when evaluation. + + +Loss: + name: NRTRLoss + smoothing: True + +PostProcess: + name: NRTRLabelDecode + +Metric: + name: RecMetric + main_indicator: acc + +Train: + dataset: + name: LMDBDataSet + data_dir: ./train_data/data_lmdb_release/training/ + transforms: + - NRTRDecodeImage: # load image + img_mode: BGR + channel_first: False + - NRTRLabelEncode: # Class handling label + - NRTRRecResizeImg: + image_shape: [100, 32] + resize_type: PIL # PIL or OpenCV + - KeepKeys: + keep_keys: ['image', 'label', 'length'] # dataloader will return list in this order + loader: + shuffle: True + batch_size_per_card: 512 + drop_last: True + num_workers: 8 + +Eval: + dataset: + name: LMDBDataSet + data_dir: ./train_data/data_lmdb_release/evaluation/ + transforms: + - NRTRDecodeImage: # load image + img_mode: BGR + channel_first: False + - NRTRLabelEncode: # Class handling label + - NRTRRecResizeImg: + image_shape: [100, 32] + resize_type: PIL # PIL or OpenCV + - KeepKeys: + keep_keys: ['image', 'label', 'length'] # dataloader will return list in this order + loader: + shuffle: False + drop_last: False + batch_size_per_card: 256 + num_workers: 1 + use_shared_memory: False diff --git a/deploy/cpp_infer/CMakeLists.txt b/deploy/cpp_infer/CMakeLists.txt index efb183c5b4ebb460832b7d353e8a019ee079d975..6d3ecb6ac2e9e6993814f077ca772d0d94f5d008 100644 --- a/deploy/cpp_infer/CMakeLists.txt +++ b/deploy/cpp_infer/CMakeLists.txt @@ -1,4 +1,5 @@ project(ppocr CXX C) +cmake_minimum_required(VERSION 3.14) option(WITH_MKL "Compile demo with MKL/OpenBlas support, default use MKL." ON) option(WITH_GPU "Compile demo with GPU/CPU, default use CPU." OFF) @@ -206,9 +207,12 @@ endif() set(DEPS ${DEPS} ${OpenCV_LIBS}) +include(FetchContent) +include(external-cmake/auto-log.cmake) +include_directories(${FETCHCONTENT_BASE_DIR}/extern_autolog-src) + AUX_SOURCE_DIRECTORY(./src SRCS) add_executable(${DEMO_NAME} ${SRCS}) - target_link_libraries(${DEMO_NAME} ${DEPS}) if (WIN32 AND WITH_MKL) diff --git a/deploy/cpp_infer/external-cmake/auto-log.cmake b/deploy/cpp_infer/external-cmake/auto-log.cmake new file mode 100644 index 0000000000000000000000000000000000000000..becbff0f45df51e5db541889ae1ffdacf2c4fc78 --- /dev/null +++ b/deploy/cpp_infer/external-cmake/auto-log.cmake @@ -0,0 +1,13 @@ +find_package(Git REQUIRED) +include(FetchContent) + +set(FETCHCONTENT_BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}/third-party") + +FetchContent_Declare( + extern_Autolog + PREFIX autolog + GIT_REPOSITORY https://github.com/LDOUBLEV/AutoLog.git + GIT_TAG main +) +FetchContent_MakeAvailable(extern_Autolog) + diff --git a/deploy/cpp_infer/include/ocr_cls.h b/deploy/cpp_infer/include/ocr_cls.h index a43c80053498843ec0152c96d209057017fff352..742e1f8bb0392859ea4bc3a6a4b4410f6b375826 100644 --- a/deploy/cpp_infer/include/ocr_cls.h +++ b/deploy/cpp_infer/include/ocr_cls.h @@ -42,7 +42,7 @@ public: const int &gpu_id, const int &gpu_mem, const int &cpu_math_library_num_threads, const bool &use_mkldnn, const double &cls_thresh, - const bool &use_tensorrt, const bool &use_fp16) { + const bool &use_tensorrt, const std::string &precision) { this->use_gpu_ = use_gpu; this->gpu_id_ = gpu_id; this->gpu_mem_ = gpu_mem; @@ -51,7 +51,7 @@ public: this->cls_thresh = cls_thresh; this->use_tensorrt_ = use_tensorrt; - this->use_fp16_ = use_fp16; + this->precision_ = precision; LoadModel(model_dir); } @@ -75,7 +75,7 @@ private: std::vector scale_ = {1 / 0.5f, 1 / 0.5f, 1 / 0.5f}; bool is_scale_ = true; bool use_tensorrt_ = false; - bool use_fp16_ = false; + std::string precision_ = "fp32"; // pre-process ClsResizeImg resize_op_; Normalize normalize_op_; diff --git a/deploy/cpp_infer/include/ocr_det.h b/deploy/cpp_infer/include/ocr_det.h index 18318c9c4e37136db62c1338db1b58f82859f037..e5a31ed8e5ab6397c4fa67388252e2baef8b9dd7 100644 --- a/deploy/cpp_infer/include/ocr_det.h +++ b/deploy/cpp_infer/include/ocr_det.h @@ -46,7 +46,7 @@ public: const double &det_db_box_thresh, const double &det_db_unclip_ratio, const bool &use_polygon_score, const bool &visualize, - const bool &use_tensorrt, const bool &use_fp16) { + const bool &use_tensorrt, const std::string &precision) { this->use_gpu_ = use_gpu; this->gpu_id_ = gpu_id; this->gpu_mem_ = gpu_mem; @@ -62,7 +62,7 @@ public: this->visualize_ = visualize; this->use_tensorrt_ = use_tensorrt; - this->use_fp16_ = use_fp16; + this->precision_ = precision; LoadModel(model_dir); } @@ -71,7 +71,7 @@ public: void LoadModel(const std::string &model_dir); // Run predictor - void Run(cv::Mat &img, std::vector>> &boxes); + void Run(cv::Mat &img, std::vector>> &boxes, std::vector *times); private: std::shared_ptr predictor_; @@ -91,7 +91,7 @@ private: bool visualize_ = true; bool use_tensorrt_ = false; - bool use_fp16_ = false; + std::string precision_ = "fp32"; std::vector mean_ = {0.485f, 0.456f, 0.406f}; std::vector scale_ = {1 / 0.229f, 1 / 0.224f, 1 / 0.225f}; diff --git a/deploy/cpp_infer/include/ocr_rec.h b/deploy/cpp_infer/include/ocr_rec.h index 25f55ae26a29cc4f93f152cc072bd444aedf6bf2..d585112b051daff7c03060836a4c065ba6e3949c 100644 --- a/deploy/cpp_infer/include/ocr_rec.h +++ b/deploy/cpp_infer/include/ocr_rec.h @@ -44,14 +44,14 @@ public: const int &gpu_id, const int &gpu_mem, const int &cpu_math_library_num_threads, const bool &use_mkldnn, const string &label_path, - const bool &use_tensorrt, const bool &use_fp16) { + const bool &use_tensorrt, const std::string &precision) { this->use_gpu_ = use_gpu; this->gpu_id_ = gpu_id; this->gpu_mem_ = gpu_mem; this->cpu_math_library_num_threads_ = cpu_math_library_num_threads; this->use_mkldnn_ = use_mkldnn; this->use_tensorrt_ = use_tensorrt; - this->use_fp16_ = use_fp16; + this->precision_ = precision; this->label_list_ = Utility::ReadDict(label_path); this->label_list_.insert(this->label_list_.begin(), @@ -64,7 +64,7 @@ public: // Load Paddle inference model void LoadModel(const std::string &model_dir); - void Run(cv::Mat &img); + void Run(cv::Mat &img, std::vector *times); private: std::shared_ptr predictor_; @@ -81,7 +81,7 @@ private: std::vector scale_ = {1 / 0.5f, 1 / 0.5f, 1 / 0.5f}; bool is_scale_ = true; bool use_tensorrt_ = false; - bool use_fp16_ = false; + std::string precision_ = "fp32"; // pre-process CrnnResizeImg resize_op_; Normalize normalize_op_; @@ -90,9 +90,6 @@ private: // post-process PostProcessor post_processor_; - cv::Mat GetRotateCropImage(const cv::Mat &srcimage, - std::vector> box); - }; // class CrnnRecognizer } // namespace PaddleOCR diff --git a/deploy/cpp_infer/include/utility.h b/deploy/cpp_infer/include/utility.h index 6e8173e007279319657250b376de022240bc6f62..678187d3fabfb1c91584226950155b3c47b5f93f 100644 --- a/deploy/cpp_infer/include/utility.h +++ b/deploy/cpp_infer/include/utility.h @@ -47,6 +47,9 @@ public: static void GetAllFiles(const char *dir_name, std::vector &all_inputs); + + static cv::Mat GetRotateCropImage(const cv::Mat &srcimage, + std::vector> box); }; } // namespace PaddleOCR \ No newline at end of file diff --git a/deploy/cpp_infer/src/main.cpp b/deploy/cpp_infer/src/main.cpp index 830f032d4649c44ed33527c383dd332b494c47c3..6e8ded7f8d3cde08182d551decedd2e1777956aa 100644 --- a/deploy/cpp_infer/src/main.cpp +++ b/deploy/cpp_infer/src/main.cpp @@ -31,17 +31,21 @@ #include #include #include +#include #include #include +#include "auto_log/autolog.h" DEFINE_bool(use_gpu, false, "Infering with GPU or CPU."); DEFINE_int32(gpu_id, 0, "Device id of GPU to execute."); DEFINE_int32(gpu_mem, 4000, "GPU id when infering with GPU."); -DEFINE_int32(cpu_math_library_num_threads, 10, "Num of threads with CPU."); -DEFINE_bool(use_mkldnn, false, "Whether use mkldnn with CPU."); +DEFINE_int32(cpu_threads, 10, "Num of threads with CPU."); +DEFINE_bool(enable_mkldnn, false, "Whether use mkldnn with CPU."); DEFINE_bool(use_tensorrt, false, "Whether use tensorrt."); -DEFINE_bool(use_fp16, false, "Whether use fp16 when use tensorrt."); +DEFINE_string(precision, "fp32", "Precision be one of fp32/fp16/int8"); +DEFINE_bool(benchmark, true, "Whether use benchmark."); +DEFINE_string(save_log_path, "./log_output/", "Save benchmark log path."); // detection related DEFINE_string(image_dir, "", "Dir of input image."); DEFINE_string(det_model_dir, "", "Path of det inference model."); @@ -57,6 +61,7 @@ DEFINE_string(cls_model_dir, "", "Path of cls inference model."); DEFINE_double(cls_thresh, 0.9, "Threshold of cls_thresh."); // recognition related DEFINE_string(rec_model_dir, "", "Path of rec inference model."); +DEFINE_int32(rec_batch_num, 1, "rec_batch_num."); DEFINE_string(char_list_file, "../../ppocr/utils/ppocr_keys_v1.txt", "Path of dictionary."); @@ -76,88 +81,15 @@ static bool PathExists(const std::string& path){ } -cv::Mat GetRotateCropImage(const cv::Mat &srcimage, - std::vector> box) { - cv::Mat image; - srcimage.copyTo(image); - std::vector> points = box; - - int x_collect[4] = {box[0][0], box[1][0], box[2][0], box[3][0]}; - int y_collect[4] = {box[0][1], box[1][1], box[2][1], box[3][1]}; - int left = int(*std::min_element(x_collect, x_collect + 4)); - int right = int(*std::max_element(x_collect, x_collect + 4)); - int top = int(*std::min_element(y_collect, y_collect + 4)); - int bottom = int(*std::max_element(y_collect, y_collect + 4)); - - cv::Mat img_crop; - image(cv::Rect(left, top, right - left, bottom - top)).copyTo(img_crop); - - for (int i = 0; i < points.size(); i++) { - points[i][0] -= left; - points[i][1] -= top; - } - - int img_crop_width = int(sqrt(pow(points[0][0] - points[1][0], 2) + - pow(points[0][1] - points[1][1], 2))); - int img_crop_height = int(sqrt(pow(points[0][0] - points[3][0], 2) + - pow(points[0][1] - points[3][1], 2))); - - cv::Point2f pts_std[4]; - pts_std[0] = cv::Point2f(0., 0.); - pts_std[1] = cv::Point2f(img_crop_width, 0.); - pts_std[2] = cv::Point2f(img_crop_width, img_crop_height); - pts_std[3] = cv::Point2f(0.f, img_crop_height); - - cv::Point2f pointsf[4]; - pointsf[0] = cv::Point2f(points[0][0], points[0][1]); - pointsf[1] = cv::Point2f(points[1][0], points[1][1]); - pointsf[2] = cv::Point2f(points[2][0], points[2][1]); - pointsf[3] = cv::Point2f(points[3][0], points[3][1]); - - cv::Mat M = cv::getPerspectiveTransform(pointsf, pts_std); - - cv::Mat dst_img; - cv::warpPerspective(img_crop, dst_img, M, - cv::Size(img_crop_width, img_crop_height), - cv::BORDER_REPLICATE); - - if (float(dst_img.rows) >= float(dst_img.cols) * 1.5) { - cv::Mat srcCopy = cv::Mat(dst_img.rows, dst_img.cols, dst_img.depth()); - cv::transpose(dst_img, srcCopy); - cv::flip(srcCopy, srcCopy, 0); - return srcCopy; - } else { - return dst_img; - } -} - - -int main_det(int argc, char **argv) { - // Parsing command-line - google::ParseCommandLineFlags(&argc, &argv, true); - if (FLAGS_det_model_dir.empty() || FLAGS_image_dir.empty()) { - std::cout << "Usage[det]: ./ppocr --det_model_dir=/PATH/TO/DET_INFERENCE_MODEL/ " - << "--image_dir=/PATH/TO/INPUT/IMAGE/" << std::endl; - exit(1); - } - if (!PathExists(FLAGS_image_dir)) { - std::cerr << "[ERROR] image path not exist! image_dir: " << FLAGS_image_dir << endl; - exit(1); - } - - std::vector cv_all_img_names; - cv::glob(FLAGS_image_dir, cv_all_img_names); - std::cout << "total images num: " << cv_all_img_names.size() << endl; - +int main_det(std::vector cv_all_img_names) { + std::vector time_info = {0, 0, 0}; DBDetector det(FLAGS_det_model_dir, FLAGS_use_gpu, FLAGS_gpu_id, - FLAGS_gpu_mem, FLAGS_cpu_math_library_num_threads, - FLAGS_use_mkldnn, FLAGS_max_side_len, FLAGS_det_db_thresh, + FLAGS_gpu_mem, FLAGS_cpu_threads, + FLAGS_enable_mkldnn, FLAGS_max_side_len, FLAGS_det_db_thresh, FLAGS_det_db_box_thresh, FLAGS_det_db_unclip_ratio, FLAGS_use_polygon_score, FLAGS_visualize, - FLAGS_use_tensorrt, FLAGS_use_fp16); - - auto start = std::chrono::system_clock::now(); - + FLAGS_use_tensorrt, FLAGS_precision); + for (int i = 0; i < cv_all_img_names.size(); ++i) { LOG(INFO) << "The predict img: " << cv_all_img_names[i]; @@ -167,46 +99,38 @@ int main_det(int argc, char **argv) { exit(1); } std::vector>> boxes; + std::vector det_times; - det.Run(srcimg, boxes); - - auto end = std::chrono::system_clock::now(); - auto duration = - std::chrono::duration_cast(end - start); - std::cout << "Cost " - << double(duration.count()) * - std::chrono::microseconds::period::num / - std::chrono::microseconds::period::den - << "s" << std::endl; + det.Run(srcimg, boxes, &det_times); + + time_info[0] += det_times[0]; + time_info[1] += det_times[1]; + time_info[2] += det_times[2]; } + if (FLAGS_benchmark) { + AutoLogger autolog("ocr_det", + FLAGS_use_gpu, + FLAGS_use_tensorrt, + FLAGS_enable_mkldnn, + FLAGS_cpu_threads, + 1, + "dynamic", + FLAGS_precision, + time_info, + cv_all_img_names.size()); + autolog.report(); + } return 0; } -int main_rec(int argc, char **argv) { - // Parsing command-line - google::ParseCommandLineFlags(&argc, &argv, true); - if (FLAGS_rec_model_dir.empty() || FLAGS_image_dir.empty()) { - std::cout << "Usage[rec]: ./ppocr --rec_model_dir=/PATH/TO/REC_INFERENCE_MODEL/ " - << "--image_dir=/PATH/TO/INPUT/IMAGE/" << std::endl; - exit(1); - } - if (!PathExists(FLAGS_image_dir)) { - std::cerr << "[ERROR] image path not exist! image_dir: " << FLAGS_image_dir << endl; - exit(1); - } - - std::vector cv_all_img_names; - cv::glob(FLAGS_image_dir, cv_all_img_names); - std::cout << "total images num: " << cv_all_img_names.size() << endl; - +int main_rec(std::vector cv_all_img_names) { + std::vector time_info = {0, 0, 0}; CRNNRecognizer rec(FLAGS_rec_model_dir, FLAGS_use_gpu, FLAGS_gpu_id, - FLAGS_gpu_mem, FLAGS_cpu_math_library_num_threads, - FLAGS_use_mkldnn, FLAGS_char_list_file, - FLAGS_use_tensorrt, FLAGS_use_fp16); - - auto start = std::chrono::system_clock::now(); + FLAGS_gpu_mem, FLAGS_cpu_threads, + FLAGS_enable_mkldnn, FLAGS_char_list_file, + FLAGS_use_tensorrt, FLAGS_precision); for (int i = 0; i < cv_all_img_names.size(); ++i) { LOG(INFO) << "The predict img: " << cv_all_img_names[i]; @@ -217,65 +141,38 @@ int main_rec(int argc, char **argv) { exit(1); } - rec.Run(srcimg); + std::vector rec_times; + rec.Run(srcimg, &rec_times); - auto end = std::chrono::system_clock::now(); - auto duration = - std::chrono::duration_cast(end - start); - std::cout << "Cost " - << double(duration.count()) * - std::chrono::microseconds::period::num / - std::chrono::microseconds::period::den - << "s" << std::endl; + time_info[0] += rec_times[0]; + time_info[1] += rec_times[1]; + time_info[2] += rec_times[2]; } return 0; } -int main_system(int argc, char **argv) { - // Parsing command-line - google::ParseCommandLineFlags(&argc, &argv, true); - if ((FLAGS_det_model_dir.empty() || FLAGS_rec_model_dir.empty() || FLAGS_image_dir.empty()) || - (FLAGS_use_angle_cls && FLAGS_cls_model_dir.empty())) { - std::cout << "Usage[system without angle cls]: ./ppocr --det_model_dir=/PATH/TO/DET_INFERENCE_MODEL/ " - << "--rec_model_dir=/PATH/TO/REC_INFERENCE_MODEL/ " - << "--image_dir=/PATH/TO/INPUT/IMAGE/" << std::endl; - std::cout << "Usage[system with angle cls]: ./ppocr --det_model_dir=/PATH/TO/DET_INFERENCE_MODEL/ " - << "--use_angle_cls=true " - << "--cls_model_dir=/PATH/TO/CLS_INFERENCE_MODEL/ " - << "--rec_model_dir=/PATH/TO/REC_INFERENCE_MODEL/ " - << "--image_dir=/PATH/TO/INPUT/IMAGE/" << std::endl; - exit(1); - } - if (!PathExists(FLAGS_image_dir)) { - std::cerr << "[ERROR] image path not exist! image_dir: " << FLAGS_image_dir << endl; - exit(1); - } - - std::vector cv_all_img_names; - cv::glob(FLAGS_image_dir, cv_all_img_names); - std::cout << "total images num: " << cv_all_img_names.size() << endl; - +int main_system(std::vector cv_all_img_names) { DBDetector det(FLAGS_det_model_dir, FLAGS_use_gpu, FLAGS_gpu_id, - FLAGS_gpu_mem, FLAGS_cpu_math_library_num_threads, - FLAGS_use_mkldnn, FLAGS_max_side_len, FLAGS_det_db_thresh, + FLAGS_gpu_mem, FLAGS_cpu_threads, + FLAGS_enable_mkldnn, FLAGS_max_side_len, FLAGS_det_db_thresh, FLAGS_det_db_box_thresh, FLAGS_det_db_unclip_ratio, FLAGS_use_polygon_score, FLAGS_visualize, - FLAGS_use_tensorrt, FLAGS_use_fp16); + FLAGS_use_tensorrt, FLAGS_precision); Classifier *cls = nullptr; if (FLAGS_use_angle_cls) { cls = new Classifier(FLAGS_cls_model_dir, FLAGS_use_gpu, FLAGS_gpu_id, - FLAGS_gpu_mem, FLAGS_cpu_math_library_num_threads, - FLAGS_use_mkldnn, FLAGS_cls_thresh, - FLAGS_use_tensorrt, FLAGS_use_fp16); + FLAGS_gpu_mem, FLAGS_cpu_threads, + FLAGS_enable_mkldnn, FLAGS_cls_thresh, + FLAGS_use_tensorrt, FLAGS_precision); } CRNNRecognizer rec(FLAGS_rec_model_dir, FLAGS_use_gpu, FLAGS_gpu_id, - FLAGS_gpu_mem, FLAGS_cpu_math_library_num_threads, - FLAGS_use_mkldnn, FLAGS_char_list_file, - FLAGS_use_tensorrt, FLAGS_use_fp16); + FLAGS_gpu_mem, FLAGS_cpu_threads, + FLAGS_enable_mkldnn, FLAGS_char_list_file, + FLAGS_use_tensorrt, FLAGS_precision); auto start = std::chrono::system_clock::now(); @@ -288,17 +185,19 @@ int main_system(int argc, char **argv) { exit(1); } std::vector>> boxes; - - det.Run(srcimg, boxes); + std::vector det_times; + std::vector rec_times; + + det.Run(srcimg, boxes, &det_times); cv::Mat crop_img; for (int j = 0; j < boxes.size(); j++) { - crop_img = GetRotateCropImage(srcimg, boxes[j]); + crop_img = Utility::GetRotateCropImage(srcimg, boxes[j]); if (cls != nullptr) { crop_img = cls->Run(crop_img); } - rec.Run(crop_img); + rec.Run(crop_img, &rec_times); } auto end = std::chrono::system_clock::now(); @@ -315,22 +214,70 @@ int main_system(int argc, char **argv) { } +void check_params(char* mode) { + if (strcmp(mode, "det")==0) { + if (FLAGS_det_model_dir.empty() || FLAGS_image_dir.empty()) { + std::cout << "Usage[det]: ./ppocr --det_model_dir=/PATH/TO/DET_INFERENCE_MODEL/ " + << "--image_dir=/PATH/TO/INPUT/IMAGE/" << std::endl; + exit(1); + } + } + if (strcmp(mode, "rec")==0) { + if (FLAGS_rec_model_dir.empty() || FLAGS_image_dir.empty()) { + std::cout << "Usage[rec]: ./ppocr --rec_model_dir=/PATH/TO/REC_INFERENCE_MODEL/ " + << "--image_dir=/PATH/TO/INPUT/IMAGE/" << std::endl; + exit(1); + } + } + if (strcmp(mode, "system")==0) { + if ((FLAGS_det_model_dir.empty() || FLAGS_rec_model_dir.empty() || FLAGS_image_dir.empty()) || + (FLAGS_use_angle_cls && FLAGS_cls_model_dir.empty())) { + std::cout << "Usage[system without angle cls]: ./ppocr --det_model_dir=/PATH/TO/DET_INFERENCE_MODEL/ " + << "--rec_model_dir=/PATH/TO/REC_INFERENCE_MODEL/ " + << "--image_dir=/PATH/TO/INPUT/IMAGE/" << std::endl; + std::cout << "Usage[system with angle cls]: ./ppocr --det_model_dir=/PATH/TO/DET_INFERENCE_MODEL/ " + << "--use_angle_cls=true " + << "--cls_model_dir=/PATH/TO/CLS_INFERENCE_MODEL/ " + << "--rec_model_dir=/PATH/TO/REC_INFERENCE_MODEL/ " + << "--image_dir=/PATH/TO/INPUT/IMAGE/" << std::endl; + exit(1); + } + } + if (FLAGS_precision != "fp32" && FLAGS_precision != "fp16" && FLAGS_precision != "int8") { + cout << "precison should be 'fp32'(default), 'fp16' or 'int8'. " << endl; + exit(1); + } +} + + int main(int argc, char **argv) { - if (strcmp(argv[1], "det")!=0 && strcmp(argv[1], "rec")!=0 && strcmp(argv[1], "system")!=0) { - std::cout << "Please choose one mode of [det, rec, system] !" << std::endl; - return -1; - } - std::cout << "mode: " << argv[1] << endl; - - if (strcmp(argv[1], "det")==0) { - return main_det(argc, argv); - } - if (strcmp(argv[1], "rec")==0) { - return main_rec(argc, argv); - } - if (strcmp(argv[1], "system")==0) { - return main_system(argc, argv); - } + if (argc<=1 || (strcmp(argv[1], "det")!=0 && strcmp(argv[1], "rec")!=0 && strcmp(argv[1], "system")!=0)) { + std::cout << "Please choose one mode of [det, rec, system] !" << std::endl; + return -1; + } + std::cout << "mode: " << argv[1] << endl; + + // Parsing command-line + google::ParseCommandLineFlags(&argc, &argv, true); + check_params(argv[1]); + + if (!PathExists(FLAGS_image_dir)) { + std::cerr << "[ERROR] image path not exist! image_dir: " << FLAGS_image_dir << endl; + exit(1); + } -// return 0; + std::vector cv_all_img_names; + cv::glob(FLAGS_image_dir, cv_all_img_names); + std::cout << "total images num: " << cv_all_img_names.size() << endl; + + if (strcmp(argv[1], "det")==0) { + return main_det(cv_all_img_names); + } + if (strcmp(argv[1], "rec")==0) { + return main_rec(cv_all_img_names); + } + if (strcmp(argv[1], "system")==0) { + return main_system(cv_all_img_names); + } + } diff --git a/deploy/cpp_infer/src/ocr_cls.cpp b/deploy/cpp_infer/src/ocr_cls.cpp index 9199e082e5df42b0c9c42e668d2df37acf4521c4..3b04b6f8248bb17b9e315ae8b777530840015394 100644 --- a/deploy/cpp_infer/src/ocr_cls.cpp +++ b/deploy/cpp_infer/src/ocr_cls.cpp @@ -77,10 +77,16 @@ void Classifier::LoadModel(const std::string &model_dir) { if (this->use_gpu_) { config.EnableUseGpu(this->gpu_mem_, this->gpu_id_); if (this->use_tensorrt_) { + auto precision = paddle_infer::Config::Precision::kFloat32; + if (this->precision_ == "fp16") { + precision = paddle_infer::Config::Precision::kHalf; + } + if (this->precision_ == "int8") { + precision = paddle_infer::Config::Precision::kInt8; + } config.EnableTensorRtEngine( 1 << 20, 10, 3, - this->use_fp16_ ? paddle_infer::Config::Precision::kHalf - : paddle_infer::Config::Precision::kFloat32, + precision, false, false); } } else { diff --git a/deploy/cpp_infer/src/ocr_det.cpp b/deploy/cpp_infer/src/ocr_det.cpp index 58dc4dce8117f81b17e3c88ea02404d474ea9248..a69f5ca1bd3ee7665f8b2f5610c67dd6feb7eb54 100644 --- a/deploy/cpp_infer/src/ocr_det.cpp +++ b/deploy/cpp_infer/src/ocr_det.cpp @@ -26,10 +26,16 @@ void DBDetector::LoadModel(const std::string &model_dir) { if (this->use_gpu_) { config.EnableUseGpu(this->gpu_mem_, this->gpu_id_); if (this->use_tensorrt_) { + auto precision = paddle_infer::Config::Precision::kFloat32; + if (this->precision_ == "fp16") { + precision = paddle_infer::Config::Precision::kHalf; + } + if (this->precision_ == "int8") { + precision = paddle_infer::Config::Precision::kInt8; + } config.EnableTensorRtEngine( 1 << 20, 10, 3, - this->use_fp16_ ? paddle_infer::Config::Precision::kHalf - : paddle_infer::Config::Precision::kFloat32, + precision, false, false); std::map> min_input_shape = { {"x", {1, 3, 50, 50}}, @@ -91,13 +97,16 @@ void DBDetector::LoadModel(const std::string &model_dir) { } void DBDetector::Run(cv::Mat &img, - std::vector>> &boxes) { + std::vector>> &boxes, + std::vector *times) { float ratio_h{}; float ratio_w{}; cv::Mat srcimg; cv::Mat resize_img; img.copyTo(srcimg); + + auto preprocess_start = std::chrono::steady_clock::now(); this->resize_op_.Run(img, resize_img, this->max_side_len_, ratio_h, ratio_w, this->use_tensorrt_); @@ -106,14 +115,17 @@ void DBDetector::Run(cv::Mat &img, std::vector input(1 * 3 * resize_img.rows * resize_img.cols, 0.0f); this->permute_op_.Run(&resize_img, input.data()); - + auto preprocess_end = std::chrono::steady_clock::now(); + // Inference. auto input_names = this->predictor_->GetInputNames(); auto input_t = this->predictor_->GetInputHandle(input_names[0]); input_t->Reshape({1, 3, resize_img.rows, resize_img.cols}); + auto inference_start = std::chrono::steady_clock::now(); input_t->CopyFromCpu(input.data()); + this->predictor_->Run(); - + std::vector out_data; auto output_names = this->predictor_->GetOutputNames(); auto output_t = this->predictor_->GetOutputHandle(output_names[0]); @@ -123,7 +135,9 @@ void DBDetector::Run(cv::Mat &img, out_data.resize(out_num); output_t->CopyToCpu(out_data.data()); - + auto inference_end = std::chrono::steady_clock::now(); + + auto postprocess_start = std::chrono::steady_clock::now(); int n2 = output_shape[2]; int n3 = output_shape[3]; int n = n2 * n3; @@ -151,7 +165,15 @@ void DBDetector::Run(cv::Mat &img, this->det_db_unclip_ratio_, this->use_polygon_score_); boxes = post_processor_.FilterTagDetRes(boxes, ratio_h, ratio_w, srcimg); + auto postprocess_end = std::chrono::steady_clock::now(); std::cout << "Detected boxes num: " << boxes.size() << endl; + + std::chrono::duration preprocess_diff = preprocess_end - preprocess_start; + times->push_back(double(preprocess_diff.count() * 1000)); + std::chrono::duration inference_diff = inference_end - inference_start; + times->push_back(double(inference_diff.count() * 1000)); + std::chrono::duration postprocess_diff = postprocess_end - postprocess_start; + times->push_back(double(postprocess_diff.count() * 1000)); //// visualization if (this->visualize_) { diff --git a/deploy/cpp_infer/src/ocr_rec.cpp b/deploy/cpp_infer/src/ocr_rec.cpp index c4a784f82c789f3ebdc826ccb1d37631c8204368..b64dcea5ae2a68485296c02cdb7689c60ea504f8 100644 --- a/deploy/cpp_infer/src/ocr_rec.cpp +++ b/deploy/cpp_infer/src/ocr_rec.cpp @@ -16,13 +16,13 @@ namespace PaddleOCR { -void CRNNRecognizer::Run(cv::Mat &img) { +void CRNNRecognizer::Run(cv::Mat &img, std::vector *times) { cv::Mat srcimg; img.copyTo(srcimg); cv::Mat resize_img; float wh_ratio = float(srcimg.cols) / float(srcimg.rows); - + auto preprocess_start = std::chrono::steady_clock::now(); this->resize_op_.Run(srcimg, resize_img, wh_ratio, this->use_tensorrt_); this->normalize_op_.Run(&resize_img, this->mean_, this->scale_, @@ -31,11 +31,13 @@ void CRNNRecognizer::Run(cv::Mat &img) { std::vector input(1 * 3 * resize_img.rows * resize_img.cols, 0.0f); this->permute_op_.Run(&resize_img, input.data()); + auto preprocess_end = std::chrono::steady_clock::now(); // Inference. auto input_names = this->predictor_->GetInputNames(); auto input_t = this->predictor_->GetInputHandle(input_names[0]); input_t->Reshape({1, 3, resize_img.rows, resize_img.cols}); + auto inference_start = std::chrono::steady_clock::now(); input_t->CopyFromCpu(input.data()); this->predictor_->Run(); @@ -49,8 +51,10 @@ void CRNNRecognizer::Run(cv::Mat &img) { predict_batch.resize(out_num); output_t->CopyToCpu(predict_batch.data()); + auto inference_end = std::chrono::steady_clock::now(); // ctc decode + auto postprocess_start = std::chrono::steady_clock::now(); std::vector str_res; int argmax_idx; int last_index = 0; @@ -73,11 +77,19 @@ void CRNNRecognizer::Run(cv::Mat &img) { } last_index = argmax_idx; } + auto postprocess_end = std::chrono::steady_clock::now(); score /= count; for (int i = 0; i < str_res.size(); i++) { std::cout << str_res[i]; } std::cout << "\tscore: " << score << std::endl; + + std::chrono::duration preprocess_diff = preprocess_end - preprocess_start; + times->push_back(double(preprocess_diff.count() * 1000)); + std::chrono::duration inference_diff = inference_end - inference_start; + times->push_back(double(inference_diff.count() * 1000)); + std::chrono::duration postprocess_diff = postprocess_end - postprocess_start; + times->push_back(double(postprocess_diff.count() * 1000)); } void CRNNRecognizer::LoadModel(const std::string &model_dir) { @@ -89,10 +101,16 @@ void CRNNRecognizer::LoadModel(const std::string &model_dir) { if (this->use_gpu_) { config.EnableUseGpu(this->gpu_mem_, this->gpu_id_); if (this->use_tensorrt_) { + auto precision = paddle_infer::Config::Precision::kFloat32; + if (this->precision_ == "fp16") { + precision = paddle_infer::Config::Precision::kHalf; + } + if (this->precision_ == "int8") { + precision = paddle_infer::Config::Precision::kInt8; + } config.EnableTensorRtEngine( 1 << 20, 10, 3, - this->use_fp16_ ? paddle_infer::Config::Precision::kHalf - : paddle_infer::Config::Precision::kFloat32, + precision, false, false); std::map> min_input_shape = { {"x", {1, 3, 32, 10}}}; @@ -126,59 +144,4 @@ void CRNNRecognizer::LoadModel(const std::string &model_dir) { this->predictor_ = CreatePredictor(config); } -cv::Mat CRNNRecognizer::GetRotateCropImage(const cv::Mat &srcimage, - std::vector> box) { - cv::Mat image; - srcimage.copyTo(image); - std::vector> points = box; - - int x_collect[4] = {box[0][0], box[1][0], box[2][0], box[3][0]}; - int y_collect[4] = {box[0][1], box[1][1], box[2][1], box[3][1]}; - int left = int(*std::min_element(x_collect, x_collect + 4)); - int right = int(*std::max_element(x_collect, x_collect + 4)); - int top = int(*std::min_element(y_collect, y_collect + 4)); - int bottom = int(*std::max_element(y_collect, y_collect + 4)); - - cv::Mat img_crop; - image(cv::Rect(left, top, right - left, bottom - top)).copyTo(img_crop); - - for (int i = 0; i < points.size(); i++) { - points[i][0] -= left; - points[i][1] -= top; - } - - int img_crop_width = int(sqrt(pow(points[0][0] - points[1][0], 2) + - pow(points[0][1] - points[1][1], 2))); - int img_crop_height = int(sqrt(pow(points[0][0] - points[3][0], 2) + - pow(points[0][1] - points[3][1], 2))); - - cv::Point2f pts_std[4]; - pts_std[0] = cv::Point2f(0., 0.); - pts_std[1] = cv::Point2f(img_crop_width, 0.); - pts_std[2] = cv::Point2f(img_crop_width, img_crop_height); - pts_std[3] = cv::Point2f(0.f, img_crop_height); - - cv::Point2f pointsf[4]; - pointsf[0] = cv::Point2f(points[0][0], points[0][1]); - pointsf[1] = cv::Point2f(points[1][0], points[1][1]); - pointsf[2] = cv::Point2f(points[2][0], points[2][1]); - pointsf[3] = cv::Point2f(points[3][0], points[3][1]); - - cv::Mat M = cv::getPerspectiveTransform(pointsf, pts_std); - - cv::Mat dst_img; - cv::warpPerspective(img_crop, dst_img, M, - cv::Size(img_crop_width, img_crop_height), - cv::BORDER_REPLICATE); - - if (float(dst_img.rows) >= float(dst_img.cols) * 1.5) { - cv::Mat srcCopy = cv::Mat(dst_img.rows, dst_img.cols, dst_img.depth()); - cv::transpose(dst_img, srcCopy); - cv::flip(srcCopy, srcCopy, 0); - return srcCopy; - } else { - return dst_img; - } -} - } // namespace PaddleOCR diff --git a/deploy/cpp_infer/src/utility.cpp b/deploy/cpp_infer/src/utility.cpp index 2cd84f7e8dbdd8144b5337f55b3f3a62ed43d5b3..dba445b747ff3f3c0d2db91061650c369977c4dd 100644 --- a/deploy/cpp_infer/src/utility.cpp +++ b/deploy/cpp_infer/src/utility.cpp @@ -92,4 +92,59 @@ void Utility::GetAllFiles(const char *dir_name, } } +cv::Mat Utility::GetRotateCropImage(const cv::Mat &srcimage, + std::vector> box) { + cv::Mat image; + srcimage.copyTo(image); + std::vector> points = box; + + int x_collect[4] = {box[0][0], box[1][0], box[2][0], box[3][0]}; + int y_collect[4] = {box[0][1], box[1][1], box[2][1], box[3][1]}; + int left = int(*std::min_element(x_collect, x_collect + 4)); + int right = int(*std::max_element(x_collect, x_collect + 4)); + int top = int(*std::min_element(y_collect, y_collect + 4)); + int bottom = int(*std::max_element(y_collect, y_collect + 4)); + + cv::Mat img_crop; + image(cv::Rect(left, top, right - left, bottom - top)).copyTo(img_crop); + + for (int i = 0; i < points.size(); i++) { + points[i][0] -= left; + points[i][1] -= top; + } + + int img_crop_width = int(sqrt(pow(points[0][0] - points[1][0], 2) + + pow(points[0][1] - points[1][1], 2))); + int img_crop_height = int(sqrt(pow(points[0][0] - points[3][0], 2) + + pow(points[0][1] - points[3][1], 2))); + + cv::Point2f pts_std[4]; + pts_std[0] = cv::Point2f(0., 0.); + pts_std[1] = cv::Point2f(img_crop_width, 0.); + pts_std[2] = cv::Point2f(img_crop_width, img_crop_height); + pts_std[3] = cv::Point2f(0.f, img_crop_height); + + cv::Point2f pointsf[4]; + pointsf[0] = cv::Point2f(points[0][0], points[0][1]); + pointsf[1] = cv::Point2f(points[1][0], points[1][1]); + pointsf[2] = cv::Point2f(points[2][0], points[2][1]); + pointsf[3] = cv::Point2f(points[3][0], points[3][1]); + + cv::Mat M = cv::getPerspectiveTransform(pointsf, pts_std); + + cv::Mat dst_img; + cv::warpPerspective(img_crop, dst_img, M, + cv::Size(img_crop_width, img_crop_height), + cv::BORDER_REPLICATE); + + if (float(dst_img.rows) >= float(dst_img.cols) * 1.5) { + cv::Mat srcCopy = cv::Mat(dst_img.rows, dst_img.cols, dst_img.depth()); + cv::transpose(dst_img, srcCopy); + cv::flip(srcCopy, srcCopy, 0); + return srcCopy; + } else { + return dst_img; + } +} + } // namespace PaddleOCR \ No newline at end of file diff --git a/deploy/slim/prune/sensitivity_anal.py b/deploy/slim/prune/sensitivity_anal.py index bd2b96497221fd886c83b9401cc8ed2a1a201a50..f80ddd9fb424a4b0c8f30304530d7d20f982598a 100644 --- a/deploy/slim/prune/sensitivity_anal.py +++ b/deploy/slim/prune/sensitivity_anal.py @@ -75,7 +75,7 @@ def main(config, device, logger, vdl_writer): model = build_model(config['Architecture']) flops = paddle.flops(model, [1, 3, 640, 640]) - logger.info(f"FLOPs before pruning: {flops}") + logger.info("FLOPs before pruning: {}".format(flops)) from paddleslim.dygraph import FPGMFilterPruner model.train() @@ -106,8 +106,8 @@ def main(config, device, logger, vdl_writer): def eval_fn(): metric = program.eval(model, valid_dataloader, post_process_class, - eval_class) - logger.info(f"metric['hmean']: {metric['hmean']}") + eval_class, False) + logger.info("metric['hmean']: {}".format(metric['hmean'])) return metric['hmean'] params_sensitive = pruner.sensitive( @@ -123,16 +123,17 @@ def main(config, device, logger, vdl_writer): # calculate pruned params's ratio params_sensitive = pruner._get_ratios_by_loss(params_sensitive, loss=0.02) for key in params_sensitive.keys(): - logger.info(f"{key}, {params_sensitive[key]}") + logger.info("{}, {}".format(key, params_sensitive[key])) + + #params_sensitive = {} + #for param in model.parameters(): + # if 'transpose' not in param.name and 'linear' not in param.name: + # params_sensitive[param.name] = 0.1 plan = pruner.prune_vars(params_sensitive, [0]) - for param in model.parameters(): - if ("weights" in param.name and "conv" in param.name) or ( - "w_0" in param.name and "conv2d" in param.name): - logger.info(f"{param.name}: {param.shape}") flops = paddle.flops(model, [1, 3, 640, 640]) - logger.info(f"FLOPs after pruning: {flops}") + logger.info("FLOPs after pruning: {}".format(flops)) # start train diff --git a/doc/doc_ch/algorithm_overview.md b/doc/doc_ch/algorithm_overview.md index 19d7a69c7fb08a8e7fb36c3043aa211de19b9295..e8f23b54e50be7ac2f5388a726ed6540d2c159c3 100755 --- a/doc/doc_ch/algorithm_overview.md +++ b/doc/doc_ch/algorithm_overview.md @@ -44,6 +44,7 @@ PaddleOCR基于动态图开源的文本识别算法列表: - [x] STAR-Net([paper](http://www.bmva.org/bmvc/2016/papers/paper043/index.html))[11] - [x] RARE([paper](https://arxiv.org/abs/1603.03915v1))[12] - [x] SRN([paper](https://arxiv.org/abs/2003.12294))[5] +- [x] NRTR([paper](https://arxiv.org/abs/1806.00926v2)) 参考[DTRB][3](https://arxiv.org/abs/1904.01906)文字识别训练和评估流程,使用MJSynth和SynthText两个文字识别数据集训练,在IIIT, SVT, IC03, IC13, IC15, SVTP, CUTE数据集上进行评估,算法效果如下: @@ -58,6 +59,7 @@ PaddleOCR基于动态图开源的文本识别算法列表: |RARE|MobileNetV3|82.5%|rec_mv3_tps_bilstm_att |[下载链接](https://paddleocr.bj.bcebos.com/dygraph_v2.0/en/rec_mv3_tps_bilstm_att_v2.0_train.tar)| |RARE|Resnet34_vd|83.6%|rec_r34_vd_tps_bilstm_att |[下载链接](https://paddleocr.bj.bcebos.com/dygraph_v2.0/en/rec_r34_vd_tps_bilstm_att_v2.0_train.tar)| |SRN|Resnet50_vd_fpn| 88.52% | rec_r50fpn_vd_none_srn | [下载链接](https://paddleocr.bj.bcebos.com/dygraph_v2.0/en/rec_r50_vd_srn_train.tar) | +|NRTR|NRTR_MTB| 84.3% | rec_mtb_nrtr | [下载链接](https://paddleocr.bj.bcebos.com/dygraph_v2.0/en/rec_mtb_nrtr_train.tar) | PaddleOCR文本识别算法的训练和使用请参考文档教程中[模型训练/评估中的文本识别部分](./recognition.md)。 diff --git a/doc/doc_ch/recognition.md b/doc/doc_ch/recognition.md index 0ff0513a2b9a3e5e732e78bd8b4f42ab9f79094f..9d5bf2861ba2e700975cdb5584efcf6a8ab26801 100644 --- a/doc/doc_ch/recognition.md +++ b/doc/doc_ch/recognition.md @@ -185,11 +185,11 @@ python3 -m paddle.distributed.launch --gpus '0,1,2,3' tools/train.py -c configs #### 2.1 数据增强 -PaddleOCR提供了多种数据增强方式,如果您希望在训练时加入扰动,请在配置文件中设置 `distort: true`。 +PaddleOCR提供了多种数据增强方式,默认配置文件中已经添加了数据增广。 -默认的扰动方式有:颜色空间转换(cvtColor)、模糊(blur)、抖动(jitter)、噪声(Gasuss noise)、随机切割(random crop)、透视(perspective)、颜色反转(reverse)。 +默认的扰动方式有:颜色空间转换(cvtColor)、模糊(blur)、抖动(jitter)、噪声(Gasuss noise)、随机切割(random crop)、透视(perspective)、颜色反转(reverse)、TIA数据增广。 -训练过程中每种扰动方式以50%的概率被选择,具体代码实现请参考:[img_tools.py](https://github.com/PaddlePaddle/PaddleOCR/blob/develop/ppocr/data/rec/img_tools.py) +训练过程中每种扰动方式以40%的概率被选择,具体代码实现请参考:[rec_img_aug.py](../../ppocr/data/imaug/rec_img_aug.py) *由于OpenCV的兼容性问题,扰动操作暂时只支持Linux* @@ -215,6 +215,7 @@ PaddleOCR支持训练和评估交替进行, 可以在 `configs/rec/rec_icdar15_t | rec_mv3_tps_bilstm_att.yml | CRNN | Mobilenet_v3 | TPS | BiLSTM | att | | rec_r34_vd_tps_bilstm_att.yml | CRNN | Resnet34_vd | TPS | BiLSTM | att | | rec_r50fpn_vd_none_srn.yml | SRN | Resnet50_fpn_vd | None | rnn | srn | +| rec_mtb_nrtr.yml | NRTR | nrtr_mtb | None | transformer encoder | transformer decoder | 训练中文数据,推荐使用[rec_chinese_lite_train_v2.0.yml](../../configs/rec/ch_ppocr_v2.0/rec_chinese_lite_train_v2.0.yml),如您希望尝试其他算法在中文数据集上的效果,请参考下列说明修改配置文件: diff --git a/doc/doc_en/algorithm_overview_en.md b/doc/doc_en/algorithm_overview_en.md index d70f99bb5c5b0bdcb7d39209dfc9a77c56918260..8e8f0d3f8c36885515ea65f17e910c31838bc603 100755 --- a/doc/doc_en/algorithm_overview_en.md +++ b/doc/doc_en/algorithm_overview_en.md @@ -46,6 +46,7 @@ PaddleOCR open-source text recognition algorithms list: - [x] STAR-Net([paper](http://www.bmva.org/bmvc/2016/papers/paper043/index.html))[11] - [x] RARE([paper](https://arxiv.org/abs/1603.03915v1))[12] - [x] SRN([paper](https://arxiv.org/abs/2003.12294))[5] +- [x] NRTR([paper](https://arxiv.org/abs/1806.00926v2)) Refer to [DTRB](https://arxiv.org/abs/1904.01906), the training and evaluation result of these above text recognition (using MJSynth and SynthText for training, evaluate on IIIT, SVT, IC03, IC13, IC15, SVTP, CUTE) is as follow: @@ -60,5 +61,6 @@ Refer to [DTRB](https://arxiv.org/abs/1904.01906), the training and evaluation r |RARE|MobileNetV3|82.5%|rec_mv3_tps_bilstm_att |[Download link](https://paddleocr.bj.bcebos.com/dygraph_v2.0/en/rec_mv3_tps_bilstm_att_v2.0_train.tar)| |RARE|Resnet34_vd|83.6%|rec_r34_vd_tps_bilstm_att |[Download link](https://paddleocr.bj.bcebos.com/dygraph_v2.0/en/rec_r34_vd_tps_bilstm_att_v2.0_train.tar)| |SRN|Resnet50_vd_fpn| 88.52% | rec_r50fpn_vd_none_srn |[Download link](https://paddleocr.bj.bcebos.com/dygraph_v2.0/en/rec_r50_vd_srn_train.tar)| +|NRTR|NRTR_MTB| 84.3% | rec_mtb_nrtr | [Download link](https://paddleocr.bj.bcebos.com/dygraph_v2.0/en/rec_mtb_nrtr_train.tar) | Please refer to the document for training guide and use of PaddleOCR text recognition algorithms [Text recognition model training/evaluation/prediction](./recognition_en.md) diff --git a/doc/doc_en/recognition_en.md b/doc/doc_en/recognition_en.md index 634ec783aa5e1dd6c9202385cf2978d140ca44a1..ff5b802d8dbf54e842c035bce9ed480428eade83 100644 --- a/doc/doc_en/recognition_en.md +++ b/doc/doc_en/recognition_en.md @@ -177,11 +177,11 @@ python3 -m paddle.distributed.launch --gpus '0,1,2,3' tools/train.py -c configs #### 2.1 Data Augmentation -PaddleOCR provides a variety of data augmentation methods. If you want to add disturbance during training, please set `distort: true` in the configuration file. +PaddleOCR provides a variety of data augmentation methods. All the augmentation methods are enabled by default. -The default perturbation methods are: cvtColor, blur, jitter, Gasuss noise, random crop, perspective, color reverse. +The default perturbation methods are: cvtColor, blur, jitter, Gasuss noise, random crop, perspective, color reverse, TIA augmentation. -Each disturbance method is selected with a 50% probability during the training process. For specific code implementation, please refer to: [img_tools.py](https://github.com/PaddlePaddle/PaddleOCR/blob/develop/ppocr/data/rec/img_tools.py) +Each disturbance method is selected with a 40% probability during the training process. For specific code implementation, please refer to: [rec_img_aug.py](../../ppocr/data/imaug/rec_img_aug.py) #### 2.2 Training @@ -207,7 +207,7 @@ If the evaluation set is large, the test will be time-consuming. It is recommend | rec_mv3_tps_bilstm_att.yml | CRNN | Mobilenet_v3 | TPS | BiLSTM | att | | rec_r34_vd_tps_bilstm_att.yml | CRNN | Resnet34_vd | TPS | BiLSTM | att | | rec_r50fpn_vd_none_srn.yml | SRN | Resnet50_fpn_vd | None | rnn | srn | - +| rec_mtb_nrtr.yml | NRTR | nrtr_mtb | None | transformer encoder | transformer decoder | For training Chinese data, it is recommended to use [rec_chinese_lite_train_v2.0.yml](../../configs/rec/ch_ppocr_v2.0/rec_chinese_lite_train_v2.0.yml). If you want to try the result of other algorithms on the Chinese data set, please refer to the following instructions to modify the configuration file: diff --git a/doc/joinus.PNG b/doc/joinus.PNG index 1228ce0a4ddd549b9ddfe00090675d9bd7e3cb6b..3be14c603e8fa8c09ac1340fc662ba14ec045f38 100644 Binary files a/doc/joinus.PNG and b/doc/joinus.PNG differ diff --git a/doc/table/1.png b/doc/table/1.png index 47df618ab1bef431a5dd94418c01be16b09d31aa..faff6e3178662407961fe074a9202015f755e2f8 100644 Binary files a/doc/table/1.png and b/doc/table/1.png differ diff --git a/doc/table/table.jpg b/doc/table/table.jpg index 3daa619e52dc2471df62ea7767be3bff350b623f..95fdf84d92908d4b21f49fb516601334867163b1 100644 Binary files a/doc/table/table.jpg and b/doc/table/table.jpg differ diff --git a/paddleocr.py b/paddleocr.py index c52737f55b61cd29c08367adb6d7e05c561e933e..45c1a40dbbe3ad5cba88cadf0ced85717c7a23da 100644 --- a/paddleocr.py +++ b/paddleocr.py @@ -127,7 +127,7 @@ model_urls = { } SUPPORT_DET_MODEL = ['DB'] -VERSION = '2.2' +VERSION = '2.2.0.1' SUPPORT_REC_MODEL = ['CRNN'] BASE_DIR = os.path.expanduser("~/.paddleocr/") diff --git a/ppocr/data/__init__.py b/ppocr/data/__init__.py index e860c5a6986f495e6384d9df93c24795c04a0d5f..0bb3d506483a331fba48feafeff9ca2d439f3782 100644 --- a/ppocr/data/__init__.py +++ b/ppocr/data/__init__.py @@ -49,14 +49,12 @@ def term_mp(sig_num, frame): os.killpg(pgid, signal.SIGKILL) -signal.signal(signal.SIGINT, term_mp) -signal.signal(signal.SIGTERM, term_mp) - - def build_dataloader(config, mode, device, logger, seed=None): config = copy.deepcopy(config) - support_dict = ['SimpleDataSet', 'LMDBDataSet', 'PGDataSet', 'PubTabDataSet'] + support_dict = [ + 'SimpleDataSet', 'LMDBDataSet', 'PGDataSet', 'PubTabDataSet' + ] module_name = config[mode]['dataset']['name'] assert module_name in support_dict, Exception( 'DataSet only support {}'.format(support_dict)) @@ -96,4 +94,8 @@ def build_dataloader(config, mode, device, logger, seed=None): return_list=True, use_shared_memory=use_shared_memory) + # support exit using ctrl+c + signal.signal(signal.SIGINT, term_mp) + signal.signal(signal.SIGTERM, term_mp) + return data_loader diff --git a/ppocr/data/imaug/__init__.py b/ppocr/data/imaug/__init__.py index 52194eb964f7a7fd159cc1a42b73d280f8ee5fb4..4418d075cb297880017b4839438aa1cbb9b5ebcd 100644 --- a/ppocr/data/imaug/__init__.py +++ b/ppocr/data/imaug/__init__.py @@ -21,7 +21,7 @@ from .make_border_map import MakeBorderMap from .make_shrink_map import MakeShrinkMap from .random_crop_data import EastRandomCropData, PSERandomCrop -from .rec_img_aug import RecAug, RecResizeImg, ClsResizeImg, SRNRecResizeImg +from .rec_img_aug import RecAug, RecResizeImg, ClsResizeImg, SRNRecResizeImg, NRTRRecResizeImg from .randaugment import RandAugment from .copy_paste import CopyPaste from .operators import * diff --git a/ppocr/data/imaug/label_ops.py b/ppocr/data/imaug/label_ops.py index d222c4109c3723bc1adb71ee7c21a27a010f8f45..f6263950959b0ee6a96647fb248098bb5c567651 100644 --- a/ppocr/data/imaug/label_ops.py +++ b/ppocr/data/imaug/label_ops.py @@ -161,6 +161,34 @@ class BaseRecLabelEncode(object): return text_list +class NRTRLabelEncode(BaseRecLabelEncode): + """ Convert between text-label and text-index """ + + def __init__(self, + max_text_length, + character_dict_path=None, + character_type='EN_symbol', + use_space_char=False, + **kwargs): + + super(NRTRLabelEncode, + self).__init__(max_text_length, character_dict_path, + character_type, use_space_char) + def __call__(self, data): + text = data['label'] + text = self.encode(text) + if text is None: + return None + data['length'] = np.array(len(text)) + text.insert(0, 2) + text.append(3) + text = text + [0] * (self.max_text_len - len(text)) + data['label'] = np.array(text) + return data + def add_special_char(self, dict_character): + dict_character = ['blank','','',''] + dict_character + return dict_character + class CTCLabelEncode(BaseRecLabelEncode): """ Convert between text-label and text-index """ diff --git a/ppocr/data/imaug/operators.py b/ppocr/data/imaug/operators.py index 2535b4420c503f2e9e9cc5a677ef70c4dd9c36be..aa3acd1d1264fb2af75c773efd1e5c575b465fe5 100644 --- a/ppocr/data/imaug/operators.py +++ b/ppocr/data/imaug/operators.py @@ -57,6 +57,38 @@ class DecodeImage(object): return data +class NRTRDecodeImage(object): + """ decode image """ + + def __init__(self, img_mode='RGB', channel_first=False, **kwargs): + 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" + else: + 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) + img = img[:, :, ::-1] + img = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) + 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 """ diff --git a/ppocr/data/imaug/rec_img_aug.py b/ppocr/data/imaug/rec_img_aug.py index 28e6bd0bce768c45dbc334c15ace601fd6403f5d..e914d3844606b5b88333a89e5d0e5fda65729458 100644 --- a/ppocr/data/imaug/rec_img_aug.py +++ b/ppocr/data/imaug/rec_img_aug.py @@ -16,7 +16,7 @@ import math import cv2 import numpy as np import random - +from PIL import Image from .text_image_aug import tia_perspective, tia_stretch, tia_distort @@ -43,6 +43,25 @@ class ClsResizeImg(object): return data +class NRTRRecResizeImg(object): + def __init__(self, image_shape, resize_type, **kwargs): + self.image_shape = image_shape + self.resize_type = resize_type + + def __call__(self, data): + img = data['image'] + if self.resize_type == 'PIL': + image_pil = Image.fromarray(np.uint8(img)) + img = image_pil.resize(self.image_shape, Image.ANTIALIAS) + img = np.array(img) + if self.resize_type == 'OpenCV': + img = cv2.resize(img, self.image_shape) + norm_img = np.expand_dims(img, -1) + norm_img = norm_img.transpose((2, 0, 1)) + data['image'] = norm_img.astype(np.float32) / 128. - 1. + return data + + class RecResizeImg(object): def __init__(self, image_shape, diff --git a/ppocr/losses/__init__.py b/ppocr/losses/__init__.py index 025ae7ca5cc604eea59423ca7f523c37c1492e35..eed5a46efcb94cce5e38101640f7ba50d5c60801 100755 --- a/ppocr/losses/__init__.py +++ b/ppocr/losses/__init__.py @@ -25,7 +25,7 @@ from .det_sast_loss import SASTLoss from .rec_ctc_loss import CTCLoss from .rec_att_loss import AttentionLoss from .rec_srn_loss import SRNLoss - +from .rec_nrtr_loss import NRTRLoss # cls loss from .cls_loss import ClsLoss @@ -44,8 +44,9 @@ from .table_att_loss import TableAttentionLoss def build_loss(config): support_dict = [ 'DBLoss', 'EASTLoss', 'SASTLoss', 'CTCLoss', 'ClsLoss', 'AttentionLoss', - 'SRNLoss', 'PGLoss', 'CombinedLoss', 'TableAttentionLoss' + 'SRNLoss', 'PGLoss', 'CombinedLoss', 'NRTRLoss', 'TableAttentionLoss' ] + config = copy.deepcopy(config) module_name = config.pop('name') assert module_name in support_dict, Exception('loss only support {}'.format( diff --git a/ppocr/losses/cls_loss.py b/ppocr/losses/cls_loss.py index ecca5d2e1739631716123d4a793f5ece09d7f9ab..abc5e5b72cb055716715345105b59089f0a96edc 100755 --- a/ppocr/losses/cls_loss.py +++ b/ppocr/losses/cls_loss.py @@ -25,6 +25,6 @@ class ClsLoss(nn.Layer): self.loss_func = nn.CrossEntropyLoss(reduction='mean') def forward(self, predicts, batch): - label = batch[1] + label = batch[1].astype("int64") loss = self.loss_func(input=predicts, label=label) return {'loss': loss} diff --git a/ppocr/losses/rec_nrtr_loss.py b/ppocr/losses/rec_nrtr_loss.py new file mode 100644 index 0000000000000000000000000000000000000000..41714dd2a3ae15eeedc62521d97935f68271c598 --- /dev/null +++ b/ppocr/losses/rec_nrtr_loss.py @@ -0,0 +1,30 @@ +import paddle +from paddle import nn +import paddle.nn.functional as F + + +class NRTRLoss(nn.Layer): + def __init__(self, smoothing=True, **kwargs): + super(NRTRLoss, self).__init__() + self.loss_func = nn.CrossEntropyLoss(reduction='mean', ignore_index=0) + self.smoothing = smoothing + + def forward(self, pred, batch): + pred = pred.reshape([-1, pred.shape[2]]) + max_len = batch[2].max() + tgt = batch[1][:, 1:2 + max_len] + tgt = tgt.reshape([-1]) + if self.smoothing: + eps = 0.1 + n_class = pred.shape[1] + one_hot = F.one_hot(tgt, pred.shape[1]) + one_hot = one_hot * (1 - eps) + (1 - one_hot) * eps / (n_class - 1) + log_prb = F.log_softmax(pred, axis=1) + non_pad_mask = paddle.not_equal( + tgt, paddle.zeros( + tgt.shape, dtype='int64')) + loss = -(one_hot * log_prb).sum(axis=1) + loss = loss.masked_select(non_pad_mask).mean() + else: + loss = self.loss_func(pred, tgt) + return {'loss': loss} diff --git a/ppocr/metrics/rec_metric.py b/ppocr/metrics/rec_metric.py index 66c084d771dece0e2974bc72a177b53f564a8f2e..3e82fe756b1e42d6a77192af41e27e0fe30a86ab 100644 --- a/ppocr/metrics/rec_metric.py +++ b/ppocr/metrics/rec_metric.py @@ -57,3 +57,4 @@ class RecMetric(object): self.correct_num = 0 self.all_num = 0 self.norm_edit_dis = 0 + diff --git a/ppocr/modeling/architectures/base_model.py b/ppocr/modeling/architectures/base_model.py index dbd18070b36f7e99c62de94048ab53d1bedcebe0..c498d9862abcfc85eaf29ed1d949230a1dc1629c 100644 --- a/ppocr/modeling/architectures/base_model.py +++ b/ppocr/modeling/architectures/base_model.py @@ -14,7 +14,6 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function - from paddle import nn from ppocr.modeling.transforms import build_transform from ppocr.modeling.backbones import build_backbone diff --git a/ppocr/modeling/backbones/__init__.py b/ppocr/modeling/backbones/__init__.py index f4fe8c76be0835f55f402f35ad6a91a5ca116d88..f8ca7e408ac5fb9118114d1dfaae4a9eb481160f 100755 --- a/ppocr/modeling/backbones/__init__.py +++ b/ppocr/modeling/backbones/__init__.py @@ -26,8 +26,9 @@ def build_backbone(config, model_type): from .rec_resnet_vd import ResNet from .rec_resnet_fpn import ResNetFPN from .rec_mv1_enhance import MobileNetV1Enhance + from .rec_nrtr_mtb import MTB support_dict = [ - "MobileNetV1Enhance", "MobileNetV3", "ResNet", "ResNetFPN" + 'MobileNetV1Enhance', 'MobileNetV3', 'ResNet', 'ResNetFPN', 'MTB' ] elif model_type == "e2e": from .e2e_resnet_vd_pg import ResNet diff --git a/ppocr/modeling/backbones/rec_nrtr_mtb.py b/ppocr/modeling/backbones/rec_nrtr_mtb.py new file mode 100644 index 0000000000000000000000000000000000000000..04b5c9bb5fdff448fbf7ad366bc39bf0e3ebfe6b --- /dev/null +++ b/ppocr/modeling/backbones/rec_nrtr_mtb.py @@ -0,0 +1,46 @@ +# copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# 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. + +from paddle import nn + + +class MTB(nn.Layer): + def __init__(self, cnn_num, in_channels): + super(MTB, self).__init__() + self.block = nn.Sequential() + self.out_channels = in_channels + self.cnn_num = cnn_num + if self.cnn_num == 2: + for i in range(self.cnn_num): + self.block.add_sublayer( + 'conv_{}'.format(i), + nn.Conv2D( + in_channels=in_channels + if i == 0 else 32 * (2**(i - 1)), + out_channels=32 * (2**i), + kernel_size=3, + stride=2, + padding=1)) + self.block.add_sublayer('relu_{}'.format(i), nn.ReLU()) + self.block.add_sublayer('bn_{}'.format(i), + nn.BatchNorm2D(32 * (2**i))) + + def forward(self, images): + x = self.block(images) + if self.cnn_num == 2: + # (b, w, h, c) + x = x.transpose([0, 3, 2, 1]) + x_shape = x.shape + x = x.reshape([x_shape[0], x_shape[1], x_shape[2] * x_shape[3]]) + return x diff --git a/ppocr/modeling/heads/__init__.py b/ppocr/modeling/heads/__init__.py index 5096479415f504aa9f074d55bd9b2e4a31c730b4..572ec4aa8a0c9cdee236ef66b0277a2f614cfd47 100755 --- a/ppocr/modeling/heads/__init__.py +++ b/ppocr/modeling/heads/__init__.py @@ -26,12 +26,14 @@ def build_head(config): from .rec_ctc_head import CTCHead from .rec_att_head import AttentionHead from .rec_srn_head import SRNHead + from .rec_nrtr_head import Transformer # cls head from .cls_head import ClsHead support_dict = [ 'DBHead', 'EASTHead', 'SASTHead', 'CTCHead', 'ClsHead', 'AttentionHead', - 'SRNHead', 'PGHead', 'TableAttentionHead'] + 'SRNHead', 'PGHead', 'Transformer', 'TableAttentionHead' + ] #table head from .table_att_head import TableAttentionHead diff --git a/ppocr/modeling/heads/multiheadAttention.py b/ppocr/modeling/heads/multiheadAttention.py new file mode 100755 index 0000000000000000000000000000000000000000..651d4f577d2f5d1c11e36f90d1c7fea5fc3ab86e --- /dev/null +++ b/ppocr/modeling/heads/multiheadAttention.py @@ -0,0 +1,178 @@ +# copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve. +# +# 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 paddle +from paddle import nn +import paddle.nn.functional as F +from paddle.nn import Linear +from paddle.nn.initializer import XavierUniform as xavier_uniform_ +from paddle.nn.initializer import Constant as constant_ +from paddle.nn.initializer import XavierNormal as xavier_normal_ + +zeros_ = constant_(value=0.) +ones_ = constant_(value=1.) + + +class MultiheadAttention(nn.Layer): + """Allows the model to jointly attend to information + from different representation subspaces. + See reference: Attention Is All You Need + + .. math:: + \text{MultiHead}(Q, K, V) = \text{Concat}(head_1,\dots,head_h)W^O + \text{where} head_i = \text{Attention}(QW_i^Q, KW_i^K, VW_i^V) + + Args: + embed_dim: total dimension of the model + num_heads: parallel attention layers, or heads + + """ + + def __init__(self, + embed_dim, + num_heads, + dropout=0., + bias=True, + add_bias_kv=False, + add_zero_attn=False): + super(MultiheadAttention, self).__init__() + self.embed_dim = embed_dim + self.num_heads = num_heads + self.dropout = dropout + self.head_dim = embed_dim // num_heads + assert self.head_dim * num_heads == self.embed_dim, "embed_dim must be divisible by num_heads" + self.scaling = self.head_dim**-0.5 + self.out_proj = Linear(embed_dim, embed_dim, bias_attr=bias) + self._reset_parameters() + self.conv1 = paddle.nn.Conv2D( + in_channels=embed_dim, out_channels=embed_dim, kernel_size=(1, 1)) + self.conv2 = paddle.nn.Conv2D( + in_channels=embed_dim, out_channels=embed_dim, kernel_size=(1, 1)) + self.conv3 = paddle.nn.Conv2D( + in_channels=embed_dim, out_channels=embed_dim, kernel_size=(1, 1)) + + def _reset_parameters(self): + xavier_uniform_(self.out_proj.weight) + + def forward(self, + query, + key, + value, + key_padding_mask=None, + incremental_state=None, + need_weights=True, + static_kv=False, + attn_mask=None): + """ + Inputs of forward function + query: [target length, batch size, embed dim] + key: [sequence length, batch size, embed dim] + value: [sequence length, batch size, embed dim] + key_padding_mask: if True, mask padding based on batch size + incremental_state: if provided, previous time steps are cashed + need_weights: output attn_output_weights + static_kv: key and value are static + + Outputs of forward function + attn_output: [target length, batch size, embed dim] + attn_output_weights: [batch size, target length, sequence length] + """ + tgt_len, bsz, embed_dim = query.shape + assert embed_dim == self.embed_dim + assert list(query.shape) == [tgt_len, bsz, embed_dim] + assert key.shape == value.shape + + q = self._in_proj_q(query) + k = self._in_proj_k(key) + v = self._in_proj_v(value) + q *= self.scaling + + q = q.reshape([tgt_len, bsz * self.num_heads, self.head_dim]).transpose( + [1, 0, 2]) + k = k.reshape([-1, bsz * self.num_heads, self.head_dim]).transpose( + [1, 0, 2]) + v = v.reshape([-1, bsz * self.num_heads, self.head_dim]).transpose( + [1, 0, 2]) + + src_len = k.shape[1] + + if key_padding_mask is not None: + assert key_padding_mask.shape[0] == bsz + assert key_padding_mask.shape[1] == src_len + + attn_output_weights = paddle.bmm(q, k.transpose([0, 2, 1])) + assert list(attn_output_weights. + shape) == [bsz * self.num_heads, tgt_len, src_len] + + if attn_mask is not None: + attn_mask = attn_mask.unsqueeze(0) + attn_output_weights += attn_mask + if key_padding_mask is not None: + attn_output_weights = attn_output_weights.reshape( + [bsz, self.num_heads, tgt_len, src_len]) + key = key_padding_mask.unsqueeze(1).unsqueeze(2).astype('float32') + y = paddle.full(shape=key.shape, dtype='float32', fill_value='-inf') + y = paddle.where(key == 0., key, y) + attn_output_weights += y + attn_output_weights = attn_output_weights.reshape( + [bsz * self.num_heads, tgt_len, src_len]) + + attn_output_weights = F.softmax( + attn_output_weights.astype('float32'), + axis=-1, + dtype=paddle.float32 if attn_output_weights.dtype == paddle.float16 + else attn_output_weights.dtype) + attn_output_weights = F.dropout( + attn_output_weights, p=self.dropout, training=self.training) + + attn_output = paddle.bmm(attn_output_weights, v) + assert list(attn_output. + shape) == [bsz * self.num_heads, tgt_len, self.head_dim] + attn_output = attn_output.transpose([1, 0, 2]).reshape( + [tgt_len, bsz, embed_dim]) + attn_output = self.out_proj(attn_output) + + if need_weights: + # average attention weights over heads + attn_output_weights = attn_output_weights.reshape( + [bsz, self.num_heads, tgt_len, src_len]) + attn_output_weights = attn_output_weights.sum( + axis=1) / self.num_heads + else: + attn_output_weights = None + return attn_output, attn_output_weights + + def _in_proj_q(self, query): + query = query.transpose([1, 2, 0]) + query = paddle.unsqueeze(query, axis=2) + res = self.conv1(query) + res = paddle.squeeze(res, axis=2) + res = res.transpose([2, 0, 1]) + return res + + def _in_proj_k(self, key): + key = key.transpose([1, 2, 0]) + key = paddle.unsqueeze(key, axis=2) + res = self.conv2(key) + res = paddle.squeeze(res, axis=2) + res = res.transpose([2, 0, 1]) + return res + + def _in_proj_v(self, value): + value = value.transpose([1, 2, 0]) #(1, 2, 0) + value = paddle.unsqueeze(value, axis=2) + res = self.conv3(value) + res = paddle.squeeze(res, axis=2) + res = res.transpose([2, 0, 1]) + return res diff --git a/ppocr/modeling/heads/rec_nrtr_head.py b/ppocr/modeling/heads/rec_nrtr_head.py new file mode 100644 index 0000000000000000000000000000000000000000..05dba677b4109897b6a20888151e680e652d6741 --- /dev/null +++ b/ppocr/modeling/heads/rec_nrtr_head.py @@ -0,0 +1,844 @@ +# copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve. +# +# 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 math +import paddle +import copy +from paddle import nn +import paddle.nn.functional as F +from paddle.nn import LayerList +from paddle.nn.initializer import XavierNormal as xavier_uniform_ +from paddle.nn import Dropout, Linear, LayerNorm, Conv2D +import numpy as np +from ppocr.modeling.heads.multiheadAttention import MultiheadAttention +from paddle.nn.initializer import Constant as constant_ +from paddle.nn.initializer import XavierNormal as xavier_normal_ + +zeros_ = constant_(value=0.) +ones_ = constant_(value=1.) + + +class Transformer(nn.Layer): + """A transformer model. User is able to modify the attributes as needed. The architechture + is based on the paper "Attention Is All You Need". Ashish Vaswani, Noam Shazeer, + Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Lukasz Kaiser, and + Illia Polosukhin. 2017. Attention is all you need. In Advances in Neural Information + Processing Systems, pages 6000-6010. + + Args: + d_model: the number of expected features in the encoder/decoder inputs (default=512). + nhead: the number of heads in the multiheadattention models (default=8). + num_encoder_layers: the number of sub-encoder-layers in the encoder (default=6). + num_decoder_layers: the number of sub-decoder-layers in the decoder (default=6). + dim_feedforward: the dimension of the feedforward network model (default=2048). + dropout: the dropout value (default=0.1). + custom_encoder: custom encoder (default=None). + custom_decoder: custom decoder (default=None). + + """ + + def __init__(self, + d_model=512, + nhead=8, + num_encoder_layers=6, + beam_size=0, + num_decoder_layers=6, + dim_feedforward=1024, + attention_dropout_rate=0.0, + residual_dropout_rate=0.1, + custom_encoder=None, + custom_decoder=None, + in_channels=0, + out_channels=0, + dst_vocab_size=99, + scale_embedding=True): + super(Transformer, self).__init__() + self.embedding = Embeddings( + d_model=d_model, + vocab=dst_vocab_size, + padding_idx=0, + scale_embedding=scale_embedding) + self.positional_encoding = PositionalEncoding( + dropout=residual_dropout_rate, + dim=d_model, ) + if custom_encoder is not None: + self.encoder = custom_encoder + else: + if num_encoder_layers > 0: + encoder_layer = TransformerEncoderLayer( + d_model, nhead, dim_feedforward, attention_dropout_rate, + residual_dropout_rate) + self.encoder = TransformerEncoder(encoder_layer, + num_encoder_layers) + else: + self.encoder = None + + if custom_decoder is not None: + self.decoder = custom_decoder + else: + decoder_layer = TransformerDecoderLayer( + d_model, nhead, dim_feedforward, attention_dropout_rate, + residual_dropout_rate) + self.decoder = TransformerDecoder(decoder_layer, num_decoder_layers) + + self._reset_parameters() + self.beam_size = beam_size + self.d_model = d_model + self.nhead = nhead + self.tgt_word_prj = nn.Linear(d_model, dst_vocab_size, bias_attr=False) + w0 = np.random.normal(0.0, d_model**-0.5, + (d_model, dst_vocab_size)).astype(np.float32) + self.tgt_word_prj.weight.set_value(w0) + self.apply(self._init_weights) + + def _init_weights(self, m): + + if isinstance(m, nn.Conv2D): + xavier_normal_(m.weight) + if m.bias is not None: + zeros_(m.bias) + + def forward_train(self, src, tgt): + tgt = tgt[:, :-1] + + tgt_key_padding_mask = self.generate_padding_mask(tgt) + tgt = self.embedding(tgt).transpose([1, 0, 2]) + tgt = self.positional_encoding(tgt) + tgt_mask = self.generate_square_subsequent_mask(tgt.shape[0]) + + if self.encoder is not None: + src = self.positional_encoding(src.transpose([1, 0, 2])) + memory = self.encoder(src) + else: + memory = src.squeeze(2).transpose([2, 0, 1]) + output = self.decoder( + tgt, + memory, + tgt_mask=tgt_mask, + memory_mask=None, + tgt_key_padding_mask=tgt_key_padding_mask, + memory_key_padding_mask=None) + output = output.transpose([1, 0, 2]) + logit = self.tgt_word_prj(output) + return logit + + def forward(self, src, targets=None): + """Take in and process masked source/target sequences. + Args: + src: the sequence to the encoder (required). + tgt: the sequence to the decoder (required). + Shape: + - src: :math:`(S, N, E)`. + - tgt: :math:`(T, N, E)`. + Examples: + >>> output = transformer_model(src, tgt) + """ + + if self.training: + max_len = targets[1].max() + tgt = targets[0][:, :2 + max_len] + return self.forward_train(src, tgt) + else: + if self.beam_size > 0: + return self.forward_beam(src) + else: + return self.forward_test(src) + + def forward_test(self, src): + bs = src.shape[0] + if self.encoder is not None: + src = self.positional_encoding(src.transpose([1, 0, 2])) + memory = self.encoder(src) + else: + memory = src.squeeze(2).transpose([2, 0, 1]) + dec_seq = paddle.full((bs, 1), 2, dtype=paddle.int64) + for len_dec_seq in range(1, 25): + src_enc = memory.clone() + tgt_key_padding_mask = self.generate_padding_mask(dec_seq) + dec_seq_embed = self.embedding(dec_seq).transpose([1, 0, 2]) + dec_seq_embed = self.positional_encoding(dec_seq_embed) + tgt_mask = self.generate_square_subsequent_mask(dec_seq_embed.shape[ + 0]) + output = self.decoder( + dec_seq_embed, + src_enc, + tgt_mask=tgt_mask, + memory_mask=None, + tgt_key_padding_mask=tgt_key_padding_mask, + memory_key_padding_mask=None) + dec_output = output.transpose([1, 0, 2]) + + dec_output = dec_output[:, + -1, :] # Pick the last step: (bh * bm) * d_h + word_prob = F.log_softmax(self.tgt_word_prj(dec_output), axis=1) + word_prob = word_prob.reshape([1, bs, -1]) + preds_idx = word_prob.argmax(axis=2) + + if paddle.equal_all( + preds_idx[-1], + paddle.full( + preds_idx[-1].shape, 3, dtype='int64')): + break + + preds_prob = word_prob.max(axis=2) + dec_seq = paddle.concat( + [dec_seq, preds_idx.reshape([-1, 1])], axis=1) + + return dec_seq + + def forward_beam(self, images): + ''' Translation work in one batch ''' + + def get_inst_idx_to_tensor_position_map(inst_idx_list): + ''' Indicate the position of an instance in a tensor. ''' + return { + inst_idx: tensor_position + for tensor_position, inst_idx in enumerate(inst_idx_list) + } + + def collect_active_part(beamed_tensor, curr_active_inst_idx, + n_prev_active_inst, n_bm): + ''' Collect tensor parts associated to active instances. ''' + + _, *d_hs = beamed_tensor.shape + n_curr_active_inst = len(curr_active_inst_idx) + new_shape = (n_curr_active_inst * n_bm, *d_hs) + + beamed_tensor = beamed_tensor.reshape([n_prev_active_inst, -1]) + beamed_tensor = beamed_tensor.index_select( + paddle.to_tensor(curr_active_inst_idx), axis=0) + beamed_tensor = beamed_tensor.reshape([*new_shape]) + + return beamed_tensor + + def collate_active_info(src_enc, inst_idx_to_position_map, + active_inst_idx_list): + # Sentences which are still active are collected, + # so the decoder will not run on completed sentences. + + n_prev_active_inst = len(inst_idx_to_position_map) + active_inst_idx = [ + inst_idx_to_position_map[k] for k in active_inst_idx_list + ] + active_inst_idx = paddle.to_tensor(active_inst_idx, dtype='int64') + active_src_enc = collect_active_part( + src_enc.transpose([1, 0, 2]), active_inst_idx, + n_prev_active_inst, n_bm).transpose([1, 0, 2]) + active_inst_idx_to_position_map = get_inst_idx_to_tensor_position_map( + active_inst_idx_list) + return active_src_enc, active_inst_idx_to_position_map + + def beam_decode_step(inst_dec_beams, len_dec_seq, enc_output, + inst_idx_to_position_map, n_bm, + memory_key_padding_mask): + ''' Decode and update beam status, and then return active beam idx ''' + + def prepare_beam_dec_seq(inst_dec_beams, len_dec_seq): + dec_partial_seq = [ + b.get_current_state() for b in inst_dec_beams if not b.done + ] + dec_partial_seq = paddle.stack(dec_partial_seq) + + dec_partial_seq = dec_partial_seq.reshape([-1, len_dec_seq]) + return dec_partial_seq + + def prepare_beam_memory_key_padding_mask( + inst_dec_beams, memory_key_padding_mask, n_bm): + keep = [] + for idx in (memory_key_padding_mask): + if not inst_dec_beams[idx].done: + keep.append(idx) + memory_key_padding_mask = memory_key_padding_mask[ + paddle.to_tensor(keep)] + len_s = memory_key_padding_mask.shape[-1] + n_inst = memory_key_padding_mask.shape[0] + memory_key_padding_mask = paddle.concat( + [memory_key_padding_mask for i in range(n_bm)], axis=1) + memory_key_padding_mask = memory_key_padding_mask.reshape( + [n_inst * n_bm, len_s]) #repeat(1, n_bm) + return memory_key_padding_mask + + def predict_word(dec_seq, enc_output, n_active_inst, n_bm, + memory_key_padding_mask): + tgt_key_padding_mask = self.generate_padding_mask(dec_seq) + dec_seq = self.embedding(dec_seq).transpose([1, 0, 2]) + dec_seq = self.positional_encoding(dec_seq) + tgt_mask = self.generate_square_subsequent_mask(dec_seq.shape[ + 0]) + dec_output = self.decoder( + dec_seq, + enc_output, + tgt_mask=tgt_mask, + tgt_key_padding_mask=tgt_key_padding_mask, + memory_key_padding_mask=memory_key_padding_mask, + ).transpose([1, 0, 2]) + dec_output = dec_output[:, + -1, :] # Pick the last step: (bh * bm) * d_h + word_prob = F.log_softmax(self.tgt_word_prj(dec_output), axis=1) + word_prob = word_prob.reshape([n_active_inst, n_bm, -1]) + return word_prob + + def collect_active_inst_idx_list(inst_beams, word_prob, + inst_idx_to_position_map): + active_inst_idx_list = [] + for inst_idx, inst_position in inst_idx_to_position_map.items(): + is_inst_complete = inst_beams[inst_idx].advance(word_prob[ + inst_position]) + if not is_inst_complete: + active_inst_idx_list += [inst_idx] + + return active_inst_idx_list + + n_active_inst = len(inst_idx_to_position_map) + dec_seq = prepare_beam_dec_seq(inst_dec_beams, len_dec_seq) + memory_key_padding_mask = None + word_prob = predict_word(dec_seq, enc_output, n_active_inst, n_bm, + memory_key_padding_mask) + # Update the beam with predicted word prob information and collect incomplete instances + active_inst_idx_list = collect_active_inst_idx_list( + inst_dec_beams, word_prob, inst_idx_to_position_map) + return active_inst_idx_list + + def collect_hypothesis_and_scores(inst_dec_beams, n_best): + all_hyp, all_scores = [], [] + for inst_idx in range(len(inst_dec_beams)): + scores, tail_idxs = inst_dec_beams[inst_idx].sort_scores() + all_scores += [scores[:n_best]] + hyps = [ + inst_dec_beams[inst_idx].get_hypothesis(i) + for i in tail_idxs[:n_best] + ] + all_hyp += [hyps] + return all_hyp, all_scores + + with paddle.no_grad(): + #-- Encode + + if self.encoder is not None: + src = self.positional_encoding(images.transpose([1, 0, 2])) + src_enc = self.encoder(src).transpose([1, 0, 2]) + else: + src_enc = images.squeeze(2).transpose([0, 2, 1]) + + #-- Repeat data for beam search + n_bm = self.beam_size + n_inst, len_s, d_h = src_enc.shape + src_enc = paddle.concat([src_enc for i in range(n_bm)], axis=1) + src_enc = src_enc.reshape([n_inst * n_bm, len_s, d_h]).transpose( + [1, 0, 2]) + #-- Prepare beams + inst_dec_beams = [Beam(n_bm) for _ in range(n_inst)] + + #-- Bookkeeping for active or not + active_inst_idx_list = list(range(n_inst)) + inst_idx_to_position_map = get_inst_idx_to_tensor_position_map( + active_inst_idx_list) + #-- Decode + for len_dec_seq in range(1, 25): + src_enc_copy = src_enc.clone() + active_inst_idx_list = beam_decode_step( + inst_dec_beams, len_dec_seq, src_enc_copy, + inst_idx_to_position_map, n_bm, None) + if not active_inst_idx_list: + break # all instances have finished their path to + src_enc, inst_idx_to_position_map = collate_active_info( + src_enc_copy, inst_idx_to_position_map, + active_inst_idx_list) + batch_hyp, batch_scores = collect_hypothesis_and_scores(inst_dec_beams, + 1) + result_hyp = [] + for bs_hyp in batch_hyp: + bs_hyp_pad = bs_hyp[0] + [3] * (25 - len(bs_hyp[0])) + result_hyp.append(bs_hyp_pad) + return paddle.to_tensor(np.array(result_hyp), dtype=paddle.int64) + + def generate_square_subsequent_mask(self, sz): + """Generate a square mask for the sequence. The masked positions are filled with float('-inf'). + Unmasked positions are filled with float(0.0). + """ + mask = paddle.zeros([sz, sz], dtype='float32') + mask_inf = paddle.triu( + paddle.full( + shape=[sz, sz], dtype='float32', fill_value='-inf'), + diagonal=1) + mask = mask + mask_inf + return mask + + def generate_padding_mask(self, x): + padding_mask = x.equal(paddle.to_tensor(0, dtype=x.dtype)) + return padding_mask + + def _reset_parameters(self): + """Initiate parameters in the transformer model.""" + + for p in self.parameters(): + if p.dim() > 1: + xavier_uniform_(p) + + +class TransformerEncoder(nn.Layer): + """TransformerEncoder is a stack of N encoder layers + Args: + encoder_layer: an instance of the TransformerEncoderLayer() class (required). + num_layers: the number of sub-encoder-layers in the encoder (required). + norm: the layer normalization component (optional). + """ + + def __init__(self, encoder_layer, num_layers): + super(TransformerEncoder, self).__init__() + self.layers = _get_clones(encoder_layer, num_layers) + self.num_layers = num_layers + + def forward(self, src): + """Pass the input through the endocder layers in turn. + Args: + src: the sequnce to the encoder (required). + mask: the mask for the src sequence (optional). + src_key_padding_mask: the mask for the src keys per batch (optional). + """ + output = src + + for i in range(self.num_layers): + output = self.layers[i](output, + src_mask=None, + src_key_padding_mask=None) + + return output + + +class TransformerDecoder(nn.Layer): + """TransformerDecoder is a stack of N decoder layers + + Args: + decoder_layer: an instance of the TransformerDecoderLayer() class (required). + num_layers: the number of sub-decoder-layers in the decoder (required). + norm: the layer normalization component (optional). + + """ + + def __init__(self, decoder_layer, num_layers): + super(TransformerDecoder, self).__init__() + self.layers = _get_clones(decoder_layer, num_layers) + self.num_layers = num_layers + + def forward(self, + tgt, + memory, + tgt_mask=None, + memory_mask=None, + tgt_key_padding_mask=None, + memory_key_padding_mask=None): + """Pass the inputs (and mask) through the decoder layer in turn. + + Args: + tgt: the sequence to the decoder (required). + memory: the sequnce from the last layer of the encoder (required). + tgt_mask: the mask for the tgt sequence (optional). + memory_mask: the mask for the memory sequence (optional). + tgt_key_padding_mask: the mask for the tgt keys per batch (optional). + memory_key_padding_mask: the mask for the memory keys per batch (optional). + """ + output = tgt + for i in range(self.num_layers): + output = self.layers[i]( + output, + memory, + tgt_mask=tgt_mask, + memory_mask=memory_mask, + tgt_key_padding_mask=tgt_key_padding_mask, + memory_key_padding_mask=memory_key_padding_mask) + + return output + + +class TransformerEncoderLayer(nn.Layer): + """TransformerEncoderLayer is made up of self-attn and feedforward network. + This standard encoder layer is based on the paper "Attention Is All You Need". + Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, + Lukasz Kaiser, and Illia Polosukhin. 2017. Attention is all you need. In Advances in + Neural Information Processing Systems, pages 6000-6010. Users may modify or implement + in a different way during application. + + Args: + d_model: the number of expected features in the input (required). + nhead: the number of heads in the multiheadattention models (required). + dim_feedforward: the dimension of the feedforward network model (default=2048). + dropout: the dropout value (default=0.1). + + """ + + def __init__(self, + d_model, + nhead, + dim_feedforward=2048, + attention_dropout_rate=0.0, + residual_dropout_rate=0.1): + super(TransformerEncoderLayer, self).__init__() + self.self_attn = MultiheadAttention( + d_model, nhead, dropout=attention_dropout_rate) + + self.conv1 = Conv2D( + in_channels=d_model, + out_channels=dim_feedforward, + kernel_size=(1, 1)) + self.conv2 = Conv2D( + in_channels=dim_feedforward, + out_channels=d_model, + kernel_size=(1, 1)) + + self.norm1 = LayerNorm(d_model) + self.norm2 = LayerNorm(d_model) + self.dropout1 = Dropout(residual_dropout_rate) + self.dropout2 = Dropout(residual_dropout_rate) + + def forward(self, src, src_mask=None, src_key_padding_mask=None): + """Pass the input through the endocder layer. + Args: + src: the sequnce to the encoder layer (required). + src_mask: the mask for the src sequence (optional). + src_key_padding_mask: the mask for the src keys per batch (optional). + """ + src2 = self.self_attn( + src, + src, + src, + attn_mask=src_mask, + key_padding_mask=src_key_padding_mask)[0] + src = src + self.dropout1(src2) + src = self.norm1(src) + + src = src.transpose([1, 2, 0]) + src = paddle.unsqueeze(src, 2) + src2 = self.conv2(F.relu(self.conv1(src))) + src2 = paddle.squeeze(src2, 2) + src2 = src2.transpose([2, 0, 1]) + src = paddle.squeeze(src, 2) + src = src.transpose([2, 0, 1]) + + src = src + self.dropout2(src2) + src = self.norm2(src) + return src + + +class TransformerDecoderLayer(nn.Layer): + """TransformerDecoderLayer is made up of self-attn, multi-head-attn and feedforward network. + This standard decoder layer is based on the paper "Attention Is All You Need". + Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, + Lukasz Kaiser, and Illia Polosukhin. 2017. Attention is all you need. In Advances in + Neural Information Processing Systems, pages 6000-6010. Users may modify or implement + in a different way during application. + + Args: + d_model: the number of expected features in the input (required). + nhead: the number of heads in the multiheadattention models (required). + dim_feedforward: the dimension of the feedforward network model (default=2048). + dropout: the dropout value (default=0.1). + + """ + + def __init__(self, + d_model, + nhead, + dim_feedforward=2048, + attention_dropout_rate=0.0, + residual_dropout_rate=0.1): + super(TransformerDecoderLayer, self).__init__() + self.self_attn = MultiheadAttention( + d_model, nhead, dropout=attention_dropout_rate) + self.multihead_attn = MultiheadAttention( + d_model, nhead, dropout=attention_dropout_rate) + + self.conv1 = Conv2D( + in_channels=d_model, + out_channels=dim_feedforward, + kernel_size=(1, 1)) + self.conv2 = Conv2D( + in_channels=dim_feedforward, + out_channels=d_model, + kernel_size=(1, 1)) + + self.norm1 = LayerNorm(d_model) + self.norm2 = LayerNorm(d_model) + self.norm3 = LayerNorm(d_model) + self.dropout1 = Dropout(residual_dropout_rate) + self.dropout2 = Dropout(residual_dropout_rate) + self.dropout3 = Dropout(residual_dropout_rate) + + def forward(self, + tgt, + memory, + tgt_mask=None, + memory_mask=None, + tgt_key_padding_mask=None, + memory_key_padding_mask=None): + """Pass the inputs (and mask) through the decoder layer. + + Args: + tgt: the sequence to the decoder layer (required). + memory: the sequnce from the last layer of the encoder (required). + tgt_mask: the mask for the tgt sequence (optional). + memory_mask: the mask for the memory sequence (optional). + tgt_key_padding_mask: the mask for the tgt keys per batch (optional). + memory_key_padding_mask: the mask for the memory keys per batch (optional). + + """ + tgt2 = self.self_attn( + tgt, + tgt, + tgt, + attn_mask=tgt_mask, + key_padding_mask=tgt_key_padding_mask)[0] + tgt = tgt + self.dropout1(tgt2) + tgt = self.norm1(tgt) + tgt2 = self.multihead_attn( + tgt, + memory, + memory, + attn_mask=memory_mask, + key_padding_mask=memory_key_padding_mask)[0] + tgt = tgt + self.dropout2(tgt2) + tgt = self.norm2(tgt) + + # default + tgt = tgt.transpose([1, 2, 0]) + tgt = paddle.unsqueeze(tgt, 2) + tgt2 = self.conv2(F.relu(self.conv1(tgt))) + tgt2 = paddle.squeeze(tgt2, 2) + tgt2 = tgt2.transpose([2, 0, 1]) + tgt = paddle.squeeze(tgt, 2) + tgt = tgt.transpose([2, 0, 1]) + + tgt = tgt + self.dropout3(tgt2) + tgt = self.norm3(tgt) + return tgt + + +def _get_clones(module, N): + return LayerList([copy.deepcopy(module) for i in range(N)]) + + +class PositionalEncoding(nn.Layer): + """Inject some information about the relative or absolute position of the tokens + in the sequence. The positional encodings have the same dimension as + the embeddings, so that the two can be summed. Here, we use sine and cosine + functions of different frequencies. + .. math:: + \text{PosEncoder}(pos, 2i) = sin(pos/10000^(2i/d_model)) + \text{PosEncoder}(pos, 2i+1) = cos(pos/10000^(2i/d_model)) + \text{where pos is the word position and i is the embed idx) + Args: + d_model: the embed dim (required). + dropout: the dropout value (default=0.1). + max_len: the max. length of the incoming sequence (default=5000). + Examples: + >>> pos_encoder = PositionalEncoding(d_model) + """ + + def __init__(self, dropout, dim, max_len=5000): + super(PositionalEncoding, self).__init__() + self.dropout = nn.Dropout(p=dropout) + + pe = paddle.zeros([max_len, dim]) + position = paddle.arange(0, max_len, dtype=paddle.float32).unsqueeze(1) + div_term = paddle.exp( + paddle.arange(0, dim, 2).astype('float32') * + (-math.log(10000.0) / dim)) + pe[:, 0::2] = paddle.sin(position * div_term) + pe[:, 1::2] = paddle.cos(position * div_term) + pe = pe.unsqueeze(0) + pe = pe.transpose([1, 0, 2]) + self.register_buffer('pe', pe) + + def forward(self, x): + """Inputs of forward function + Args: + x: the sequence fed to the positional encoder model (required). + Shape: + x: [sequence length, batch size, embed dim] + output: [sequence length, batch size, embed dim] + Examples: + >>> output = pos_encoder(x) + """ + x = x + self.pe[:x.shape[0], :] + return self.dropout(x) + + +class PositionalEncoding_2d(nn.Layer): + """Inject some information about the relative or absolute position of the tokens + in the sequence. The positional encodings have the same dimension as + the embeddings, so that the two can be summed. Here, we use sine and cosine + functions of different frequencies. + .. math:: + \text{PosEncoder}(pos, 2i) = sin(pos/10000^(2i/d_model)) + \text{PosEncoder}(pos, 2i+1) = cos(pos/10000^(2i/d_model)) + \text{where pos is the word position and i is the embed idx) + Args: + d_model: the embed dim (required). + dropout: the dropout value (default=0.1). + max_len: the max. length of the incoming sequence (default=5000). + Examples: + >>> pos_encoder = PositionalEncoding(d_model) + """ + + def __init__(self, dropout, dim, max_len=5000): + super(PositionalEncoding_2d, self).__init__() + self.dropout = nn.Dropout(p=dropout) + + pe = paddle.zeros([max_len, dim]) + position = paddle.arange(0, max_len, dtype=paddle.float32).unsqueeze(1) + div_term = paddle.exp( + paddle.arange(0, dim, 2).astype('float32') * + (-math.log(10000.0) / dim)) + pe[:, 0::2] = paddle.sin(position * div_term) + pe[:, 1::2] = paddle.cos(position * div_term) + pe = pe.unsqueeze(0).transpose([1, 0, 2]) + self.register_buffer('pe', pe) + + self.avg_pool_1 = nn.AdaptiveAvgPool2D((1, 1)) + self.linear1 = nn.Linear(dim, dim) + self.linear1.weight.data.fill_(1.) + self.avg_pool_2 = nn.AdaptiveAvgPool2D((1, 1)) + self.linear2 = nn.Linear(dim, dim) + self.linear2.weight.data.fill_(1.) + + def forward(self, x): + """Inputs of forward function + Args: + x: the sequence fed to the positional encoder model (required). + Shape: + x: [sequence length, batch size, embed dim] + output: [sequence length, batch size, embed dim] + Examples: + >>> output = pos_encoder(x) + """ + w_pe = self.pe[:x.shape[-1], :] + w1 = self.linear1(self.avg_pool_1(x).squeeze()).unsqueeze(0) + w_pe = w_pe * w1 + w_pe = w_pe.transpose([1, 2, 0]) + w_pe = w_pe.unsqueeze(2) + + h_pe = self.pe[:x.shape[-2], :] + w2 = self.linear2(self.avg_pool_2(x).squeeze()).unsqueeze(0) + h_pe = h_pe * w2 + h_pe = h_pe.transpose([1, 2, 0]) + h_pe = h_pe.unsqueeze(3) + + x = x + w_pe + h_pe + x = x.reshape( + [x.shape[0], x.shape[1], x.shape[2] * x.shape[3]]).transpose( + [2, 0, 1]) + + return self.dropout(x) + + +class Embeddings(nn.Layer): + def __init__(self, d_model, vocab, padding_idx, scale_embedding): + super(Embeddings, self).__init__() + self.embedding = nn.Embedding(vocab, d_model, padding_idx=padding_idx) + w0 = np.random.normal(0.0, d_model**-0.5, + (vocab, d_model)).astype(np.float32) + self.embedding.weight.set_value(w0) + self.d_model = d_model + self.scale_embedding = scale_embedding + + def forward(self, x): + if self.scale_embedding: + x = self.embedding(x) + return x * math.sqrt(self.d_model) + return self.embedding(x) + + +class Beam(): + ''' Beam search ''' + + def __init__(self, size, device=False): + + self.size = size + self._done = False + # The score for each translation on the beam. + self.scores = paddle.zeros((size, ), dtype=paddle.float32) + self.all_scores = [] + # The backpointers at each time-step. + self.prev_ks = [] + # The outputs at each time-step. + self.next_ys = [paddle.full((size, ), 0, dtype=paddle.int64)] + self.next_ys[0][0] = 2 + + def get_current_state(self): + "Get the outputs for the current timestep." + return self.get_tentative_hypothesis() + + def get_current_origin(self): + "Get the backpointers for the current timestep." + return self.prev_ks[-1] + + @property + def done(self): + return self._done + + def advance(self, word_prob): + "Update beam status and check if finished or not." + num_words = word_prob.shape[1] + + # Sum the previous scores. + if len(self.prev_ks) > 0: + beam_lk = word_prob + self.scores.unsqueeze(1).expand_as(word_prob) + else: + beam_lk = word_prob[0] + + flat_beam_lk = beam_lk.reshape([-1]) + best_scores, best_scores_id = flat_beam_lk.topk(self.size, 0, True, + True) # 1st sort + self.all_scores.append(self.scores) + self.scores = best_scores + # bestScoresId is flattened as a (beam x word) array, + # so we need to calculate which word and beam each score came from + prev_k = best_scores_id // num_words + self.prev_ks.append(prev_k) + self.next_ys.append(best_scores_id - prev_k * num_words) + # End condition is when top-of-beam is EOS. + if self.next_ys[-1][0] == 3: + self._done = True + self.all_scores.append(self.scores) + + return self._done + + def sort_scores(self): + "Sort the scores." + return self.scores, paddle.to_tensor( + [i for i in range(self.scores.shape[0])], dtype='int32') + + def get_the_best_score_and_idx(self): + "Get the score of the best in the beam." + scores, ids = self.sort_scores() + return scores[1], ids[1] + + def get_tentative_hypothesis(self): + "Get the decoded sequence for the current timestep." + if len(self.next_ys) == 1: + dec_seq = self.next_ys[0].unsqueeze(1) + else: + _, keys = self.sort_scores() + hyps = [self.get_hypothesis(k) for k in keys] + hyps = [[2] + h for h in hyps] + dec_seq = paddle.to_tensor(hyps, dtype='int64') + return dec_seq + + def get_hypothesis(self, k): + """ Walk back to construct the full hypothesis. """ + hyp = [] + for j in range(len(self.prev_ks) - 1, -1, -1): + hyp.append(self.next_ys[j + 1][k]) + k = self.prev_ks[j][k] + return list(map(lambda x: x.item(), hyp[::-1])) diff --git a/ppocr/postprocess/__init__.py b/ppocr/postprocess/__init__.py index 654ddf39d23590fbaf7f7b9b57f38cc86a1b6669..6159398770e796dc9f5a6dc97e3f845667de95f0 100644 --- a/ppocr/postprocess/__init__.py +++ b/ppocr/postprocess/__init__.py @@ -24,18 +24,16 @@ __all__ = ['build_post_process'] from .db_postprocess import DBPostProcess, DistillationDBPostProcess from .east_postprocess import EASTPostProcess from .sast_postprocess import SASTPostProcess -from .rec_postprocess import CTCLabelDecode, AttnLabelDecode, SRNLabelDecode, DistillationCTCLabelDecode, \ +from .rec_postprocess import CTCLabelDecode, AttnLabelDecode, SRNLabelDecode, DistillationCTCLabelDecode, NRTRLabelDecode, \ TableLabelDecode from .cls_postprocess import ClsPostProcess from .pg_postprocess import PGPostProcess - def build_post_process(config, global_config=None): support_dict = [ 'DBPostProcess', 'EASTPostProcess', 'SASTPostProcess', 'CTCLabelDecode', 'AttnLabelDecode', 'ClsPostProcess', 'SRNLabelDecode', 'PGPostProcess', - 'DistillationCTCLabelDecode', 'TableLabelDecode', - 'DistillationDBPostProcess' + 'DistillationCTCLabelDecode', 'NRTRLabelDecode', 'TableLabelDecode', 'DistillationDBPostProcess' ] config = copy.deepcopy(config) diff --git a/ppocr/postprocess/rec_postprocess.py b/ppocr/postprocess/rec_postprocess.py index 8ebe5b2741b77537b46b8057d9aa9c36dc99aeec..9f23b5495f63a41283656ceaf9df76f96b8d1592 100644 --- a/ppocr/postprocess/rec_postprocess.py +++ b/ppocr/postprocess/rec_postprocess.py @@ -156,6 +156,69 @@ class DistillationCTCLabelDecode(CTCLabelDecode): return output +class NRTRLabelDecode(BaseRecLabelDecode): + """ Convert between text-label and text-index """ + + def __init__(self, + character_dict_path=None, + character_type='EN_symbol', + use_space_char=True, + **kwargs): + super(NRTRLabelDecode, self).__init__(character_dict_path, + character_type, use_space_char) + + def __call__(self, preds, label=None, *args, **kwargs): + if preds.dtype == paddle.int64: + if isinstance(preds, paddle.Tensor): + preds = preds.numpy() + if preds[0][0]==2: + preds_idx = preds[:,1:] + else: + preds_idx = preds + + text = self.decode(preds_idx) + if label is None: + return text + label = self.decode(label[:,1:]) + else: + if isinstance(preds, paddle.Tensor): + preds = preds.numpy() + preds_idx = preds.argmax(axis=2) + preds_prob = preds.max(axis=2) + text = self.decode(preds_idx, preds_prob, is_remove_duplicate=False) + if label is None: + return text + label = self.decode(label[:,1:]) + return text, label + + def add_special_char(self, dict_character): + dict_character = ['blank','','',''] + dict_character + return dict_character + + def decode(self, text_index, text_prob=None, is_remove_duplicate=False): + """ convert text-index into text-label. """ + result_list = [] + 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] == 3: # end + break + try: + char_list.append(self.character[int(text_index[batch_idx][idx])]) + except: + continue + 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.lower(), np.mean(conf_list))) + return result_list + + + class AttnLabelDecode(BaseRecLabelDecode): """ Convert between text-label and text-index """ @@ -193,8 +256,7 @@ class AttnLabelDecode(BaseRecLabelDecode): 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])]) + 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: diff --git a/ppstructure/README.md b/ppstructure/README.md index 8e1642cc75cc52b179d0f8441a8da2fe86e78d7b..a00d12d8edbf5bd20a5c7efd41cf69809861ea31 100644 --- a/ppstructure/README.md +++ b/ppstructure/README.md @@ -30,13 +30,13 @@ python3 -m pip install paddlepaddle-gpu==2.1.1 -i https://mirror.baidu.com/pypi/ # CPU python3 -m pip install paddlepaddle==2.1.1 -i https://mirror.baidu.com/pypi/simple -# For more,refer[Installation](https://www.paddlepaddle.org.cn/install/quick)。 ``` +For more,refer [Installation](https://www.paddlepaddle.org.cn/install/quick) . - **(2) Install Layout-Parser** ```bash -pip3 install -U premailer paddleocr https://paddleocr.bj.bcebos.com/whl/layoutparser-0.0.0-py3-none-any.whl +pip3 install -U https://paddleocr.bj.bcebos.com/whl/layoutparser-0.0.0-py3-none-any.whl ``` ### 2.2 Install PaddleOCR(including PP-OCR and PP-Structure) @@ -180,10 +180,10 @@ OCR and table recognition model |model name|description|model size|download| | --- | --- | --- | --- | -|ch_ppocr_mobile_slim_v2.0_det|Slim pruned lightweight model, supporting Chinese, English, multilingual text detection|2.6M|[inference model](https://paddleocr.bj.bcebos.com/dygraph_v2.0/slim/ch_ppocr_mobile_v2.0_det_prune_infer.tar) | -|ch_ppocr_mobile_slim_v2.0_rec|Slim pruned and quantized lightweight model, supporting Chinese, English and number recognition|6M|[inference model](https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_rec_slim_infer.tar) | -|en_ppocr_mobile_v2.0_table_det|Text detection of English table scenes trained on PubLayNet dataset|4.7M|[inference model](https://paddleocr.bj.bcebos.com/dygraph_v2.0/table/en_ppocr_mobile_v2.0_table_det_infer.tar) | -|en_ppocr_mobile_v2.0_table_rec|Text recognition of English table scene trained on PubLayNet dataset|6.9M|[inference model](https://paddleocr.bj.bcebos.com/dygraph_v2.0/table/en_ppocr_mobile_v2.0_table_rec_infer.tar) | -|en_ppocr_mobile_v2.0_table_structure|Table structure prediction of English table scene trained on PubLayNet dataset|18.6M|[inference model](https://paddleocr.bj.bcebos.com/dygraph_v2.0/table/en_ppocr_mobile_v2.0_table_structure_infer.tar) | +|ch_ppocr_mobile_slim_v2.0_det|Slim pruned lightweight model, supporting Chinese, English, multilingual text detection|2.6M|[inference model](https://paddleocr.bj.bcebos.com/dygraph_v2.0/slim/ch_ppocr_mobile_v2.0_det_prune_infer.tar) / [trained model](https://paddleocr.bj.bcebos.com/dygraph_v2.0/slim/ch_ppocr_mobile_v2.0_det_prune_infer.tar) | +|ch_ppocr_mobile_slim_v2.0_rec|Slim pruned and quantized lightweight model, supporting Chinese, English and number recognition|6M|[inference model](https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_rec_slim_infer.tar) / [trained model](https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_rec_slim_train.tar) | +|en_ppocr_mobile_v2.0_table_det|Text detection of English table scenes trained on PubLayNet dataset|4.7M|[inference model](https://paddleocr.bj.bcebos.com/dygraph_v2.0/table/en_ppocr_mobile_v2.0_table_det_infer.tar) / [trained model](https://paddleocr.bj.bcebos.com/dygraph_v2.1/table/en_ppocr_mobile_v2.0_table_det_train.tar) | +|en_ppocr_mobile_v2.0_table_rec|Text recognition of English table scene trained on PubLayNet dataset|6.9M|[inference model](https://paddleocr.bj.bcebos.com/dygraph_v2.0/table/en_ppocr_mobile_v2.0_table_rec_infer.tar) [trained model](https://paddleocr.bj.bcebos.com/dygraph_v2.1/table/en_ppocr_mobile_v2.0_table_rec_train.tar) | +|en_ppocr_mobile_v2.0_table_structure|Table structure prediction of English table scene trained on PubLayNet dataset|18.6M|[inference model](https://paddleocr.bj.bcebos.com/dygraph_v2.0/table/en_ppocr_mobile_v2.0_table_structure_infer.tar) / [trained model](https://paddleocr.bj.bcebos.com/dygraph_v2.1/table/en_ppocr_mobile_v2.0_table_structure_train.tar) | If you need to use other models, you can download the model in [model_list](../doc/doc_en/models_list_en.md) or use your own trained model to configure it to the three fields of `det_model_dir`, `rec_model_dir`, `table_model_dir` . diff --git a/ppstructure/README_ch.md b/ppstructure/README_ch.md index c8acac590039647cf52f47b16a99092ff68f2b6e..821a6c3e36361abefa4d754537fdbd694e844efe 100644 --- a/ppstructure/README_ch.md +++ b/ppstructure/README_ch.md @@ -30,13 +30,13 @@ python3 -m pip install paddlepaddle-gpu==2.1.1 -i https://mirror.baidu.com/pypi/ # CPU安装 python3 -m pip install paddlepaddle==2.1.1 -i https://mirror.baidu.com/pypi/simple -# 更多需求,请参照[安装文档](https://www.paddlepaddle.org.cn/install/quick)中的说明进行操作。 ``` +更多需求,请参照[安装文档](https://www.paddlepaddle.org.cn/install/quick)中的说明进行操作。 - **(2) 安装 Layout-Parser** ```bash -pip3 install -U premailer paddleocr https://paddleocr.bj.bcebos.com/whl/layoutparser-0.0.0-py3-none-any.whl +pip3 install -U https://paddleocr.bj.bcebos.com/whl/layoutparser-0.0.0-py3-none-any.whl ``` ### 2.2 安装PaddleOCR(包含PP-OCR和PP-Structure) @@ -179,10 +179,10 @@ OCR和表格识别模型 |模型名称|模型简介|推理模型大小|下载地址| | --- | --- | --- | --- | -|ch_ppocr_mobile_slim_v2.0_det|slim裁剪版超轻量模型,支持中英文、多语种文本检测|2.6M|[推理模型](https://paddleocr.bj.bcebos.com/dygraph_v2.0/slim/ch_ppocr_mobile_v2.0_det_prune_infer.tar) | -|ch_ppocr_mobile_slim_v2.0_rec|slim裁剪量化版超轻量模型,支持中英文、数字识别|6M|[推理模型](https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_rec_slim_infer.tar) | -|en_ppocr_mobile_v2.0_table_det|PubLayNet数据集训练的英文表格场景的文字检测|4.7M|[推理模型](https://paddleocr.bj.bcebos.com/dygraph_v2.0/table/en_ppocr_mobile_v2.0_table_det_infer.tar) | -|en_ppocr_mobile_v2.0_table_rec|PubLayNet数据集训练的英文表格场景的文字识别|6.9M|[推理模型](https://paddleocr.bj.bcebos.com/dygraph_v2.0/table/en_ppocr_mobile_v2.0_table_rec_infer.tar) | -|en_ppocr_mobile_v2.0_table_structure|PubLayNet数据集训练的英文表格场景的表格结构预测|18.6M|[推理模型](https://paddleocr.bj.bcebos.com/dygraph_v2.0/table/en_ppocr_mobile_v2.0_table_structure_infer.tar) | +|ch_ppocr_mobile_slim_v2.0_det|slim裁剪版超轻量模型,支持中英文、多语种文本检测|2.6M|[推理模型](https://paddleocr.bj.bcebos.com/dygraph_v2.0/slim/ch_ppocr_mobile_v2.0_det_prune_infer.tar) / [训练模型](https://paddleocr.bj.bcebos.com/dygraph_v2.0/slim/ch_ppocr_mobile_v2.0_det_prune_infer.tar) | +|ch_ppocr_mobile_slim_v2.0_rec|slim裁剪量化版超轻量模型,支持中英文、数字识别|6M|[推理模型](https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_rec_slim_infer.tar) / [训练模型](https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_rec_slim_train.tar) | +|en_ppocr_mobile_v2.0_table_det|PubLayNet数据集训练的英文表格场景的文字检测|4.7M|[推理模型](https://paddleocr.bj.bcebos.com/dygraph_v2.0/table/en_ppocr_mobile_v2.0_table_det_infer.tar) / [训练模型](https://paddleocr.bj.bcebos.com/dygraph_v2.1/table/en_ppocr_mobile_v2.0_table_det_train.tar) | +|en_ppocr_mobile_v2.0_table_rec|PubLayNet数据集训练的英文表格场景的文字识别|6.9M|[推理模型](https://paddleocr.bj.bcebos.com/dygraph_v2.0/table/en_ppocr_mobile_v2.0_table_rec_infer.tar) / [训练模型](https://paddleocr.bj.bcebos.com/dygraph_v2.1/table/en_ppocr_mobile_v2.0_table_rec_train.tar) | +|en_ppocr_mobile_v2.0_table_structure|PubLayNet数据集训练的英文表格场景的表格结构预测|18.6M|[推理模型](https://paddleocr.bj.bcebos.com/dygraph_v2.0/table/en_ppocr_mobile_v2.0_table_structure_infer.tar) / [训练模型](https://paddleocr.bj.bcebos.com/dygraph_v2.1/table/en_ppocr_mobile_v2.0_table_structure_train.tar) | 如需要使用其他模型,可以在 [model_list](../doc/doc_ch/models_list.md) 下载模型或者使用自己训练好的模型配置到`det_model_dir`,`rec_model_dir`,`table_model_dir`三个字段即可。 diff --git a/ppstructure/table/README.md b/ppstructure/table/README.md index a8d10b79e507ab59ef2481982a33902e4a95e73e..67c4d8e26d5c615f4a930752005420ba1abcc834 100644 --- a/ppstructure/table/README.md +++ b/ppstructure/table/README.md @@ -41,7 +41,7 @@ wget https://paddleocr.bj.bcebos.com/dygraph_v2.0/table/en_ppocr_mobile_v2.0_tab wget https://paddleocr.bj.bcebos.com/dygraph_v2.0/table/en_ppocr_mobile_v2.0_table_structure_infer.tar && tar xf en_ppocr_mobile_v2.0_table_structure_infer.tar cd .. # run -python3 table/predict_table.py --det_model_dir=inference/en_ppocr_mobile_v2.0_table_det_infer --rec_model_dir=inference/en_ppocr_mobile_v2.0_table_rec_infer --table_model_dir=inference/en_ppocr_mobile_v2.0_table_structure_infer --image_dir=../doc/table/table.jpg --rec_char_dict_path=../ppocr/utils/ppocr_keys_v1.txt --table_char_dict_path=../ppocr/utils/dict/table_structure_dict.txt --rec_char_type=ch --det_limit_side_len=736 --det_limit_type=min --output ../output/table +python3 table/predict_table.py --det_model_dir=inference/en_ppocr_mobile_v2.0_table_det_infer --rec_model_dir=inference/en_ppocr_mobile_v2.0_table_rec_infer --table_model_dir=inference/en_ppocr_mobile_v2.0_table_structure_infer --image_dir=../doc/table/table.jpg --rec_char_dict_path=../ppocr/utils/dict/table_dict.txt --table_char_dict_path=../ppocr/utils/dict/table_structure_dict.txt --rec_char_type=EN --det_limit_side_len=736 --det_limit_type=min --output ../output/table ``` Note: The above model is trained on the PubLayNet dataset and only supports English scanning scenarios. If you need to identify other scenarios, you need to train the model yourself and replace the three fields `det_model_dir`, `rec_model_dir`, `table_model_dir`. diff --git a/ppstructure/table/README_ch.md b/ppstructure/table/README_ch.md index 2ded403c371984a447f94268d23ca1c6240cf432..e580debaebd2425786e84bedb13301c2f0bb09d3 100644 --- a/ppstructure/table/README_ch.md +++ b/ppstructure/table/README_ch.md @@ -43,7 +43,7 @@ wget https://paddleocr.bj.bcebos.com/dygraph_v2.0/table/en_ppocr_mobile_v2.0_tab wget https://paddleocr.bj.bcebos.com/dygraph_v2.0/table/en_ppocr_mobile_v2.0_table_structure_infer.tar && tar xf en_ppocr_mobile_v2.0_table_structure_infer.tar cd .. # 执行预测 -python3 table/predict_table.py --det_model_dir=inference/en_ppocr_mobile_v2.0_table_det_infer --rec_model_dir=inference/en_ppocr_mobile_v2.0_table_rec_infer --table_model_dir=inference/en_ppocr_mobile_v2.0_table_structure_infer --image_dir=../doc/table/table.jpg --rec_char_dict_path=../ppocr/utils/ppocr_keys_v1.txt --table_char_dict_path=../ppocr/utils/dict/table_structure_dict.txt --rec_char_type=ch --det_limit_side_len=736 --det_limit_type=min --output ../output/table +python3 table/predict_table.py --det_model_dir=inference/en_ppocr_mobile_v2.0_table_det_infer --rec_model_dir=inference/en_ppocr_mobile_v2.0_table_rec_infer --table_model_dir=inference/en_ppocr_mobile_v2.0_table_structure_infer --image_dir=../doc/table/table.jpg --rec_char_dict_path=../ppocr/utils/dict/table_dict.txt --table_char_dict_path=../ppocr/utils/dict/table_structure_dict.txt --rec_char_type=EN --det_limit_side_len=736 --det_limit_type=min --output ../output/table ``` 运行完成后,每张图片的excel表格会保存到output字段指定的目录下 diff --git a/requirements.txt b/requirements.txt index 351d409092a1f387b720c3ff2d43889170f320a7..2c7baa8516932f56f77b71b4e6dc7d45cd43072e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,4 +7,7 @@ tqdm numpy visualdl python-Levenshtein -opencv-contrib-python==4.4.0.46 \ No newline at end of file +opencv-contrib-python==4.4.0.46 +lxml +premailer +openpyxl \ No newline at end of file diff --git a/tests/compare_results.py b/tests/compare_results.py new file mode 100644 index 0000000000000000000000000000000000000000..1c3fe4ea951aef122728a7aed7fc4ecaf8e7607e --- /dev/null +++ b/tests/compare_results.py @@ -0,0 +1,133 @@ +import numpy as np +import os +import subprocess +import json +import argparse +import glob + + +def init_args(): + parser = argparse.ArgumentParser() + # params for testing assert allclose + parser.add_argument("--atol", type=float, default=1e-3) + parser.add_argument("--rtol", type=float, default=1e-3) + parser.add_argument("--gt_file", type=str, default="") + parser.add_argument("--log_file", type=str, default="") + parser.add_argument("--precision", type=str, default="fp32") + return parser + + +def parse_args(): + parser = init_args() + return parser.parse_args() + + +def run_shell_command(cmd): + p = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) + out, err = p.communicate() + + if p.returncode == 0: + return out.decode('utf-8') + else: + return None + + +def parser_results_from_log_by_name(log_path, names_list): + if not os.path.exists(log_path): + raise ValueError("The log file {} does not exists!".format(log_path)) + + if names_list is None or len(names_list) < 1: + return [] + + parser_results = {} + for name in names_list: + cmd = "grep {} {}".format(name, log_path) + outs = run_shell_command(cmd) + outs = outs.split("\n")[0] + result = outs.split("{}".format(name))[-1] + result = json.loads(result) + parser_results[name] = result + return parser_results + + +def load_gt_from_file(gt_file): + if not os.path.exists(gt_file): + raise ValueError("The log file {} does not exists!".format(gt_file)) + with open(gt_file, 'r') as f: + data = f.readlines() + f.close() + parser_gt = {} + for line in data: + image_name, result = line.strip("\n").split("\t") + result = json.loads(result) + parser_gt[image_name] = result + return parser_gt + + +def load_gt_from_txts(gt_file): + gt_list = glob.glob(gt_file) + gt_collection = {} + for gt_f in gt_list: + gt_dict = load_gt_from_file(gt_f) + basename = os.path.basename(gt_f) + if "fp32" in basename: + gt_collection["fp32"] = [gt_dict, gt_f] + elif "fp16" in basename: + gt_collection["fp16"] = [gt_dict, gt_f] + elif "int8" in basename: + gt_collection["int8"] = [gt_dict, gt_f] + else: + continue + return gt_collection + + +def collect_predict_from_logs(log_path, key_list): + log_list = glob.glob(log_path) + pred_collection = {} + for log_f in log_list: + pred_dict = parser_results_from_log_by_name(log_f, key_list) + key = os.path.basename(log_f) + pred_collection[key] = pred_dict + + return pred_collection + + +def testing_assert_allclose(dict_x, dict_y, atol=1e-7, rtol=1e-7): + for k in dict_x: + np.testing.assert_allclose( + np.array(dict_x[k]), np.array(dict_y[k]), atol=atol, rtol=rtol) + + +if __name__ == "__main__": + # Usage: + # python3.7 tests/compare_results.py --gt_file=./tests/results/*.txt --log_file=./tests/output/infer_*.log + + args = parse_args() + + gt_collection = load_gt_from_txts(args.gt_file) + key_list = gt_collection["fp32"][0].keys() + + pred_collection = collect_predict_from_logs(args.log_file, key_list) + for filename in pred_collection.keys(): + if "fp32" in filename: + gt_dict, gt_filename = gt_collection["fp32"] + elif "fp16" in filename: + gt_dict, gt_filename = gt_collection["fp16"] + elif "int8" in filename: + gt_dict, gt_filename = gt_collection["int8"] + else: + continue + pred_dict = pred_collection[filename] + + try: + testing_assert_allclose( + gt_dict, pred_dict, atol=args.atol, rtol=args.rtol) + print( + "Assert allclose passed! The results of {} and {} are consistent!". + format(filename, gt_filename)) + except Exception as E: + print(E) + raise ValueError( + "The results of {} and the results of {} are inconsistent!". + format(filename, gt_filename)) diff --git a/tests/ocr_det_params.txt b/tests/ocr_det_params.txt index 2dd9f958ab1688ef40a835dce6c6d10be7bb94a5..a34e94b3013efd716ebdc94ec39f866c220b7b82 100644 --- a/tests/ocr_det_params.txt +++ b/tests/ocr_det_params.txt @@ -4,7 +4,7 @@ python:python3.7 gpu_list:0|0,1 Global.use_gpu:True|True Global.auto_cast:null -Global.epoch_num:lite_train_infer=2|whole_train_infer=300 +Global.epoch_num:lite_train_infer=1|whole_train_infer=300 Global.save_model_dir:./output/ Train.loader.batch_size_per_card:lite_train_infer=2|whole_train_infer=4 Global.pretrained_model:null @@ -15,7 +15,7 @@ null:null trainer:norm_train|pact_train norm_train:tools/train.py -c configs/det/det_mv3_db.yml -o Global.pretrained_model=./pretrain_models/MobileNetV3_large_x0_5_pretrained pact_train:deploy/slim/quantization/quant.py -c configs/det/det_mv3_db.yml -o -fpgm_train:null +fpgm_train:deploy/slim/prune/sensitivity_anal.py -c configs/det/det_mv3_db.yml -o Global.pretrained_model=./pretrain_models/det_mv3_db_v2.0_train/best_accuracy distill_train:null null:null null:null @@ -29,7 +29,7 @@ Global.save_inference_dir:./output/ Global.pretrained_model: norm_export:tools/export_model.py -c configs/det/det_mv3_db.yml -o quant_export:deploy/slim/quantization/export_model.py -c configs/det/det_mv3_db.yml -o -fpgm_export:deploy/slim/prune/export_prune_model.py +fpgm_export:deploy/slim/prune/export_prune_model.py -c configs/det/det_mv3_db.yml -o distill_export:null export1:null export2:null @@ -49,7 +49,22 @@ inference:tools/infer/predict_det.py --save_log_path:null --benchmark:True null:null -===========================deploy_params=========================== +===========================cpp_infer_params=========================== +use_opencv:True +infer_model:./inference/ch_ppocr_mobile_v2.0_det_infer/ +infer_quant:False +inference:./deploy/cpp_infer/build/ppocr det +--use_gpu:True|False +--enable_mkldnn:True|False +--cpu_threads:1|6 +--rec_batch_num:1 +--use_tensorrt:False|True +--precision:fp32|fp16 +--det_model_dir: +--image_dir:./inference/ch_det_data_50/all-sum-510/ +--save_log_path:null +--benchmark:True +===========================serving_params=========================== trans_model:-m paddle_serving_client.convert --dirname:./inference/ch_ppocr_mobile_v2.0_det_infer/ --model_filename:inference.pdmodel diff --git a/tests/ocr_det_server_params.txt b/tests/ocr_det_server_params.txt new file mode 100644 index 0000000000000000000000000000000000000000..0835cfffa62dd879d092bf829d782e767b9680ad --- /dev/null +++ b/tests/ocr_det_server_params.txt @@ -0,0 +1,52 @@ +===========================train_params=========================== +model_name:ocr_server_det +python:python3.7 +gpu_list:0|0,1 +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=2|whole_train_infer=4 +Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./train_data/icdar2015/text_localization/ch4_test_images/ +null:null +## +trainer:norm_train|pact_train +norm_train:tools/train.py -c configs/det/det_r50_vd_db.yml -o Global.pretrained_model="" +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:tools/eval.py -c configs/det/det_mv3_db.yml -o +null:null +## +===========================infer_params=========================== +Global.save_inference_dir:./output/ +Global.pretrained_model: +norm_export:tools/export_model.py -c configs/det/det_r50_vd_db.yml -o +quant_export:null +fpgm_export:null +distill_export:null +export1:null +export2:null +## +infer_model:./inference/ch_ppocr_server_v2.0_det_infer/ +infer_export:null +infer_quant:False +inference:tools/infer/predict_det.py +--use_gpu:True|False +--enable_mkldnn:True|False +--cpu_threads:1|6 +--rec_batch_num:1 +--use_tensorrt:False|True +--precision:fp32|fp16|int8 +--det_model_dir: +--image_dir:./inference/ch_det_data_50/all-sum-510/ +--save_log_path:null +--benchmark:True +null:null + diff --git a/tests/prepare.sh b/tests/prepare.sh index 94367f4829c418226598ecef852dfb091e7a0e54..ce28841fa3ed046791a2daacb344073d40b576e8 100644 --- a/tests/prepare.sh +++ b/tests/prepare.sh @@ -1,6 +1,6 @@ #!/bin/bash FILENAME=$1 -# MODE be one of ['lite_train_infer' 'whole_infer' 'whole_train_infer', 'infer'] +# MODE be one of ['lite_train_infer' 'whole_infer' 'whole_train_infer', 'infer', 'cpp_infer'] MODE=$2 dataline=$(cat ${FILENAME}) @@ -34,11 +34,15 @@ MODE=$2 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 + wget -nc -P ./pretrain_models/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/en/det_mv3_db_v2.0_train.tar + cd ./pretrain_models/ && tar xf det_mv3_db_v2.0_train.tar && cd ../ 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 wget -nc -P ./train_data/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/ic15_data.tar # todo change to bcebos wget -nc -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/rec_inference.tar + wget -nc -P ./deploy/slim/prune https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/sen.pickle + cd ./train_data/ && tar xf icdar2015_lite.tar && tar xf ic15_data.tar ln -s ./icdar2015_lite ./icdar2015 cd ../ @@ -59,13 +63,17 @@ elif [ ${MODE} = "whole_infer" ];then cd ./train_data/ && tar xf icdar2015_infer.tar && tar xf ic15_data.tar ln -s ./icdar2015_infer ./icdar2015 cd ../ -else +elif [ ${MODE} = "infer" ] || [ ${MODE} = "cpp_infer" ];then 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/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 ../ + elif [ ${model_name} = "ocr_server_det" ]; then + wget -nc -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_server_v2.0_det_infer.tar + wget -nc -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/ch_det_data_50.tar + cd ./inference && tar xf ch_ppocr_server_v2.0_det_infer.tar && tar xf ch_det_data_50.tar && cd ../ else rm -rf ./train_data/ic15_data eval_model_name="ch_ppocr_mobile_v2.0_rec_infer" @@ -86,3 +94,72 @@ wget -nc -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppoc cd ./inference && tar xf ch_ppocr_mobile_v2.0_det_infer.tar && tar xf ch_ppocr_mobile_v2.0_rec_infer.tar +if [ ${MODE} = "cpp_infer" ];then + cd deploy/cpp_infer + use_opencv=$(func_parser_value "${lines[52]}") + if [ ${use_opencv} = "True" ]; then + echo "################### build opencv ###################" + rm -rf 3.4.7.tar.gz opencv-3.4.7/ + wget https://github.com/opencv/opencv/archive/3.4.7.tar.gz + tar -xf 3.4.7.tar.gz + + cd opencv-3.4.7/ + install_path=$(pwd)/opencv-3.4.7/opencv3 + + rm -rf build + mkdir build + cd build + + cmake .. \ + -DCMAKE_INSTALL_PREFIX=${install_path} \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_SHARED_LIBS=OFF \ + -DWITH_IPP=OFF \ + -DBUILD_IPP_IW=OFF \ + -DWITH_LAPACK=OFF \ + -DWITH_EIGEN=OFF \ + -DCMAKE_INSTALL_LIBDIR=lib64 \ + -DWITH_ZLIB=ON \ + -DBUILD_ZLIB=ON \ + -DWITH_JPEG=ON \ + -DBUILD_JPEG=ON \ + -DWITH_PNG=ON \ + -DBUILD_PNG=ON \ + -DWITH_TIFF=ON \ + -DBUILD_TIFF=ON + + make -j + make install + cd ../ + echo "################### build opencv finished ###################" + fi + + + echo "################### build PaddleOCR demo ####################" + if [ ${use_opencv} = "True" ]; then + OPENCV_DIR=$(pwd)/opencv-3.4.7/opencv3/ + else + OPENCV_DIR='' + fi + LIB_DIR=$(pwd)/Paddle/build/paddle_inference_install_dir/ + CUDA_LIB_DIR=$(dirname `find /usr -name libcudart.so`) + CUDNN_LIB_DIR=$(dirname `find /usr -name libcudnn.so`) + + BUILD_DIR=build + rm -rf ${BUILD_DIR} + mkdir ${BUILD_DIR} + cd ${BUILD_DIR} + cmake .. \ + -DPADDLE_LIB=${LIB_DIR} \ + -DWITH_MKL=ON \ + -DWITH_GPU=OFF \ + -DWITH_STATIC_LIB=OFF \ + -DWITH_TENSORRT=OFF \ + -DOPENCV_DIR=${OPENCV_DIR} \ + -DCUDNN_LIB=${CUDNN_LIB_DIR} \ + -DCUDA_LIB=${CUDA_LIB_DIR} \ + -DTENSORRT_DIR=${TENSORRT_DIR} \ + + make -j + echo "################### build PaddleOCR demo finished ###################" +fi diff --git a/tests/readme.md b/tests/readme.md new file mode 100644 index 0000000000000000000000000000000000000000..1c5e0faee90cad9709b6e4d517cbf7830aa2bb8e --- /dev/null +++ b/tests/readme.md @@ -0,0 +1,58 @@ + +# 介绍 + +test.sh和params.txt文件配合使用,完成OCR轻量检测和识别模型从训练到预测的流程测试。 + +# 安装依赖 +- 安装PaddlePaddle >= 2.0 +- 安装PaddleOCR依赖 + ``` + pip3 install -r ../requirements.txt + ``` +- 安装autolog + ``` + git clone https://github.com/LDOUBLEV/AutoLog + cd AutoLog + pip3 install -r requirements.txt + python3 setup.py bdist_wheel + pip3 install ./dist/auto_log-1.0.0-py3-none-any.whl + cd ../ + ``` + +# 目录介绍 + +```bash +tests/ +├── ocr_det_params.txt # 测试OCR检测模型的参数配置文件 +├── ocr_rec_params.txt # 测试OCR识别模型的参数配置文件 +└── prepare.sh # 完成test.sh运行所需要的数据和模型下载 +└── test.sh # 根据 +``` + +# 使用方法 +test.sh包含四种运行模式,每种模式的运行数据不同,分别用于测试速度和精度,分别是: +- 模式1 lite_train_infer,使用少量数据训练,用于快速验证训练到预测的走通流程,不验证精度和速度; +``` +bash test/prepare.sh ./tests/ocr_det_params.txt 'lite_train_infer' +bash tests/test.sh ./tests/ocr_det_params.txt 'lite_train_infer' +``` +- 模式2 whole_infer,使用少量数据训练,一定量数据预测,用于验证训练后的模型执行预测,预测速度是否合理; +``` +bash tests/prepare.sh ./tests/ocr_det_params.txt 'whole_infer' +bash tests/test.sh ./tests/ocr_det_params.txt 'whole_infer' +``` + +- 模式3 infer 不训练,全量数据预测,走通开源模型评估、动转静,检查inference model预测时间和精度; +``` +bash tests/prepare.sh ./tests/ocr_det_params.txt 'infer' +用法1: +bash tests/test.sh ./tests/ocr_det_params.txt 'infer' +用法2: 指定GPU卡预测,第三个传入参数为GPU卡号 +bash tests/test.sh ./tests/ocr_det_params.txt 'infer' '1' +``` + +模式4: whole_train_infer , CE: 全量数据训练,全量数据预测,验证模型训练精度,预测精度,预测速度 +``` +bash tests/prepare.sh ./tests/ocr_det_params.txt 'whole_train_infer' +bash tests/test.sh ./tests/ocr_det_params.txt 'whole_train_infer' +``` diff --git a/tests/results/det_results_gpu_fp32.txt b/tests/results/det_results_gpu_fp32.txt new file mode 100644 index 0000000000000000000000000000000000000000..28af26d0b2178802baf45c58586d38f9eeffe820 --- /dev/null +++ b/tests/results/det_results_gpu_fp32.txt @@ -0,0 +1,49 @@ +00008790.jpg [[[209, 406], [280, 406], [280, 419], [209, 419]], [[60, 398], [105, 398], [105, 411], [60, 411]], [[198, 389], [291, 389], [291, 402], [198, 402]], [[162, 391], [173, 391], [173, 401], [162, 401]], [[35, 380], [133, 380], [133, 393], [35, 393]], [[199, 371], [292, 371], [292, 384], [199, 384]], [[218, 310], [272, 310], [272, 324], [218, 324]], [[162, 305], [172, 305], [172, 314], [162, 314]], [[371, 302], [436, 302], [436, 316], [371, 316]], [[31, 302], [134, 301], [134, 315], [31, 316]], [[223, 292], [269, 292], [269, 306], [223, 306]], [[60, 225], [104, 225], [104, 236], [60, 236]], [[218, 223], [272, 223], [272, 237], [218, 237]], [[162, 219], [173, 219], [173, 227], [162, 227]], [[33, 207], [131, 207], [131, 220], [33, 220]], [[223, 206], [269, 206], [269, 220], [223, 220]], [[74, 146], [383, 146], [383, 159], [74, 159]], [[54, 120], [117, 120], [117, 134], [54, 134]], [[74, 51], [296, 51], [296, 65], [74, 65]], [[56, 18], [116, 18], [116, 32], [56, 32]]] +00018946.jpg [[[441, 328], [474, 328], [474, 339], [441, 339]], [[86, 284], [141, 286], [140, 307], [85, 305]], [[302, 279], [377, 279], [377, 297], [302, 297]], [[197, 265], [281, 274], [279, 293], [195, 284]], [[198, 197], [452, 219], [450, 242], [196, 220]], [[343, 182], [376, 182], [376, 192], [343, 192]], [[199, 164], [340, 171], [339, 192], [198, 185]], [[177, 101], [415, 118], [413, 145], [175, 128]]] +00034387.jpg [[[265, 460], [740, 460], [740, 484], [265, 484]], [[348, 417], [420, 417], [420, 443], [348, 443]], [[545, 418], [568, 418], [568, 442], [545, 442]], [[685, 417], [710, 417], [710, 443], [685, 443]], [[175, 415], [226, 415], [226, 443], [175, 443]], [[874, 414], [908, 414], [908, 446], [874, 446]], [[56, 417], [74, 417], [74, 442], [56, 442]], [[856, 373], [925, 373], [925, 400], [856, 400]], [[348, 372], [418, 372], [418, 397], [348, 397]], [[674, 372], [723, 372], [723, 401], [674, 401]], [[539, 373], [570, 373], [570, 400], [539, 400]], [[151, 365], [228, 369], [226, 402], [149, 398]], [[56, 372], [74, 372], [74, 397], [56, 397]], [[857, 329], [925, 329], [925, 355], [857, 355]], [[351, 330], [419, 330], [419, 356], [351, 356]], [[674, 328], [723, 328], [723, 356], [674, 356]], [[541, 329], [570, 329], [570, 357], [541, 357]], [[171, 327], [227, 324], [229, 355], [173, 358]], [[57, 330], [74, 330], [74, 356], [57, 356]], [[298, 327], [316, 327], [316, 334], [298, 334]], [[855, 286], [925, 286], [925, 312], [855, 312]], [[674, 286], [723, 286], [723, 313], [674, 313]], [[346, 286], [426, 283], [427, 313], [347, 316]], [[540, 285], [569, 285], [569, 312], [540, 312]], [[172, 282], [226, 282], [226, 313], [172, 313]], [[56, 287], [73, 287], [73, 312], [56, 312]], [[857, 242], [925, 242], [925, 268], [857, 268]], [[348, 242], [460, 242], [460, 268], [348, 268]], [[156, 242], [227, 242], [227, 269], [156, 269]], [[674, 241], [724, 241], [724, 269], [674, 269]], [[531, 241], [572, 241], [572, 270], [531, 270]], [[56, 242], [74, 242], [74, 268], [56, 268]], [[855, 197], [925, 200], [924, 226], [854, 224]], [[674, 198], [726, 198], [726, 226], [674, 226]], [[344, 200], [434, 195], [436, 223], [346, 228]], [[176, 197], [227, 197], [227, 225], [176, 225]], [[56, 200], [73, 200], [73, 226], [56, 226]], [[527, 194], [576, 194], [576, 226], [527, 226]], [[349, 155], [419, 155], [419, 181], [349, 181]], [[854, 154], [925, 154], [925, 180], [854, 180]], [[176, 154], [226, 154], [226, 183], [176, 183]], [[670, 153], [723, 153], [723, 181], [670, 181]], [[538, 154], [571, 154], [571, 182], [538, 182]], [[56, 156], [74, 156], [74, 182], [56, 182]], [[349, 111], [419, 111], [419, 137], [349, 137]], [[174, 111], [227, 111], [227, 139], [174, 139]], [[546, 113], [564, 113], [564, 137], [546, 137]], [[52, 112], [75, 112], [75, 139], [52, 139]], [[639, 108], [727, 105], [728, 138], [640, 141]], [[817, 103], [927, 110], [925, 139], [815, 132]], [[814, 68], [951, 68], [951, 92], [814, 92]], [[307, 66], [446, 68], [446, 93], [306, 90]], [[673, 67], [723, 67], [723, 93], [673, 93]], [[175, 65], [228, 68], [226, 95], [174, 92]], [[39, 65], [90, 68], [88, 97], [37, 94]], [[528, 65], [580, 65], [580, 94], [528, 94]], [[334, 20], [670, 20], [670, 43], [334, 43]]] +00037951.jpg [[[434, 976], [551, 978], [550, 993], [434, 991]], [[433, 932], [553, 932], [553, 969], [433, 969]], [[30, 522], [98, 522], [98, 545], [30, 545]], [[31, 443], [145, 443], [145, 464], [31, 464]], [[234, 335], [326, 332], [327, 354], [235, 356]], [[124, 252], [436, 252], [436, 284], [124, 284]], [[182, 206], [378, 206], [378, 227], [182, 227]], [[258, 106], [320, 123], [304, 181], [242, 163]], [[28, 65], [33, 65], [33, 71], [28, 71]], [[37, 58], [147, 58], [147, 80], [37, 80]]] +00044782.jpg [[[104, 218], [115, 218], [115, 227], [104, 227]], [[223, 216], [246, 216], [246, 228], [223, 228]], [[163, 216], [182, 216], [182, 229], [163, 229]], [[124, 191], [164, 191], [164, 202], [124, 202]], [[91, 84], [251, 84], [251, 98], [91, 98]], [[73, 63], [278, 63], [278, 78], [73, 78]], [[104, 15], [243, 15], [243, 44], [104, 44]]] +00067516.jpg [[[141, 808], [594, 809], [594, 822], [141, 821]], [[49, 784], [696, 784], [696, 798], [49, 798]], [[579, 751], [667, 751], [667, 764], [579, 764]], [[355, 750], [395, 750], [395, 767], [355, 767]], [[221, 751], [260, 751], [260, 765], [221, 765]], [[477, 750], [501, 750], [501, 768], [477, 768]], [[69, 748], [133, 751], [132, 765], [68, 761]], [[576, 682], [668, 682], [668, 699], [576, 699]], [[476, 682], [518, 682], [518, 700], [476, 700]], [[354, 682], [395, 682], [395, 700], [354, 700]], [[69, 681], [133, 684], [132, 699], [68, 695]], [[220, 679], [243, 682], [241, 700], [218, 697]], [[577, 615], [667, 615], [667, 632], [577, 632]], [[68, 612], [134, 615], [133, 632], [67, 629]], [[476, 614], [500, 614], [500, 633], [476, 633]], [[354, 613], [378, 613], [378, 634], [354, 634]], [[219, 612], [245, 612], [245, 633], [219, 633]], [[578, 547], [667, 547], [667, 564], [578, 564]], [[476, 546], [518, 546], [518, 565], [476, 565]], [[353, 545], [379, 545], [379, 566], [353, 566]], [[219, 545], [245, 545], [245, 566], [219, 566]], [[68, 542], [133, 546], [132, 563], [67, 560]], [[68, 478], [133, 482], [132, 499], [67, 496]], [[586, 481], [664, 481], [664, 497], [586, 497]], [[476, 480], [518, 480], [518, 498], [476, 498]], [[354, 480], [395, 480], [395, 498], [354, 498]], [[219, 479], [245, 479], [245, 500], [219, 500]], [[580, 425], [665, 429], [664, 449], [580, 446]], [[346, 429], [410, 429], [410, 447], [346, 447]], [[68, 426], [150, 429], [149, 449], [67, 447]], [[474, 427], [515, 427], [515, 449], [474, 449]], [[218, 427], [259, 427], [259, 449], [218, 449]], [[283, 398], [478, 399], [478, 419], [283, 418]], [[86, 318], [664, 318], [664, 332], [86, 332]], [[65, 279], [665, 279], [665, 292], [65, 292]], [[458, 210], [584, 210], [584, 224], [458, 224]], [[313, 209], [372, 209], [372, 226], [313, 226]], [[164, 209], [225, 209], [225, 226], [164, 226]], [[505, 151], [539, 151], [539, 166], [505, 166]], [[266, 48], [483, 48], [483, 68], [266, 68]]] +00088568.jpg [[[341, 446], [371, 446], [371, 453], [341, 453]], [[58, 445], [117, 445], [117, 455], [58, 455]], [[552, 433], [571, 433], [571, 440], [552, 440]], [[583, 431], [740, 431], [740, 442], [583, 442]], [[311, 415], [743, 415], [743, 428], [311, 428]], [[311, 377], [736, 377], [736, 390], [311, 390]], [[425, 340], [551, 340], [551, 350], [425, 350]], [[287, 324], [294, 332], [289, 337], [281, 330]], [[276, 294], [348, 296], [347, 311], [276, 309]], [[54, 288], [210, 288], [210, 301], [54, 301]], [[275, 265], [421, 265], [421, 278], [275, 278]], [[56, 264], [248, 264], [248, 277], [56, 277]], [[671, 248], [695, 248], [695, 261], [671, 261]], [[602, 248], [628, 248], [628, 261], [602, 261]], [[533, 248], [557, 248], [557, 261], [533, 261]], [[463, 248], [487, 248], [487, 261], [463, 261]], [[278, 248], [309, 248], [309, 260], [278, 260]], [[55, 240], [142, 240], [142, 254], [55, 254]], [[277, 231], [398, 231], [398, 244], [277, 244]], [[741, 228], [749, 237], [742, 245], [733, 236]], [[665, 230], [700, 230], [700, 244], [665, 244]], [[598, 230], [631, 230], [631, 244], [598, 244]], [[528, 230], [562, 230], [562, 244], [528, 244]], [[459, 230], [492, 230], [492, 244], [459, 244]], [[54, 215], [211, 217], [211, 231], [54, 229]], [[739, 211], [749, 221], [740, 229], [731, 220]], [[663, 214], [704, 214], [704, 228], [663, 228]], [[595, 215], [637, 215], [637, 226], [595, 226]], [[524, 215], [569, 215], [569, 226], [524, 226]], [[454, 215], [495, 215], [495, 226], [454, 226]], [[279, 215], [351, 215], [351, 226], [279, 226]], [[736, 199], [747, 199], [747, 208], [736, 208]], [[668, 197], [700, 197], [700, 208], [668, 208]], [[599, 196], [633, 196], [633, 210], [599, 210]], [[529, 197], [562, 197], [562, 208], [529, 208]], [[461, 197], [491, 197], [491, 208], [461, 208]], [[277, 195], [417, 196], [417, 211], [277, 209]], [[55, 192], [239, 192], [239, 205], [55, 205]], [[665, 181], [703, 181], [703, 192], [665, 192]], [[279, 180], [351, 181], [350, 192], [279, 191]], [[734, 180], [747, 180], [747, 193], [734, 193]], [[597, 180], [634, 180], [634, 191], [597, 191]], [[525, 179], [566, 179], [566, 193], [525, 193]], [[458, 180], [493, 180], [493, 191], [458, 191]], [[55, 170], [142, 170], [142, 184], [55, 184]], [[735, 165], [747, 165], [747, 175], [735, 175]], [[665, 163], [703, 163], [703, 175], [665, 175]], [[598, 163], [634, 163], [634, 175], [598, 175]], [[527, 163], [565, 163], [565, 175], [527, 175]], [[458, 163], [492, 163], [492, 175], [458, 175]], [[279, 162], [398, 162], [398, 176], [279, 176]], [[54, 146], [148, 146], [148, 159], [54, 159]], [[453, 147], [495, 147], [495, 158], [453, 158]], [[731, 143], [748, 146], [745, 161], [728, 158]], [[663, 145], [704, 145], [704, 159], [663, 159]], [[596, 146], [635, 146], [635, 157], [596, 157]], [[522, 145], [566, 142], [567, 157], [523, 159]], [[277, 144], [310, 144], [310, 158], [277, 158]], [[276, 121], [428, 121], [428, 139], [276, 139]], [[52, 120], [232, 121], [232, 139], [52, 138]], [[404, 91], [701, 91], [701, 106], [404, 106]], [[48, 79], [280, 79], [280, 97], [48, 97]], [[325, 69], [744, 70], [744, 84], [325, 83]], [[668, 48], [743, 48], [743, 63], [668, 63]], [[297, 48], [433, 48], [433, 62], [297, 62]]] +00091741.jpg [[[47, 336], [83, 336], [83, 358], [47, 358]], [[99, 211], [257, 211], [257, 230], [99, 230]], [[103, 190], [257, 191], [257, 205], [103, 204]], [[89, 101], [266, 99], [267, 181], [90, 184]], [[94, 48], [262, 55], [260, 114], [91, 107]], [[91, 12], [257, 14], [257, 37], [90, 35]]] +00105313.jpg [[[291, 262], [406, 262], [406, 275], [291, 275]], [[153, 262], [264, 262], [264, 274], [153, 274]], [[11, 258], [73, 261], [72, 274], [11, 272]], [[33, 231], [132, 231], [132, 244], [33, 244]], [[35, 217], [216, 217], [216, 227], [35, 227]], [[33, 200], [146, 200], [146, 213], [33, 213]], [[32, 183], [215, 184], [215, 197], [32, 196]], [[35, 170], [105, 170], [105, 181], [35, 181]], [[35, 155], [124, 155], [124, 164], [35, 164]], [[34, 137], [142, 138], [142, 149], [34, 148]], [[35, 123], [176, 123], [176, 133], [35, 133]], [[33, 106], [176, 106], [176, 119], [33, 119]], [[34, 92], [102, 92], [102, 102], [34, 102]], [[34, 77], [119, 77], [119, 87], [34, 87]], [[32, 60], [120, 60], [120, 73], [32, 73]], [[35, 46], [119, 46], [119, 55], [35, 55]], [[32, 29], [142, 29], [142, 42], [32, 42]], [[25, 12], [147, 12], [147, 24], [25, 24]]] +00134770.jpg [[[388, 646], [456, 646], [456, 656], [388, 656]], [[407, 620], [484, 619], [485, 633], [408, 634]], [[112, 534], [270, 531], [270, 549], [113, 551]], [[111, 502], [443, 497], [443, 514], [112, 519]], [[111, 471], [443, 467], [443, 484], [112, 488]], [[111, 439], [444, 434], [444, 451], [112, 457]], [[111, 409], [442, 405], [442, 421], [112, 425]], [[153, 376], [441, 373], [441, 390], [153, 394]], [[184, 338], [369, 336], [369, 356], [185, 358]], [[75, 98], [515, 104], [513, 218], [74, 212]]] +00145943.jpg [[[394, 248], [746, 279], [731, 449], [379, 418]], [[90, 92], [300, 92], [300, 119], [90, 119]], [[46, 41], [326, 39], [326, 75], [46, 77]]] +00147605.jpg [[[804, 615], [874, 616], [874, 627], [804, 626]], [[516, 607], [784, 605], [784, 628], [516, 629]], [[118, 522], [224, 522], [224, 560], [118, 560]], [[253, 524], [307, 524], [307, 557], [253, 557]], [[715, 501], [900, 505], [900, 538], [714, 534]], [[255, 502], [295, 502], [295, 517], [255, 517]], [[347, 481], [473, 481], [473, 515], [347, 515]], [[252, 484], [295, 484], [295, 499], [252, 499]], [[350, 456], [447, 456], [447, 470], [350, 470]], [[145, 444], [201, 444], [201, 467], [145, 467]], [[728, 371], [878, 371], [878, 420], [728, 420]], [[528, 369], [681, 369], [681, 418], [528, 418]], [[143, 369], [488, 369], [488, 420], [143, 420]], [[744, 315], [871, 315], [871, 336], [744, 336]], [[799, 157], [886, 154], [887, 188], [800, 191]], [[274, 142], [455, 142], [455, 160], [274, 160]], [[738, 116], [894, 119], [893, 157], [737, 153]], [[108, 112], [204, 112], [204, 130], [108, 130]], [[270, 92], [463, 96], [462, 132], [270, 129]]] +00150341.jpg [[[100, 645], [298, 645], [298, 662], [100, 662]], [[115, 617], [288, 617], [288, 631], [115, 631]], [[84, 593], [319, 592], [319, 609], [84, 610]], [[31, 565], [313, 562], [314, 580], [31, 582]], [[444, 560], [461, 560], [461, 569], [444, 569]], [[390, 557], [446, 557], [446, 572], [390, 572]], [[31, 515], [168, 515], [168, 529], [31, 529]], [[33, 490], [110, 490], [110, 504], [33, 504]], [[358, 459], [464, 463], [463, 485], [357, 481]], [[28, 459], [268, 460], [268, 481], [28, 480]], [[339, 439], [421, 444], [421, 460], [338, 455]], [[65, 439], [143, 439], [143, 453], [65, 453]], [[207, 416], [292, 416], [292, 434], [207, 434]], [[319, 408], [441, 413], [440, 438], [318, 433]], [[44, 405], [175, 409], [174, 434], [43, 430]], [[31, 383], [137, 383], [137, 404], [31, 404]]] +00150669.jpg [[[649, 700], [681, 700], [681, 716], [649, 716]], [[517, 685], [549, 685], [549, 720], [517, 720]], [[651, 688], [678, 688], [678, 701], [651, 701]], [[862, 687], [876, 687], [876, 695], [862, 695]], [[922, 675], [938, 675], [938, 685], [922, 685]], [[785, 671], [807, 671], [807, 687], [785, 687]], [[592, 672], [606, 672], [606, 686], [592, 686]], [[722, 679], [732, 669], [742, 678], [731, 688]], [[651, 680], [667, 665], [681, 679], [666, 695]], [[273, 667], [422, 667], [422, 688], [273, 688]], [[136, 666], [203, 666], [203, 688], [136, 688]], [[46, 666], [109, 666], [109, 687], [46, 687]], [[782, 629], [810, 629], [810, 661], [782, 661]], [[645, 627], [685, 627], [685, 665], [645, 665]], [[516, 628], [548, 628], [548, 664], [516, 664]], [[655, 619], [672, 619], [672, 627], [655, 627]], [[598, 617], [605, 624], [599, 629], [592, 622]], [[523, 619], [540, 619], [540, 627], [523, 627]], [[858, 618], [868, 618], [868, 627], [858, 627]], [[727, 618], [735, 618], [735, 627], [727, 627]], [[919, 620], [932, 611], [942, 624], [929, 633]], [[786, 616], [805, 616], [805, 629], [786, 629]], [[373, 604], [420, 604], [420, 619], [373, 619]], [[85, 603], [215, 605], [214, 621], [84, 619]], [[48, 603], [71, 603], [71, 622], [48, 622]], [[788, 561], [806, 561], [806, 572], [788, 572]], [[923, 560], [935, 560], [935, 574], [923, 574]], [[856, 560], [869, 560], [869, 574], [856, 574]], [[62, 554], [410, 554], [410, 568], [62, 568]], [[63, 532], [116, 535], [115, 545], [62, 543]], [[859, 527], [868, 527], [868, 539], [859, 539]], [[925, 526], [934, 526], [934, 540], [925, 540]], [[794, 520], [807, 529], [798, 542], [785, 533]], [[526, 526], [535, 526], [535, 536], [526, 536]], [[262, 513], [395, 513], [395, 526], [262, 526]], [[122, 514], [245, 514], [245, 524], [122, 524]], [[49, 514], [119, 514], [119, 525], [49, 525]], [[755, 492], [828, 492], [828, 507], [755, 507]], [[638, 492], [710, 492], [710, 507], [638, 507]], [[519, 492], [592, 492], [592, 507], [519, 507]], [[85, 450], [123, 450], [123, 461], [85, 461]], [[220, 450], [236, 447], [238, 459], [223, 462]], [[683, 445], [868, 445], [868, 459], [683, 459]], [[562, 445], [666, 445], [666, 459], [562, 459]], [[491, 446], [544, 446], [544, 458], [491, 458]], [[183, 437], [208, 437], [208, 459], [183, 459]], [[52, 431], [72, 438], [64, 462], [44, 455]], [[224, 432], [276, 432], [276, 443], [224, 443]], [[88, 432], [144, 432], [144, 443], [88, 443]], [[506, 383], [616, 382], [616, 397], [506, 398]], [[702, 381], [758, 381], [758, 399], [702, 399]], [[308, 373], [364, 373], [364, 384], [308, 384]], [[92, 373], [167, 373], [167, 384], [92, 384]], [[688, 335], [820, 335], [820, 350], [688, 350]], [[498, 335], [657, 335], [657, 350], [498, 350]], [[208, 316], [244, 316], [244, 331], [208, 331]], [[499, 289], [641, 289], [641, 302], [499, 302]], [[671, 287], [801, 287], [801, 301], [671, 301]], [[670, 241], [816, 241], [816, 255], [670, 255]], [[497, 241], [643, 241], [643, 255], [497, 255]], [[670, 194], [815, 194], [815, 208], [670, 208]], [[498, 194], [643, 194], [643, 208], [498, 208]], [[670, 145], [815, 145], [815, 160], [670, 160]], [[499, 145], [645, 145], [645, 160], [499, 160]], [[489, 103], [546, 103], [546, 120], [489, 120]], [[56, 89], [95, 89], [95, 97], [56, 97]], [[845, 26], [887, 20], [889, 39], [848, 44]], [[26, 20], [700, 20], [700, 37], [26, 37]], [[898, 11], [996, 16], [995, 45], [896, 40]]] +00152568.jpg [[[3, 252], [284, 254], [284, 280], [3, 278]], [[196, 233], [254, 233], [254, 240], [196, 240]], [[49, 229], [90, 229], [90, 240], [49, 240]], [[200, 159], [281, 165], [276, 229], [195, 222]]] +00155628.jpg [[[149, 901], [503, 903], [503, 922], [149, 920]], [[520, 893], [561, 896], [560, 911], [519, 908]], [[61, 885], [81, 885], [81, 894], [61, 894]], [[150, 878], [503, 882], [503, 900], [149, 896]], [[524, 834], [640, 839], [639, 856], [524, 852]], [[70, 834], [185, 835], [185, 853], [69, 852]], [[246, 555], [466, 555], [466, 569], [246, 569]], [[308, 507], [403, 509], [403, 524], [308, 522]], [[244, 482], [459, 484], [459, 502], [244, 500]], [[252, 422], [459, 424], [458, 452], [251, 450]], [[195, 378], [517, 380], [516, 408], [195, 406]], [[474, 194], [624, 196], [624, 210], [473, 208]], [[73, 129], [641, 131], [641, 160], [73, 158]], [[483, 41], [597, 37], [599, 98], [486, 102]], [[68, 25], [135, 16], [139, 43], [72, 52]]] +00173364.jpg [[[8, 178], [57, 178], [57, 200], [8, 200]], [[137, 120], [194, 120], [194, 133], [137, 133]], [[39, 76], [86, 76], [86, 105], [39, 105]], [[249, 20], [310, 20], [310, 36], [249, 36]], [[21, 16], [104, 16], [104, 39], [21, 39]]] +00175503.jpg [[[43, 260], [500, 255], [501, 358], [44, 363]], [[52, 200], [349, 178], [354, 251], [58, 273]]] +00193218.jpg [[[283, 375], [410, 375], [410, 388], [283, 388]], [[172, 375], [221, 375], [221, 389], [172, 389]], [[110, 375], [161, 375], [161, 389], [110, 389]], [[276, 358], [357, 358], [357, 371], [276, 371]], [[171, 359], [220, 359], [220, 370], [171, 370]], [[409, 357], [492, 357], [492, 370], [409, 370]], [[26, 187], [62, 187], [62, 202], [26, 202]], [[501, 185], [557, 185], [557, 199], [501, 199]], [[381, 187], [420, 185], [421, 199], [382, 201]], [[284, 186], [310, 186], [310, 201], [284, 201]], [[174, 186], [196, 186], [196, 201], [174, 201]], [[499, 165], [540, 165], [540, 176], [499, 176]], [[381, 164], [409, 164], [409, 177], [381, 177]], [[262, 163], [302, 163], [302, 177], [262, 177]], [[176, 163], [230, 163], [230, 177], [176, 177]], [[26, 163], [79, 163], [79, 177], [26, 177]], [[387, 140], [488, 140], [488, 153], [387, 153]], [[28, 139], [131, 139], [131, 152], [28, 152]], [[443, 117], [537, 119], [537, 133], [443, 132]], [[346, 119], [405, 119], [405, 130], [346, 130]], [[261, 119], [302, 119], [302, 130], [261, 130]], [[30, 113], [228, 116], [228, 131], [30, 129]], [[131, 91], [394, 94], [394, 109], [131, 105]], [[562, 82], [583, 82], [583, 107], [562, 107]]] +00195033.jpg [[[488, 263], [533, 265], [532, 280], [487, 278]], [[126, 250], [192, 250], [192, 283], [126, 283]], [[338, 249], [362, 249], [362, 266], [338, 266]], [[319, 222], [380, 225], [380, 238], [319, 236]], [[431, 224], [450, 224], [450, 235], [431, 235]], [[365, 203], [538, 203], [538, 216], [365, 216]], [[89, 200], [146, 203], [146, 217], [89, 214]], [[329, 201], [354, 201], [354, 212], [329, 212]], [[371, 181], [449, 181], [449, 194], [371, 194]], [[329, 181], [352, 181], [352, 192], [329, 192]], [[96, 179], [240, 179], [240, 193], [96, 193]], [[456, 162], [555, 162], [555, 175], [456, 175]], [[129, 150], [287, 151], [287, 165], [129, 164]], [[36, 145], [73, 149], [72, 163], [35, 159]], [[527, 146], [552, 146], [552, 155], [527, 155]], [[102, 145], [120, 145], [120, 153], [102, 153]], [[371, 129], [503, 128], [503, 139], [371, 140]], [[99, 126], [193, 126], [193, 139], [99, 139]], [[322, 127], [337, 127], [337, 135], [322, 135]], [[37, 123], [77, 123], [77, 134], [37, 134]], [[324, 106], [337, 106], [337, 115], [324, 115]], [[309, 107], [315, 107], [315, 112], [309, 112]], [[372, 103], [501, 103], [501, 116], [372, 116]], [[349, 105], [360, 105], [360, 114], [349, 114]], [[38, 103], [80, 103], [80, 113], [38, 113]], [[99, 100], [205, 101], [205, 115], [99, 114]], [[306, 90], [317, 90], [317, 97], [306, 97]], [[347, 88], [362, 88], [362, 96], [347, 96]], [[321, 87], [340, 87], [340, 99], [321, 99]], [[358, 84], [513, 82], [513, 95], [358, 97]], [[41, 83], [89, 83], [89, 93], [41, 93]], [[94, 79], [241, 80], [241, 94], [94, 93]], [[313, 66], [394, 66], [394, 79], [313, 79]], [[242, 66], [288, 66], [288, 77], [242, 77]], [[185, 54], [220, 54], [220, 65], [185, 65]], [[469, 48], [547, 48], [547, 61], [469, 61]], [[423, 36], [436, 36], [436, 54], [423, 54]], [[465, 30], [551, 30], [551, 43], [465, 43]], [[207, 21], [329, 23], [328, 41], [207, 39]]] +00208502.jpg [[[247, 566], [282, 566], [282, 573], [247, 573]], [[558, 534], [629, 539], [627, 570], [556, 565]], [[205, 540], [284, 540], [284, 552], [205, 552]], [[143, 513], [189, 513], [189, 525], [143, 525]], [[249, 512], [307, 512], [307, 524], [249, 524]], [[44, 500], [118, 500], [118, 519], [44, 519]], [[467, 491], [556, 491], [556, 508], [467, 508]], [[667, 490], [678, 494], [675, 503], [664, 499]], [[788, 489], [794, 495], [789, 499], [783, 494]], [[726, 491], [737, 491], [737, 501], [726, 501]], [[42, 452], [117, 450], [117, 469], [42, 470]], [[175, 450], [236, 450], [236, 464], [175, 464]], [[614, 407], [638, 407], [638, 422], [614, 422]], [[95, 405], [119, 405], [119, 422], [95, 422]], [[49, 399], [64, 414], [50, 427], [36, 413]], [[209, 401], [226, 401], [226, 415], [209, 415]], [[40, 357], [58, 357], [58, 374], [40, 374]], [[94, 356], [119, 356], [119, 373], [94, 373]], [[188, 341], [246, 339], [247, 361], [189, 364]], [[459, 321], [549, 319], [549, 337], [460, 339]], [[459, 273], [551, 273], [551, 290], [459, 290]], [[563, 272], [735, 269], [735, 286], [564, 289]], [[517, 225], [547, 225], [547, 245], [517, 245]], [[459, 226], [480, 226], [480, 244], [459, 244]], [[621, 187], [673, 187], [673, 201], [621, 201]], [[457, 132], [548, 130], [548, 147], [458, 149]], [[572, 106], [787, 99], [787, 120], [573, 126]], [[122, 48], [290, 48], [290, 97], [122, 97]], [[539, 39], [708, 39], [708, 89], [539, 89]]] +00224225.jpg [[[134, 429], [153, 426], [157, 445], [138, 448]], [[202, 404], [478, 411], [476, 459], [201, 452]], [[205, 230], [469, 230], [469, 390], [205, 390]], [[131, 265], [172, 265], [172, 279], [131, 279]], [[345, 207], [456, 207], [456, 231], [345, 231]], [[199, 189], [346, 196], [344, 239], [197, 232]], [[10, 44], [157, 41], [158, 112], [11, 115]]] +00227746.jpg [[[190, 232], [258, 232], [258, 238], [190, 238]], [[160, 232], [183, 232], [183, 238], [160, 238]], [[123, 232], [150, 232], [150, 238], [123, 238]], [[290, 209], [345, 207], [346, 221], [291, 223]], [[172, 181], [249, 181], [249, 194], [172, 194]], [[143, 178], [165, 180], [162, 208], [140, 206]], [[142, 164], [157, 162], [160, 177], [145, 180]], [[173, 157], [203, 157], [203, 164], [173, 164]], [[200, 154], [347, 154], [347, 167], [200, 167]], [[144, 111], [277, 114], [277, 134], [144, 131]], [[201, 52], [387, 53], [386, 69], [201, 68]], [[139, 47], [191, 45], [192, 62], [140, 64]], [[40, 26], [61, 26], [61, 42], [40, 42]]] +00229605.jpg [[[743, 529], [881, 529], [881, 544], [743, 544]], [[236, 499], [589, 498], [589, 522], [236, 523]], [[6, 498], [227, 498], [227, 522], [6, 522]], [[736, 496], [883, 499], [883, 520], [735, 517]], [[606, 495], [716, 489], [718, 515], [608, 521]], [[4, 245], [863, 230], [864, 288], [5, 303]], [[478, 28], [883, 28], [883, 76], [478, 76]]] +00233011.jpg [[[63, 227], [291, 227], [291, 242], [63, 242]], [[12, 219], [41, 219], [41, 250], [12, 250]], [[61, 177], [119, 177], [119, 195], [61, 195]], [[11, 173], [40, 169], [44, 200], [14, 203]], [[61, 129], [147, 131], [147, 147], [61, 144]], [[12, 124], [43, 124], [43, 154], [12, 154]], [[125, 89], [238, 89], [238, 103], [125, 103]], [[148, 51], [216, 51], [216, 65], [148, 65]], [[258, 46], [353, 50], [352, 69], [257, 65]], [[9, 49], [52, 49], [52, 68], [9, 68]], [[277, 12], [345, 12], [345, 31], [277, 31]], [[28, 11], [73, 11], [73, 31], [28, 31]]] +00233625.jpg [[[375, 397], [632, 399], [632, 443], [375, 440]], [[71, 214], [932, 207], [933, 321], [71, 328]]] +00233634.jpg [[[215, 639], [261, 639], [261, 703], [215, 703]], [[523, 635], [570, 635], [570, 695], [523, 695]], [[643, 523], [682, 523], [682, 568], [643, 568]], [[97, 516], [152, 516], [152, 589], [97, 589]], [[755, 395], [760, 395], [760, 401], [755, 401]], [[26, 395], [32, 395], [32, 400], [26, 400]], [[678, 364], [728, 362], [731, 430], [681, 432]], [[54, 361], [107, 361], [107, 434], [54, 434]], [[78, 208], [155, 208], [155, 280], [78, 280]], [[643, 205], [693, 205], [693, 272], [643, 272]], [[210, 88], [260, 86], [263, 164], [213, 166]], [[363, 48], [426, 45], [430, 115], [367, 118]]] +00234400.jpg [[[446, 421], [738, 421], [738, 438], [446, 438]], [[157, 421], [454, 421], [454, 438], [157, 438]], [[158, 394], [652, 394], [652, 411], [158, 411]], [[40, 391], [127, 391], [127, 412], [40, 412]], [[158, 342], [304, 345], [304, 363], [158, 360]], [[38, 344], [123, 344], [123, 362], [38, 362]], [[520, 295], [703, 295], [703, 314], [520, 314]], [[394, 292], [483, 290], [484, 314], [394, 317]], [[157, 293], [270, 293], [270, 313], [157, 313]], [[37, 293], [125, 293], [125, 313], [37, 313]], [[156, 243], [358, 243], [358, 267], [156, 267]], [[36, 243], [82, 243], [82, 269], [36, 269]], [[29, 152], [158, 152], [158, 175], [29, 175]], [[282, 98], [507, 98], [507, 111], [282, 111]], [[315, 46], [475, 50], [474, 88], [314, 85]], [[518, 51], [663, 53], [662, 67], [517, 65]], [[487, 19], [706, 17], [706, 43], [487, 45]]] +00234883.jpg [[[66, 125], [316, 120], [317, 190], [67, 195]], [[79, 138], [109, 141], [108, 152], [78, 148]], [[72, 120], [120, 120], [120, 130], [72, 130]], [[383, 63], [504, 62], [504, 74], [383, 75]], [[58, 29], [365, 26], [366, 112], [59, 115]], [[387, 28], [501, 26], [501, 45], [387, 47]]] +test_add_0.jpg [[[311, 521], [391, 521], [391, 534], [311, 534]], [[277, 500], [424, 500], [424, 514], [277, 514]], [[261, 446], [437, 446], [437, 459], [261, 459]], [[212, 428], [485, 428], [485, 441], [212, 441]], [[247, 388], [457, 388], [457, 409], [247, 409]], [[222, 328], [474, 328], [474, 372], [222, 372]], [[208, 207], [492, 211], [490, 277], [207, 272]], [[266, 164], [422, 166], [421, 197], [265, 195]], [[18, 20], [201, 18], [201, 43], [18, 45]]] +test_add_1.png [] +test_add_10.png [[[157, 124], [186, 124], [186, 172], [157, 172]], [[65, 117], [95, 117], [95, 168], [65, 168]], [[161, 106], [183, 106], [183, 127], [161, 127]], [[69, 100], [94, 100], [94, 128], [69, 128]], [[117, 46], [154, 45], [157, 174], [121, 175]], [[66, 34], [97, 34], [97, 112], [66, 112]]] +test_add_11.jpg [[[1525, 773], [1564, 756], [1575, 780], [1536, 798]], [[1390, 757], [1483, 757], [1483, 791], [1390, 791]], [[1013, 754], [1207, 754], [1207, 800], [1013, 800]], [[685, 755], [875, 755], [875, 796], [685, 796]], [[356, 753], [566, 747], [567, 793], [358, 798]], [[78, 751], [264, 745], [265, 793], [79, 798]], [[602, 647], [1152, 647], [1152, 703], [602, 703]], [[601, 564], [1148, 555], [1149, 611], [602, 620]], [[598, 480], [1066, 472], [1067, 526], [599, 535]], [[598, 393], [1090, 388], [1090, 439], [599, 444]], [[603, 306], [1057, 306], [1057, 357], [603, 357]], [[357, 184], [1517, 184], [1517, 261], [357, 261]], [[60, 43], [257, 37], [259, 83], [61, 89]], [[1305, 41], [1492, 41], [1492, 87], [1305, 87]], [[973, 40], [1171, 34], [1172, 80], [974, 86]], [[670, 40], [862, 34], [864, 80], [671, 86]], [[363, 34], [558, 34], [558, 85], [363, 85]]] +test_add_12.jpg [[[11, 592], [136, 594], [135, 613], [11, 611]], [[109, 521], [907, 526], [907, 569], [109, 565]], [[635, 451], [902, 448], [903, 478], [635, 481]], [[112, 447], [466, 449], [466, 486], [112, 483]], [[582, 306], [680, 304], [681, 348], [583, 351]], [[369, 261], [565, 266], [563, 357], [367, 353]], [[64, 85], [853, 88], [853, 161], [64, 159]]] +test_add_13.jpg [[[68, 94], [117, 97], [116, 114], [67, 111]]] +test_add_14.jpg [[[30, 97], [235, 95], [236, 127], [31, 129]], [[30, 52], [239, 50], [239, 86], [30, 87]]] +test_add_15.jpg [[[141, 253], [353, 253], [353, 266], [141, 266]], [[205, 214], [406, 219], [406, 232], [204, 227]], [[106, 212], [193, 213], [193, 227], [106, 226]], [[154, 156], [286, 161], [286, 174], [154, 170]], [[148, 136], [305, 142], [305, 156], [147, 150]], [[108, 137], [145, 137], [145, 148], [108, 148]], [[108, 102], [275, 109], [275, 125], [107, 117]], [[107, 72], [245, 79], [245, 96], [106, 88]], [[107, 39], [209, 42], [209, 62], [106, 59]]] +test_add_16.jpg [[[398, 842], [408, 842], [408, 852], [398, 852]], [[382, 742], [746, 742], [746, 776], [382, 776]], [[362, 703], [468, 703], [468, 725], [362, 725]], [[1552, 701], [1576, 701], [1576, 746], [1552, 746]], [[1256, 695], [1442, 695], [1442, 721], [1256, 721]], [[1244, 661], [1448, 661], [1448, 687], [1244, 687]], [[386, 645], [668, 645], [668, 679], [386, 679]], [[1226, 625], [1470, 623], [1470, 651], [1226, 653]], [[360, 604], [580, 604], [580, 629], [360, 629]], [[1202, 592], [1494, 592], [1494, 617], [1202, 617]], [[1166, 556], [1530, 556], [1530, 582], [1166, 582]], [[380, 552], [638, 552], [638, 586], [380, 586]], [[356, 502], [516, 502], [516, 536], [356, 536]], [[774, 260], [1124, 260], [1124, 300], [774, 300]], [[374, 210], [504, 210], [504, 300], [374, 300]], [[776, 212], [1088, 217], [1088, 252], [776, 248]]] +test_add_17.jpg [[[321, 255], [393, 258], [392, 271], [320, 269]], [[307, 222], [411, 228], [411, 241], [306, 236]], [[96, 137], [385, 143], [384, 206], [94, 201]], [[72, 95], [399, 103], [398, 124], [71, 117]], [[68, 76], [224, 79], [223, 93], [67, 90]], [[66, 59], [226, 62], [225, 76], [65, 74]]] +test_add_18.jpg [[[466, 788], [715, 790], [715, 813], [466, 811]], [[553, 752], [665, 757], [663, 791], [552, 786]], [[119, 539], [189, 539], [189, 570], [119, 570]], [[116, 473], [674, 486], [673, 528], [115, 516]], [[121, 429], [669, 441], [668, 470], [121, 457]], [[122, 376], [673, 383], [673, 409], [122, 402]], [[556, 262], [675, 264], [675, 278], [556, 277]], [[165, 259], [335, 259], [335, 273], [165, 273]], [[344, 195], [456, 197], [455, 220], [343, 217]], [[309, 175], [490, 175], [490, 190], [309, 190]], [[255, 128], [537, 131], [537, 169], [254, 165]], [[347, 92], [486, 94], [486, 109], [346, 107]], [[285, 41], [567, 49], [566, 82], [284, 74]], [[236, 32], [266, 32], [266, 60], [236, 60]]] +test_add_19.jpg [[[24, 294], [42, 294], [42, 302], [24, 302]], [[64, 293], [105, 293], [105, 303], [64, 303]], [[145, 287], [163, 287], [163, 304], [145, 304]], [[63, 280], [106, 280], [106, 290], [63, 290]], [[9, 281], [26, 281], [26, 288], [9, 288]], [[220, 279], [245, 279], [245, 291], [220, 291]], [[177, 279], [208, 279], [208, 290], [177, 290]], [[23, 279], [51, 279], [51, 290], [23, 290]], [[145, 278], [162, 278], [162, 292], [145, 292]], [[8, 267], [18, 267], [18, 276], [8, 276]], [[221, 265], [243, 265], [243, 277], [221, 277]], [[24, 265], [47, 265], [47, 277], [24, 277]], [[142, 263], [163, 263], [163, 279], [142, 279]], [[218, 252], [249, 252], [249, 265], [218, 265]], [[65, 253], [131, 253], [131, 263], [65, 263]], [[24, 252], [43, 252], [43, 264], [24, 264]], [[8, 253], [18, 253], [18, 262], [8, 262]], [[8, 240], [17, 240], [17, 249], [8, 249]], [[63, 237], [114, 237], [114, 251], [63, 251]], [[25, 236], [47, 239], [45, 251], [23, 249]], [[144, 234], [166, 237], [163, 253], [142, 249]], [[494, 226], [531, 226], [531, 239], [494, 239]], [[335, 226], [354, 226], [354, 237], [335, 237]], [[288, 226], [314, 226], [314, 237], [288, 237]], [[63, 226], [113, 226], [113, 236], [63, 236]], [[7, 227], [17, 227], [17, 234], [7, 234]], [[221, 225], [248, 225], [248, 235], [221, 235]], [[143, 225], [165, 222], [167, 234], [145, 237]], [[24, 224], [48, 224], [48, 238], [24, 238]], [[495, 213], [524, 213], [524, 224], [495, 224]], [[420, 212], [437, 212], [437, 225], [420, 225]], [[336, 212], [398, 212], [398, 223], [336, 223]], [[292, 212], [320, 212], [320, 223], [292, 223]], [[222, 212], [249, 212], [249, 223], [222, 223]], [[145, 212], [166, 212], [166, 223], [145, 223]], [[61, 211], [113, 209], [114, 222], [62, 224]], [[26, 211], [48, 211], [48, 223], [26, 223]], [[337, 199], [383, 199], [383, 209], [337, 209]], [[65, 200], [87, 200], [87, 207], [65, 207]], [[493, 197], [541, 197], [541, 211], [493, 211]], [[445, 202], [455, 196], [462, 206], [452, 212]], [[178, 198], [205, 198], [205, 208], [178, 208]], [[146, 199], [157, 199], [157, 208], [146, 208]], [[32, 194], [43, 204], [33, 214], [22, 203]], [[422, 193], [440, 201], [432, 215], [415, 207]], [[65, 186], [132, 186], [132, 196], [65, 196]], [[337, 185], [399, 185], [399, 196], [337, 196]], [[445, 190], [456, 182], [465, 191], [454, 200]], [[292, 188], [308, 182], [313, 193], [297, 200]], [[220, 183], [255, 183], [255, 197], [220, 197]], [[142, 184], [158, 184], [158, 197], [142, 197]], [[493, 182], [518, 182], [518, 197], [493, 197]], [[425, 180], [437, 191], [427, 202], [414, 190]], [[32, 179], [42, 189], [32, 199], [22, 189]], [[182, 179], [195, 185], [188, 198], [175, 192]], [[335, 172], [400, 169], [400, 183], [336, 185]], [[492, 170], [519, 170], [519, 185], [492, 185]], [[412, 177], [428, 164], [440, 178], [425, 190]], [[293, 171], [315, 171], [315, 185], [293, 185]], [[220, 170], [251, 170], [251, 184], [220, 184]], [[178, 172], [188, 172], [188, 183], [178, 183]], [[64, 172], [125, 170], [125, 181], [64, 182]], [[454, 168], [464, 176], [454, 185], [445, 176]], [[142, 172], [159, 168], [163, 180], [145, 185]], [[30, 165], [43, 174], [34, 186], [20, 177]], [[493, 160], [523, 160], [523, 170], [493, 170]], [[402, 161], [435, 161], [435, 168], [402, 168]], [[335, 159], [401, 159], [401, 169], [335, 169]], [[296, 159], [325, 159], [325, 170], [296, 170]], [[221, 158], [251, 158], [251, 169], [221, 169]], [[174, 161], [183, 156], [190, 167], [181, 172]], [[145, 158], [162, 158], [162, 170], [145, 170]], [[61, 158], [125, 157], [125, 168], [62, 169]], [[20, 161], [33, 154], [40, 167], [28, 174]], [[492, 143], [542, 143], [542, 157], [492, 157]], [[450, 144], [479, 144], [479, 157], [450, 157]], [[335, 143], [439, 143], [439, 156], [335, 156]], [[294, 143], [327, 143], [327, 157], [294, 157]], [[220, 143], [253, 143], [253, 157], [220, 157]], [[178, 145], [187, 145], [187, 156], [178, 156]], [[63, 144], [104, 144], [104, 155], [63, 155]], [[144, 140], [164, 145], [160, 159], [141, 154]], [[31, 137], [44, 149], [31, 162], [17, 149]], [[286, 135], [291, 135], [291, 140], [286, 140]], [[177, 133], [193, 133], [193, 144], [177, 144]], [[336, 132], [388, 132], [388, 141], [336, 141]], [[492, 131], [525, 131], [525, 141], [492, 141]], [[450, 131], [477, 131], [477, 141], [450, 141]], [[292, 131], [321, 131], [321, 141], [292, 141]], [[218, 132], [255, 130], [256, 141], [219, 144]], [[63, 131], [95, 131], [95, 141], [63, 141]], [[417, 130], [437, 130], [437, 141], [417, 141]], [[145, 130], [159, 130], [159, 143], [145, 143]], [[30, 124], [43, 133], [32, 147], [19, 138]], [[493, 118], [535, 118], [535, 129], [493, 129]], [[336, 118], [388, 118], [388, 129], [336, 129]], [[218, 118], [255, 118], [255, 128], [218, 128]], [[451, 117], [478, 117], [478, 129], [451, 129]], [[418, 117], [438, 117], [438, 130], [418, 130]], [[177, 116], [209, 116], [209, 130], [177, 130]], [[145, 117], [162, 117], [162, 130], [145, 130]], [[62, 116], [88, 116], [88, 131], [62, 131]], [[19, 121], [33, 111], [43, 124], [29, 134]], [[491, 107], [523, 107], [523, 113], [491, 113]], [[449, 107], [477, 107], [477, 113], [449, 113]], [[420, 107], [436, 107], [436, 113], [420, 113]], [[295, 107], [319, 107], [319, 114], [295, 114]], [[220, 107], [242, 107], [242, 113], [220, 113]], [[176, 107], [203, 107], [203, 113], [176, 113]], [[145, 107], [161, 107], [161, 114], [145, 114]], [[334, 105], [372, 105], [372, 114], [334, 114]], [[63, 106], [86, 106], [86, 113], [63, 113]], [[483, 89], [522, 89], [522, 99], [483, 99]], [[331, 88], [380, 88], [380, 99], [331, 99]], [[276, 88], [325, 88], [325, 99], [276, 99]], [[214, 88], [246, 88], [246, 99], [214, 99]], [[411, 86], [474, 86], [474, 100], [411, 100]], [[6, 86], [102, 86], [102, 100], [6, 100]], [[415, 66], [461, 66], [461, 77], [415, 77]], [[288, 66], [333, 66], [333, 77], [288, 77]], [[157, 64], [206, 64], [206, 78], [157, 78]], [[416, 48], [523, 49], [523, 63], [415, 62]], [[288, 49], [375, 49], [375, 63], [288, 63]], [[159, 49], [269, 49], [269, 62], [159, 62]], [[24, 53], [36, 46], [45, 59], [33, 67]], [[416, 36], [481, 36], [481, 46], [416, 46]], [[25, 38], [39, 32], [46, 46], [33, 52]], [[157, 34], [205, 34], [205, 47], [157, 47]], [[412, 4], [527, 4], [527, 17], [412, 17]], [[146, 4], [345, 2], [345, 15], [146, 17]]] +test_add_20.jpg [[[31, 346], [605, 346], [605, 370], [31, 370]], [[217, 294], [510, 294], [510, 322], [217, 322]], [[473, 271], [525, 271], [525, 286], [473, 286]], [[220, 267], [287, 267], [287, 286], [220, 286]], [[219, 239], [484, 239], [484, 263], [219, 263]], [[221, 217], [303, 217], [303, 234], [221, 234]], [[402, 192], [417, 192], [417, 205], [402, 205]], [[222, 187], [341, 187], [341, 207], [222, 207]], [[221, 162], [287, 162], [287, 180], [221, 180]], [[375, 122], [475, 124], [475, 146], [375, 143]], [[222, 124], [356, 122], [356, 143], [222, 146]], [[218, 81], [352, 84], [352, 116], [218, 113]], [[440, 35], [605, 35], [605, 60], [440, 60]], [[72, 16], [398, 16], [398, 44], [72, 44]]] +test_add_3.jpg [[[169, 327], [337, 326], [337, 341], [169, 342]], [[170, 288], [307, 290], [307, 312], [170, 310]], [[171, 221], [323, 221], [323, 234], [171, 234]], [[340, 221], [449, 217], [449, 231], [341, 234]], [[169, 201], [372, 201], [372, 214], [169, 214]], [[170, 183], [418, 183], [418, 196], [170, 196]], [[170, 149], [416, 149], [416, 163], [170, 163]], [[171, 119], [418, 119], [418, 140], [171, 140]], [[326, 64], [478, 64], [478, 91], [326, 91]], [[173, 64], [306, 60], [306, 89], [174, 93]]] +test_add_4.png [] +test_add_5.png [[[48, 164], [108, 164], [108, 174], [48, 174]], [[52, 121], [169, 121], [169, 134], [52, 134]], [[50, 102], [165, 102], [165, 118], [50, 118]], [[52, 83], [164, 83], [164, 100], [52, 100]], [[51, 68], [166, 68], [166, 84], [51, 84]], [[51, 50], [145, 47], [145, 64], [52, 67]]] +test_add_6.jpg [[[123, 223], [219, 227], [218, 251], [122, 247]], [[172, 172], [186, 186], [172, 200], [158, 186]]] +test_add_7.jpg [[[48, 938], [174, 936], [174, 962], [48, 964]], [[227, 873], [629, 876], [628, 953], [226, 949]], [[56, 745], [638, 745], [638, 790], [56, 790]], [[150, 674], [545, 678], [544, 721], [150, 718]], [[73, 504], [633, 504], [633, 601], [73, 601]], [[59, 270], [655, 279], [652, 441], [56, 432]], [[513, 193], [553, 193], [553, 223], [513, 223]], [[61, 175], [532, 175], [532, 239], [61, 239]], [[533, 178], [642, 178], [642, 236], [533, 236]]] +test_add_8.jpg [[[251, 586], [454, 580], [454, 606], [252, 613]], [[107, 533], [457, 527], [457, 560], [108, 566]], [[336, 494], [384, 494], [384, 507], [336, 507]], [[27, 307], [355, 297], [356, 320], [28, 330]], [[22, 259], [445, 251], [445, 274], [23, 282]], [[78, 209], [445, 205], [445, 225], [78, 229]], [[160, 23], [319, 30], [317, 79], [158, 72]]] +test_add_9.png [[[266, 687], [486, 687], [486, 696], [266, 696]], [[196, 668], [554, 668], [554, 681], [196, 681]], [[154, 596], [597, 596], [597, 606], [154, 606]], [[215, 578], [541, 578], [541, 588], [215, 588]], [[85, 543], [665, 543], [665, 553], [85, 553]], [[96, 522], [653, 522], [653, 535], [96, 535]], [[362, 449], [389, 449], [389, 460], [362, 460]], [[238, 376], [513, 376], [513, 389], [238, 389]], [[177, 356], [574, 356], [574, 368], [177, 368]], [[344, 281], [408, 283], [407, 297], [343, 294]], [[257, 205], [493, 205], [493, 219], [257, 219]]] diff --git a/tests/results/det_results_gpu_trt_fp16.txt b/tests/results/det_results_gpu_trt_fp16.txt new file mode 100644 index 0000000000000000000000000000000000000000..191bdaf7807dad9129eb965f4ac81dadc9572af6 --- /dev/null +++ b/tests/results/det_results_gpu_trt_fp16.txt @@ -0,0 +1,49 @@ +00008790.jpg [[[209, 406], [280, 406], [280, 419], [209, 419]], [[60, 398], [105, 398], [105, 411], [60, 411]], [[198, 389], [291, 389], [291, 402], [198, 402]], [[162, 391], [173, 391], [173, 401], [162, 401]], [[35, 380], [133, 380], [133, 393], [35, 393]], [[199, 371], [292, 371], [292, 384], [199, 384]], [[218, 310], [272, 310], [272, 324], [218, 324]], [[162, 305], [172, 305], [172, 314], [162, 314]], [[371, 302], [436, 302], [436, 316], [371, 316]], [[31, 302], [134, 301], [134, 315], [31, 316]], [[223, 292], [269, 292], [269, 306], [223, 306]], [[60, 225], [104, 225], [104, 236], [60, 236]], [[218, 223], [272, 223], [272, 237], [218, 237]], [[162, 219], [173, 219], [173, 227], [162, 227]], [[33, 207], [131, 207], [131, 220], [33, 220]], [[223, 206], [269, 206], [269, 220], [223, 220]], [[74, 146], [383, 146], [383, 159], [74, 159]], [[54, 120], [117, 120], [117, 134], [54, 134]], [[74, 51], [296, 51], [296, 65], [74, 65]], [[56, 18], [116, 18], [116, 32], [56, 32]]] +00018946.jpg [[[441, 328], [474, 328], [474, 339], [441, 339]], [[86, 284], [141, 286], [140, 307], [85, 305]], [[302, 279], [377, 279], [377, 297], [302, 297]], [[197, 265], [281, 274], [279, 293], [195, 284]], [[198, 197], [452, 219], [450, 242], [196, 220]], [[343, 182], [376, 182], [376, 192], [343, 192]], [[199, 164], [340, 171], [339, 192], [198, 185]], [[177, 101], [415, 118], [413, 145], [175, 128]]] +00034387.jpg [[[265, 460], [740, 460], [740, 484], [265, 484]], [[348, 417], [420, 417], [420, 443], [348, 443]], [[545, 418], [568, 418], [568, 442], [545, 442]], [[685, 417], [710, 417], [710, 443], [685, 443]], [[175, 415], [226, 415], [226, 443], [175, 443]], [[874, 414], [908, 414], [908, 446], [874, 446]], [[56, 417], [74, 417], [74, 442], [56, 442]], [[856, 373], [925, 373], [925, 400], [856, 400]], [[348, 372], [418, 372], [418, 397], [348, 397]], [[674, 372], [723, 372], [723, 401], [674, 401]], [[539, 373], [570, 373], [570, 400], [539, 400]], [[151, 365], [228, 369], [226, 402], [149, 398]], [[56, 372], [74, 372], [74, 397], [56, 397]], [[857, 329], [925, 329], [925, 355], [857, 355]], [[351, 330], [419, 330], [419, 356], [351, 356]], [[674, 328], [723, 328], [723, 356], [674, 356]], [[541, 329], [570, 329], [570, 357], [541, 357]], [[171, 327], [227, 324], [229, 355], [173, 358]], [[57, 330], [74, 330], [74, 356], [57, 356]], [[298, 327], [316, 327], [316, 334], [298, 334]], [[855, 286], [925, 286], [925, 312], [855, 312]], [[674, 286], [723, 286], [723, 313], [674, 313]], [[346, 286], [426, 283], [427, 313], [347, 316]], [[540, 285], [569, 285], [569, 312], [540, 312]], [[172, 282], [226, 282], [226, 313], [172, 313]], [[56, 287], [73, 287], [73, 312], [56, 312]], [[857, 242], [925, 242], [925, 268], [857, 268]], [[348, 242], [460, 242], [460, 268], [348, 268]], [[156, 242], [227, 242], [227, 269], [156, 269]], [[674, 241], [724, 241], [724, 269], [674, 269]], [[531, 241], [572, 241], [572, 270], [531, 270]], [[56, 242], [74, 242], [74, 268], [56, 268]], [[855, 197], [925, 200], [924, 226], [854, 224]], [[674, 198], [726, 198], [726, 226], [674, 226]], [[344, 200], [430, 195], [432, 224], [346, 230]], [[176, 197], [227, 197], [227, 225], [176, 225]], [[56, 200], [73, 200], [73, 226], [56, 226]], [[527, 194], [576, 194], [576, 226], [527, 226]], [[349, 155], [419, 155], [419, 181], [349, 181]], [[854, 154], [925, 154], [925, 180], [854, 180]], [[176, 154], [226, 154], [226, 183], [176, 183]], [[670, 153], [723, 153], [723, 181], [670, 181]], [[538, 154], [571, 154], [571, 182], [538, 182]], [[56, 156], [74, 156], [74, 182], [56, 182]], [[349, 111], [419, 111], [419, 137], [349, 137]], [[174, 111], [227, 111], [227, 139], [174, 139]], [[546, 113], [564, 113], [564, 137], [546, 137]], [[52, 112], [75, 112], [75, 139], [52, 139]], [[639, 108], [727, 105], [728, 138], [640, 141]], [[817, 103], [927, 110], [925, 139], [815, 132]], [[814, 68], [951, 68], [951, 92], [814, 92]], [[307, 66], [446, 68], [446, 93], [306, 90]], [[673, 67], [723, 67], [723, 93], [673, 93]], [[175, 65], [228, 68], [226, 95], [174, 92]], [[39, 65], [90, 68], [88, 97], [37, 94]], [[528, 65], [580, 65], [580, 94], [528, 94]], [[334, 20], [670, 20], [670, 43], [334, 43]]] +00037951.jpg [[[434, 976], [551, 978], [550, 993], [434, 991]], [[433, 932], [553, 932], [553, 969], [433, 969]], [[30, 522], [98, 522], [98, 545], [30, 545]], [[31, 443], [145, 443], [145, 464], [31, 464]], [[234, 335], [326, 332], [327, 354], [235, 356]], [[124, 252], [436, 252], [436, 284], [124, 284]], [[182, 206], [378, 206], [378, 227], [182, 227]], [[258, 106], [320, 123], [304, 181], [242, 163]], [[28, 65], [33, 65], [33, 71], [28, 71]], [[37, 58], [147, 58], [147, 80], [37, 80]]] +00044782.jpg [[[104, 218], [115, 218], [115, 227], [104, 227]], [[223, 216], [246, 216], [246, 228], [223, 228]], [[163, 216], [182, 216], [182, 229], [163, 229]], [[124, 191], [164, 191], [164, 202], [124, 202]], [[91, 84], [251, 84], [251, 98], [91, 98]], [[73, 63], [278, 63], [278, 78], [73, 78]], [[104, 15], [243, 15], [243, 44], [104, 44]]] +00067516.jpg [[[141, 808], [594, 809], [594, 822], [141, 821]], [[49, 784], [696, 784], [696, 798], [49, 798]], [[579, 751], [667, 751], [667, 764], [579, 764]], [[355, 750], [395, 750], [395, 767], [355, 767]], [[221, 751], [260, 751], [260, 765], [221, 765]], [[477, 750], [501, 750], [501, 768], [477, 768]], [[69, 748], [133, 751], [132, 765], [68, 761]], [[576, 682], [668, 682], [668, 699], [576, 699]], [[476, 682], [518, 682], [518, 700], [476, 700]], [[354, 682], [395, 682], [395, 700], [354, 700]], [[69, 681], [133, 684], [132, 699], [68, 695]], [[220, 679], [243, 682], [241, 700], [218, 697]], [[577, 615], [667, 615], [667, 632], [577, 632]], [[68, 612], [134, 615], [133, 632], [67, 629]], [[476, 614], [500, 614], [500, 633], [476, 633]], [[354, 613], [378, 613], [378, 634], [354, 634]], [[219, 612], [245, 612], [245, 633], [219, 633]], [[578, 547], [667, 547], [667, 564], [578, 564]], [[476, 546], [518, 546], [518, 565], [476, 565]], [[353, 545], [379, 545], [379, 566], [353, 566]], [[219, 545], [245, 545], [245, 566], [219, 566]], [[68, 542], [133, 546], [132, 563], [67, 560]], [[68, 478], [133, 482], [132, 499], [67, 496]], [[586, 481], [664, 481], [664, 497], [586, 497]], [[476, 480], [518, 480], [518, 498], [476, 498]], [[354, 480], [395, 480], [395, 498], [354, 498]], [[219, 479], [245, 479], [245, 500], [219, 500]], [[580, 425], [665, 429], [664, 449], [580, 446]], [[346, 429], [410, 429], [410, 447], [346, 447]], [[68, 426], [150, 429], [149, 449], [67, 447]], [[474, 427], [515, 427], [515, 449], [474, 449]], [[218, 427], [259, 427], [259, 449], [218, 449]], [[283, 398], [478, 399], [478, 419], [283, 418]], [[86, 318], [664, 318], [664, 332], [86, 332]], [[65, 279], [665, 279], [665, 292], [65, 292]], [[458, 210], [584, 210], [584, 224], [458, 224]], [[313, 209], [372, 209], [372, 226], [313, 226]], [[164, 209], [225, 209], [225, 226], [164, 226]], [[505, 151], [539, 151], [539, 166], [505, 166]], [[266, 48], [483, 48], [483, 68], [266, 68]]] +00088568.jpg [[[341, 446], [371, 446], [371, 453], [341, 453]], [[58, 445], [117, 445], [117, 455], [58, 455]], [[552, 433], [571, 433], [571, 440], [552, 440]], [[583, 431], [740, 431], [740, 442], [583, 442]], [[311, 415], [743, 415], [743, 428], [311, 428]], [[311, 377], [736, 377], [736, 390], [311, 390]], [[425, 340], [551, 340], [551, 350], [425, 350]], [[287, 324], [294, 332], [289, 337], [281, 330]], [[276, 294], [348, 296], [347, 311], [276, 309]], [[54, 288], [210, 288], [210, 301], [54, 301]], [[275, 265], [421, 265], [421, 278], [275, 278]], [[56, 264], [248, 264], [248, 277], [56, 277]], [[671, 248], [695, 248], [695, 261], [671, 261]], [[602, 248], [628, 248], [628, 261], [602, 261]], [[533, 248], [557, 248], [557, 261], [533, 261]], [[463, 248], [487, 248], [487, 261], [463, 261]], [[278, 248], [309, 248], [309, 260], [278, 260]], [[55, 240], [142, 240], [142, 254], [55, 254]], [[277, 231], [398, 231], [398, 244], [277, 244]], [[741, 228], [749, 237], [742, 245], [733, 236]], [[665, 230], [700, 230], [700, 244], [665, 244]], [[598, 230], [631, 230], [631, 244], [598, 244]], [[528, 230], [562, 230], [562, 244], [528, 244]], [[459, 230], [492, 230], [492, 244], [459, 244]], [[54, 215], [211, 217], [211, 231], [54, 229]], [[739, 211], [749, 221], [740, 229], [731, 220]], [[663, 214], [704, 214], [704, 228], [663, 228]], [[595, 215], [637, 215], [637, 226], [595, 226]], [[524, 215], [568, 215], [568, 226], [524, 226]], [[454, 215], [495, 215], [495, 226], [454, 226]], [[279, 215], [351, 215], [351, 226], [279, 226]], [[736, 199], [747, 199], [747, 208], [736, 208]], [[668, 197], [700, 197], [700, 208], [668, 208]], [[599, 196], [633, 196], [633, 210], [599, 210]], [[529, 197], [562, 197], [562, 208], [529, 208]], [[461, 197], [491, 197], [491, 208], [461, 208]], [[277, 195], [417, 196], [417, 211], [277, 209]], [[55, 192], [239, 192], [239, 205], [55, 205]], [[665, 181], [703, 181], [703, 192], [665, 192]], [[279, 180], [351, 181], [350, 192], [279, 191]], [[734, 180], [747, 180], [747, 193], [734, 193]], [[597, 180], [634, 180], [634, 191], [597, 191]], [[525, 179], [566, 179], [566, 193], [525, 193]], [[458, 180], [493, 180], [493, 191], [458, 191]], [[55, 170], [142, 170], [142, 184], [55, 184]], [[735, 165], [747, 165], [747, 175], [735, 175]], [[665, 163], [703, 163], [703, 175], [665, 175]], [[598, 163], [634, 163], [634, 175], [598, 175]], [[527, 163], [565, 163], [565, 175], [527, 175]], [[458, 163], [492, 163], [492, 175], [458, 175]], [[279, 162], [398, 162], [398, 176], [279, 176]], [[54, 146], [148, 146], [148, 159], [54, 159]], [[453, 147], [495, 147], [495, 158], [453, 158]], [[731, 143], [748, 146], [745, 161], [728, 158]], [[663, 145], [704, 145], [704, 159], [663, 159]], [[596, 146], [635, 146], [635, 157], [596, 157]], [[522, 145], [566, 142], [567, 157], [523, 159]], [[277, 144], [310, 144], [310, 158], [277, 158]], [[276, 121], [428, 121], [428, 139], [276, 139]], [[52, 120], [232, 121], [232, 139], [52, 138]], [[404, 91], [701, 91], [701, 106], [404, 106]], [[48, 79], [280, 79], [280, 97], [48, 97]], [[325, 69], [744, 70], [744, 84], [325, 83]], [[668, 48], [743, 48], [743, 63], [668, 63]], [[297, 48], [433, 48], [433, 62], [297, 62]]] +00091741.jpg [[[47, 336], [83, 336], [83, 358], [47, 358]], [[98, 211], [257, 209], [257, 229], [98, 231]], [[103, 190], [257, 191], [257, 205], [103, 204]], [[89, 101], [266, 99], [267, 181], [90, 184]], [[94, 48], [262, 55], [260, 114], [91, 107]], [[91, 12], [257, 14], [257, 37], [90, 35]]] +00105313.jpg [[[291, 262], [406, 262], [406, 275], [291, 275]], [[153, 262], [264, 262], [264, 274], [153, 274]], [[11, 258], [73, 261], [72, 274], [11, 272]], [[33, 231], [132, 231], [132, 244], [33, 244]], [[35, 217], [216, 217], [216, 227], [35, 227]], [[33, 200], [146, 200], [146, 213], [33, 213]], [[32, 183], [215, 184], [215, 197], [32, 196]], [[35, 170], [105, 170], [105, 181], [35, 181]], [[35, 155], [124, 155], [124, 164], [35, 164]], [[34, 137], [142, 138], [142, 149], [34, 148]], [[35, 123], [176, 123], [176, 133], [35, 133]], [[33, 106], [176, 106], [176, 119], [33, 119]], [[34, 92], [102, 92], [102, 102], [34, 102]], [[34, 77], [119, 77], [119, 87], [34, 87]], [[32, 60], [120, 60], [120, 73], [32, 73]], [[35, 46], [119, 46], [119, 55], [35, 55]], [[32, 29], [142, 29], [142, 42], [32, 42]], [[25, 12], [147, 12], [147, 24], [25, 24]]] +00134770.jpg [[[388, 646], [456, 646], [456, 656], [388, 656]], [[407, 620], [484, 619], [485, 633], [408, 634]], [[112, 534], [270, 531], [270, 549], [113, 551]], [[111, 502], [443, 497], [443, 514], [112, 519]], [[111, 471], [443, 467], [443, 484], [112, 488]], [[111, 439], [444, 434], [444, 451], [112, 457]], [[111, 409], [442, 405], [442, 421], [112, 425]], [[153, 376], [441, 373], [441, 390], [153, 394]], [[184, 338], [369, 336], [369, 356], [185, 358]], [[75, 98], [515, 104], [513, 218], [74, 212]]] +00145943.jpg [[[394, 248], [746, 279], [731, 449], [379, 418]], [[90, 92], [300, 92], [300, 119], [90, 119]], [[46, 41], [326, 39], [326, 75], [46, 77]]] +00147605.jpg [[[805, 616], [874, 616], [874, 627], [805, 627]], [[516, 607], [784, 605], [784, 628], [516, 629]], [[118, 522], [224, 522], [224, 560], [118, 560]], [[253, 524], [307, 524], [307, 557], [253, 557]], [[715, 501], [900, 505], [900, 538], [714, 534]], [[255, 502], [295, 502], [295, 517], [255, 517]], [[347, 481], [473, 481], [473, 515], [347, 515]], [[252, 484], [295, 484], [295, 499], [252, 499]], [[350, 456], [447, 456], [447, 470], [350, 470]], [[145, 444], [201, 444], [201, 467], [145, 467]], [[728, 371], [878, 371], [878, 420], [728, 420]], [[528, 369], [681, 369], [681, 418], [528, 418]], [[143, 369], [488, 369], [488, 420], [143, 420]], [[744, 315], [871, 315], [871, 336], [744, 336]], [[799, 157], [886, 154], [887, 188], [800, 191]], [[274, 142], [455, 142], [455, 160], [274, 160]], [[738, 116], [894, 119], [893, 157], [737, 153]], [[108, 112], [204, 112], [204, 130], [108, 130]], [[270, 92], [463, 96], [462, 132], [270, 129]]] +00150341.jpg [[[100, 644], [297, 644], [297, 661], [100, 661]], [[115, 617], [288, 617], [288, 631], [115, 631]], [[84, 593], [319, 592], [319, 609], [84, 610]], [[31, 565], [313, 562], [314, 580], [31, 582]], [[444, 560], [461, 560], [461, 569], [444, 569]], [[390, 557], [446, 557], [446, 572], [390, 572]], [[31, 515], [168, 515], [168, 529], [31, 529]], [[33, 490], [110, 490], [110, 504], [33, 504]], [[358, 459], [464, 463], [463, 485], [357, 481]], [[28, 459], [268, 460], [268, 481], [28, 480]], [[339, 439], [421, 444], [421, 460], [338, 455]], [[65, 439], [143, 439], [143, 453], [65, 453]], [[207, 416], [292, 416], [292, 434], [207, 434]], [[319, 408], [441, 413], [440, 438], [318, 433]], [[44, 405], [175, 409], [174, 434], [43, 430]], [[31, 383], [137, 383], [137, 404], [31, 404]]] +00150669.jpg [[[649, 700], [681, 700], [681, 716], [649, 716]], [[517, 685], [549, 685], [549, 720], [517, 720]], [[651, 688], [678, 688], [678, 701], [651, 701]], [[862, 687], [876, 687], [876, 695], [862, 695]], [[922, 675], [938, 675], [938, 685], [922, 685]], [[785, 671], [807, 671], [807, 687], [785, 687]], [[592, 672], [606, 672], [606, 686], [592, 686]], [[722, 679], [732, 669], [742, 678], [731, 688]], [[651, 680], [667, 665], [681, 679], [666, 695]], [[273, 667], [422, 667], [422, 688], [273, 688]], [[47, 668], [108, 668], [108, 686], [47, 686]], [[136, 666], [203, 666], [203, 688], [136, 688]], [[782, 629], [810, 629], [810, 661], [782, 661]], [[645, 627], [685, 627], [685, 665], [645, 665]], [[516, 628], [548, 628], [548, 664], [516, 664]], [[655, 619], [672, 619], [672, 627], [655, 627]], [[598, 617], [605, 624], [599, 629], [592, 622]], [[523, 619], [540, 619], [540, 627], [523, 627]], [[858, 618], [868, 618], [868, 627], [858, 627]], [[727, 618], [735, 618], [735, 627], [727, 627]], [[919, 620], [932, 611], [942, 624], [929, 633]], [[786, 616], [805, 616], [805, 629], [786, 629]], [[373, 604], [420, 604], [420, 619], [373, 619]], [[85, 603], [215, 605], [214, 621], [84, 619]], [[48, 603], [71, 603], [71, 622], [48, 622]], [[788, 561], [806, 561], [806, 572], [788, 572]], [[923, 560], [935, 560], [935, 574], [923, 574]], [[856, 560], [869, 560], [869, 574], [856, 574]], [[62, 554], [410, 554], [410, 568], [62, 568]], [[63, 532], [116, 535], [115, 545], [62, 543]], [[859, 527], [868, 527], [868, 539], [859, 539]], [[925, 526], [934, 526], [934, 540], [925, 540]], [[794, 520], [807, 529], [798, 542], [785, 533]], [[526, 526], [535, 526], [535, 536], [526, 536]], [[262, 513], [395, 513], [395, 526], [262, 526]], [[122, 514], [245, 514], [245, 524], [122, 524]], [[49, 514], [119, 514], [119, 525], [49, 525]], [[755, 492], [828, 492], [828, 507], [755, 507]], [[638, 492], [710, 492], [710, 507], [638, 507]], [[519, 492], [592, 492], [592, 507], [519, 507]], [[85, 450], [123, 450], [123, 461], [85, 461]], [[220, 450], [236, 447], [238, 459], [223, 462]], [[683, 445], [868, 445], [868, 459], [683, 459]], [[562, 445], [666, 445], [666, 459], [562, 459]], [[491, 446], [544, 446], [544, 458], [491, 458]], [[183, 437], [208, 437], [208, 459], [183, 459]], [[52, 431], [72, 438], [64, 462], [44, 455]], [[224, 432], [276, 432], [276, 443], [224, 443]], [[88, 432], [144, 432], [144, 443], [88, 443]], [[506, 383], [616, 382], [616, 397], [506, 398]], [[702, 381], [758, 381], [758, 399], [702, 399]], [[308, 373], [364, 373], [364, 384], [308, 384]], [[92, 373], [167, 373], [167, 384], [92, 384]], [[688, 335], [820, 335], [820, 350], [688, 350]], [[498, 335], [657, 335], [657, 350], [498, 350]], [[208, 316], [244, 316], [244, 331], [208, 331]], [[499, 289], [641, 289], [641, 302], [499, 302]], [[671, 287], [801, 287], [801, 301], [671, 301]], [[670, 241], [816, 241], [816, 255], [670, 255]], [[497, 241], [643, 241], [643, 255], [497, 255]], [[670, 194], [815, 194], [815, 208], [670, 208]], [[498, 194], [643, 194], [643, 208], [498, 208]], [[670, 145], [815, 145], [815, 160], [670, 160]], [[499, 145], [645, 145], [645, 160], [499, 160]], [[489, 103], [546, 103], [546, 120], [489, 120]], [[56, 89], [95, 89], [95, 97], [56, 97]], [[845, 26], [887, 20], [889, 39], [848, 44]], [[26, 20], [700, 20], [700, 37], [26, 37]], [[898, 11], [996, 16], [995, 45], [896, 40]]] +00152568.jpg [[[3, 252], [284, 254], [284, 280], [3, 278]], [[196, 233], [254, 233], [254, 240], [196, 240]], [[49, 229], [90, 229], [90, 240], [49, 240]], [[200, 159], [281, 165], [276, 229], [195, 222]]] +00155628.jpg [[[149, 901], [503, 903], [503, 922], [149, 920]], [[520, 893], [561, 896], [560, 911], [519, 908]], [[61, 885], [81, 885], [81, 894], [61, 894]], [[150, 878], [503, 882], [503, 900], [149, 896]], [[524, 834], [640, 839], [639, 856], [524, 852]], [[70, 834], [185, 835], [185, 853], [69, 852]], [[246, 555], [466, 555], [466, 569], [246, 569]], [[308, 507], [403, 509], [403, 524], [308, 522]], [[244, 482], [459, 484], [459, 502], [244, 500]], [[252, 422], [459, 424], [458, 452], [251, 450]], [[195, 378], [517, 380], [516, 408], [195, 406]], [[474, 194], [624, 196], [624, 210], [473, 208]], [[73, 129], [641, 131], [641, 160], [73, 158]], [[483, 41], [597, 37], [599, 98], [486, 102]], [[68, 25], [135, 16], [139, 43], [72, 52]]] +00173364.jpg [[[8, 178], [56, 178], [56, 200], [8, 200]], [[137, 120], [194, 120], [194, 133], [137, 133]], [[39, 76], [86, 76], [86, 105], [39, 105]], [[249, 20], [310, 20], [310, 36], [249, 36]], [[21, 16], [104, 16], [104, 39], [21, 39]]] +00175503.jpg [[[43, 260], [500, 255], [501, 358], [44, 363]], [[52, 200], [349, 178], [354, 251], [58, 273]]] +00193218.jpg [[[283, 375], [410, 375], [410, 388], [283, 388]], [[172, 375], [221, 375], [221, 389], [172, 389]], [[110, 375], [161, 375], [161, 389], [110, 389]], [[276, 358], [357, 358], [357, 371], [276, 371]], [[171, 359], [220, 359], [220, 370], [171, 370]], [[409, 357], [492, 357], [492, 370], [409, 370]], [[26, 187], [62, 187], [62, 202], [26, 202]], [[501, 185], [557, 185], [557, 199], [501, 199]], [[381, 187], [420, 185], [421, 199], [382, 201]], [[284, 186], [310, 186], [310, 201], [284, 201]], [[174, 186], [196, 186], [196, 201], [174, 201]], [[499, 165], [540, 165], [540, 176], [499, 176]], [[381, 164], [409, 164], [409, 177], [381, 177]], [[262, 163], [302, 163], [302, 177], [262, 177]], [[176, 163], [230, 163], [230, 177], [176, 177]], [[26, 163], [79, 163], [79, 177], [26, 177]], [[387, 140], [488, 140], [488, 153], [387, 153]], [[28, 139], [131, 139], [131, 152], [28, 152]], [[443, 117], [537, 119], [537, 133], [443, 132]], [[346, 119], [405, 119], [405, 130], [346, 130]], [[261, 119], [303, 119], [303, 130], [261, 130]], [[30, 113], [228, 116], [228, 131], [30, 129]], [[131, 91], [394, 94], [394, 109], [131, 105]], [[562, 82], [583, 82], [583, 107], [562, 107]]] +00195033.jpg [[[488, 263], [533, 265], [532, 280], [487, 278]], [[126, 250], [192, 250], [192, 283], [126, 283]], [[338, 249], [362, 249], [362, 266], [338, 266]], [[319, 222], [380, 225], [380, 238], [319, 236]], [[431, 224], [450, 224], [450, 235], [431, 235]], [[365, 203], [538, 203], [538, 216], [365, 216]], [[89, 200], [146, 203], [146, 217], [89, 214]], [[329, 201], [354, 201], [354, 212], [329, 212]], [[371, 181], [449, 181], [449, 194], [371, 194]], [[329, 181], [352, 181], [352, 192], [329, 192]], [[96, 179], [240, 179], [240, 193], [96, 193]], [[456, 162], [555, 162], [555, 175], [456, 175]], [[129, 150], [287, 151], [287, 165], [129, 164]], [[36, 145], [73, 149], [72, 163], [35, 159]], [[527, 146], [552, 146], [552, 155], [527, 155]], [[102, 145], [120, 145], [120, 153], [102, 153]], [[371, 129], [503, 128], [503, 139], [371, 140]], [[99, 126], [193, 126], [193, 139], [99, 139]], [[322, 127], [337, 127], [337, 135], [322, 135]], [[37, 123], [77, 123], [77, 134], [37, 134]], [[324, 106], [337, 106], [337, 115], [324, 115]], [[309, 107], [315, 107], [315, 112], [309, 112]], [[372, 103], [501, 103], [501, 116], [372, 116]], [[349, 105], [360, 105], [360, 114], [349, 114]], [[38, 103], [80, 103], [80, 113], [38, 113]], [[99, 100], [205, 101], [205, 115], [99, 114]], [[306, 90], [317, 90], [317, 97], [306, 97]], [[347, 88], [362, 88], [362, 96], [347, 96]], [[321, 87], [340, 87], [340, 99], [321, 99]], [[358, 84], [513, 82], [513, 95], [358, 97]], [[41, 83], [89, 83], [89, 93], [41, 93]], [[94, 79], [241, 80], [241, 94], [94, 93]], [[313, 66], [394, 66], [394, 79], [313, 79]], [[242, 66], [288, 66], [288, 77], [242, 77]], [[185, 54], [220, 54], [220, 65], [185, 65]], [[469, 48], [547, 48], [547, 61], [469, 61]], [[423, 36], [436, 36], [436, 54], [423, 54]], [[465, 30], [551, 30], [551, 43], [465, 43]], [[207, 21], [329, 23], [328, 41], [207, 39]]] +00208502.jpg [[[247, 566], [282, 566], [282, 573], [247, 573]], [[558, 534], [629, 539], [627, 570], [556, 565]], [[205, 540], [284, 540], [284, 552], [205, 552]], [[143, 513], [189, 513], [189, 525], [143, 525]], [[249, 512], [307, 512], [307, 524], [249, 524]], [[44, 500], [118, 500], [118, 519], [44, 519]], [[467, 491], [556, 491], [556, 508], [467, 508]], [[667, 490], [678, 494], [675, 503], [664, 499]], [[788, 489], [794, 495], [789, 499], [783, 494]], [[726, 491], [737, 491], [737, 501], [726, 501]], [[42, 452], [117, 450], [117, 469], [42, 470]], [[175, 450], [236, 450], [236, 464], [175, 464]], [[614, 407], [638, 407], [638, 422], [614, 422]], [[95, 405], [119, 405], [119, 422], [95, 422]], [[49, 399], [64, 414], [50, 427], [36, 413]], [[209, 401], [226, 401], [226, 415], [209, 415]], [[40, 357], [58, 357], [58, 374], [40, 374]], [[94, 356], [119, 356], [119, 373], [94, 373]], [[188, 341], [246, 339], [247, 361], [189, 364]], [[459, 321], [549, 319], [549, 337], [460, 339]], [[459, 273], [551, 273], [551, 290], [459, 290]], [[563, 272], [735, 269], [735, 286], [564, 289]], [[517, 225], [547, 225], [547, 245], [517, 245]], [[459, 226], [480, 226], [480, 244], [459, 244]], [[621, 187], [673, 187], [673, 201], [621, 201]], [[457, 132], [548, 130], [548, 147], [458, 149]], [[572, 106], [787, 99], [787, 120], [573, 126]], [[122, 48], [290, 48], [290, 97], [122, 97]], [[539, 39], [708, 39], [708, 89], [539, 89]]] +00224225.jpg [[[134, 429], [153, 426], [157, 445], [138, 448]], [[202, 404], [478, 411], [476, 459], [201, 452]], [[205, 230], [469, 230], [469, 390], [205, 390]], [[131, 265], [172, 265], [172, 279], [131, 279]], [[345, 207], [456, 207], [456, 231], [345, 231]], [[199, 189], [346, 196], [344, 239], [197, 232]], [[10, 44], [157, 41], [158, 112], [11, 115]]] +00227746.jpg [[[190, 232], [258, 232], [258, 238], [190, 238]], [[160, 232], [183, 232], [183, 238], [160, 238]], [[123, 232], [150, 232], [150, 238], [123, 238]], [[290, 208], [345, 206], [346, 222], [291, 224]], [[172, 181], [249, 181], [249, 194], [172, 194]], [[143, 178], [165, 180], [162, 208], [140, 206]], [[142, 164], [157, 162], [160, 177], [145, 180]], [[173, 157], [203, 157], [203, 164], [173, 164]], [[200, 154], [347, 154], [347, 167], [200, 167]], [[144, 111], [277, 114], [277, 134], [144, 131]], [[201, 52], [387, 53], [386, 69], [201, 68]], [[141, 46], [192, 46], [192, 63], [141, 63]], [[40, 26], [61, 26], [61, 42], [40, 42]]] +00229605.jpg [[[743, 529], [881, 529], [881, 544], [743, 544]], [[236, 499], [589, 498], [589, 522], [236, 523]], [[6, 498], [227, 498], [227, 522], [6, 522]], [[735, 496], [883, 499], [883, 520], [734, 517]], [[606, 495], [716, 489], [718, 515], [608, 521]], [[4, 245], [863, 230], [864, 288], [5, 303]], [[478, 28], [883, 28], [883, 76], [478, 76]]] +00233011.jpg [[[63, 227], [291, 227], [291, 242], [63, 242]], [[12, 219], [41, 219], [41, 250], [12, 250]], [[61, 177], [119, 177], [119, 195], [61, 195]], [[11, 173], [40, 169], [44, 200], [14, 203]], [[61, 129], [147, 131], [147, 147], [61, 144]], [[12, 124], [43, 124], [43, 154], [12, 154]], [[125, 89], [238, 89], [238, 103], [125, 103]], [[148, 51], [216, 51], [216, 65], [148, 65]], [[258, 46], [353, 50], [352, 69], [257, 65]], [[9, 49], [52, 49], [52, 68], [9, 68]], [[277, 12], [345, 12], [345, 31], [277, 31]], [[28, 11], [74, 11], [74, 31], [28, 31]]] +00233625.jpg [[[375, 397], [632, 399], [632, 443], [375, 440]], [[71, 214], [932, 207], [933, 321], [71, 328]]] +00233634.jpg [[[215, 639], [261, 639], [261, 703], [215, 703]], [[523, 635], [570, 635], [570, 695], [523, 695]], [[643, 523], [682, 523], [682, 568], [643, 568]], [[97, 516], [152, 516], [152, 589], [97, 589]], [[755, 395], [760, 395], [760, 401], [755, 401]], [[26, 395], [32, 395], [32, 400], [26, 400]], [[678, 364], [728, 362], [731, 430], [681, 432]], [[54, 361], [107, 361], [107, 434], [54, 434]], [[78, 208], [155, 208], [155, 280], [78, 280]], [[643, 205], [693, 205], [693, 272], [643, 272]], [[210, 88], [260, 86], [263, 164], [213, 166]], [[363, 48], [426, 45], [430, 115], [367, 118]]] +00234400.jpg [[[446, 421], [738, 421], [738, 438], [446, 438]], [[157, 421], [454, 421], [454, 438], [157, 438]], [[158, 394], [652, 394], [652, 411], [158, 411]], [[40, 391], [127, 391], [127, 412], [40, 412]], [[158, 342], [304, 345], [304, 363], [158, 360]], [[38, 344], [123, 344], [123, 362], [38, 362]], [[520, 295], [703, 295], [703, 314], [520, 314]], [[394, 292], [483, 290], [484, 314], [394, 317]], [[157, 293], [270, 293], [270, 313], [157, 313]], [[37, 293], [125, 293], [125, 313], [37, 313]], [[156, 243], [358, 243], [358, 267], [156, 267]], [[36, 243], [82, 243], [82, 269], [36, 269]], [[29, 152], [158, 152], [158, 175], [29, 175]], [[282, 98], [507, 98], [507, 111], [282, 111]], [[315, 46], [475, 50], [474, 88], [314, 85]], [[518, 51], [663, 53], [662, 67], [517, 65]], [[487, 19], [706, 17], [706, 43], [487, 45]]] +00234883.jpg [[[344, 145], [355, 145], [355, 153], [344, 153]], [[66, 125], [316, 120], [317, 190], [67, 195]], [[79, 138], [109, 141], [108, 152], [78, 148]], [[72, 120], [120, 120], [120, 130], [72, 130]], [[383, 63], [504, 62], [504, 74], [383, 75]], [[58, 29], [365, 26], [366, 112], [59, 115]], [[387, 28], [501, 26], [501, 45], [387, 47]]] +test_add_0.jpg [[[311, 521], [391, 521], [391, 534], [311, 534]], [[277, 500], [424, 500], [424, 514], [277, 514]], [[261, 446], [437, 446], [437, 459], [261, 459]], [[212, 428], [485, 428], [485, 441], [212, 441]], [[247, 388], [457, 388], [457, 409], [247, 409]], [[222, 328], [474, 328], [474, 372], [222, 372]], [[208, 207], [492, 211], [490, 277], [207, 272]], [[266, 164], [422, 166], [421, 197], [265, 195]], [[18, 20], [201, 18], [201, 43], [18, 45]]] +test_add_1.png [] +test_add_10.png [[[157, 124], [186, 124], [186, 172], [157, 172]], [[65, 117], [95, 117], [95, 168], [65, 168]], [[161, 106], [183, 106], [183, 127], [161, 127]], [[69, 100], [94, 100], [94, 128], [69, 128]], [[117, 46], [154, 45], [157, 174], [121, 175]], [[66, 34], [97, 34], [97, 112], [66, 112]]] +test_add_11.jpg [[[1525, 773], [1564, 756], [1575, 780], [1536, 798]], [[1390, 757], [1483, 757], [1483, 791], [1390, 791]], [[1013, 754], [1207, 754], [1207, 800], [1013, 800]], [[685, 755], [875, 755], [875, 796], [685, 796]], [[356, 753], [566, 747], [567, 793], [358, 798]], [[78, 751], [264, 745], [265, 793], [79, 798]], [[602, 647], [1152, 647], [1152, 703], [602, 703]], [[601, 564], [1148, 555], [1149, 611], [602, 620]], [[598, 480], [1066, 472], [1067, 526], [599, 535]], [[598, 393], [1090, 388], [1090, 439], [599, 444]], [[603, 306], [1057, 306], [1057, 357], [603, 357]], [[357, 184], [1517, 184], [1517, 261], [357, 261]], [[60, 43], [257, 37], [259, 83], [61, 89]], [[1305, 41], [1492, 41], [1492, 87], [1305, 87]], [[973, 40], [1171, 34], [1172, 80], [974, 86]], [[670, 40], [862, 34], [864, 80], [671, 86]], [[363, 34], [558, 34], [558, 85], [363, 85]]] +test_add_12.jpg [[[11, 592], [136, 594], [135, 613], [11, 611]], [[109, 521], [907, 526], [907, 569], [109, 565]], [[635, 451], [902, 448], [903, 478], [635, 481]], [[112, 447], [466, 449], [466, 486], [112, 483]], [[582, 306], [680, 304], [681, 348], [583, 351]], [[369, 261], [565, 266], [563, 357], [367, 353]], [[64, 85], [853, 88], [853, 161], [64, 159]]] +test_add_13.jpg [[[68, 94], [117, 97], [116, 114], [67, 111]]] +test_add_14.jpg [[[30, 97], [235, 95], [236, 127], [31, 129]], [[30, 52], [239, 50], [239, 86], [30, 87]]] +test_add_15.jpg [[[141, 253], [353, 253], [353, 266], [141, 266]], [[205, 214], [406, 219], [406, 232], [204, 227]], [[106, 212], [193, 213], [193, 227], [106, 226]], [[154, 156], [286, 161], [286, 174], [154, 170]], [[148, 136], [305, 142], [305, 156], [147, 150]], [[108, 137], [144, 137], [144, 148], [108, 148]], [[108, 102], [275, 109], [275, 125], [107, 117]], [[107, 72], [245, 79], [245, 96], [106, 88]], [[107, 39], [209, 42], [209, 62], [106, 59]]] +test_add_16.jpg [[[398, 842], [408, 842], [408, 852], [398, 852]], [[382, 742], [746, 742], [746, 776], [382, 776]], [[362, 703], [468, 703], [468, 725], [362, 725]], [[1552, 701], [1576, 701], [1576, 746], [1552, 746]], [[1256, 695], [1442, 695], [1442, 721], [1256, 721]], [[1244, 661], [1448, 661], [1448, 687], [1244, 687]], [[386, 645], [668, 645], [668, 679], [386, 679]], [[1228, 625], [1470, 623], [1470, 651], [1228, 653]], [[360, 604], [580, 604], [580, 629], [360, 629]], [[1202, 592], [1494, 592], [1494, 617], [1202, 617]], [[1166, 556], [1530, 556], [1530, 582], [1166, 582]], [[380, 552], [638, 552], [638, 586], [380, 586]], [[356, 502], [516, 502], [516, 536], [356, 536]], [[774, 260], [1124, 260], [1124, 300], [774, 300]], [[374, 210], [504, 210], [504, 300], [374, 300]], [[776, 212], [1088, 217], [1088, 252], [776, 248]]] +test_add_17.jpg [[[321, 255], [393, 258], [392, 271], [320, 269]], [[307, 222], [411, 228], [411, 241], [306, 236]], [[96, 136], [385, 143], [384, 208], [94, 201]], [[72, 95], [399, 103], [398, 124], [71, 117]], [[68, 76], [224, 79], [223, 93], [67, 90]], [[66, 59], [226, 62], [225, 76], [65, 74]]] +test_add_18.jpg [[[466, 788], [715, 790], [715, 813], [466, 811]], [[553, 752], [665, 757], [663, 791], [552, 786]], [[119, 539], [189, 539], [189, 570], [119, 570]], [[116, 473], [674, 486], [673, 528], [115, 516]], [[121, 429], [669, 441], [668, 470], [121, 457]], [[121, 375], [674, 381], [674, 410], [121, 404]], [[556, 262], [675, 264], [675, 278], [556, 277]], [[164, 259], [334, 259], [334, 273], [164, 273]], [[344, 195], [456, 197], [455, 220], [343, 217]], [[309, 175], [490, 175], [490, 190], [309, 190]], [[255, 128], [537, 131], [537, 169], [254, 165]], [[347, 92], [486, 94], [486, 109], [346, 107]], [[285, 41], [567, 49], [566, 82], [284, 74]], [[236, 32], [266, 32], [266, 60], [236, 60]]] +test_add_19.jpg [[[24, 294], [42, 294], [42, 302], [24, 302]], [[64, 293], [105, 293], [105, 303], [64, 303]], [[145, 287], [163, 287], [163, 304], [145, 304]], [[63, 280], [106, 280], [106, 290], [63, 290]], [[9, 281], [26, 281], [26, 288], [9, 288]], [[220, 279], [245, 279], [245, 291], [220, 291]], [[177, 279], [208, 279], [208, 290], [177, 290]], [[23, 279], [51, 279], [51, 290], [23, 290]], [[145, 278], [162, 278], [162, 292], [145, 292]], [[8, 267], [18, 267], [18, 276], [8, 276]], [[221, 265], [243, 265], [243, 277], [221, 277]], [[24, 265], [47, 265], [47, 277], [24, 277]], [[142, 263], [163, 263], [163, 279], [142, 279]], [[218, 252], [249, 252], [249, 265], [218, 265]], [[65, 253], [131, 253], [131, 263], [65, 263]], [[24, 252], [43, 252], [43, 264], [24, 264]], [[8, 253], [18, 253], [18, 262], [8, 262]], [[8, 240], [17, 240], [17, 249], [8, 249]], [[63, 237], [114, 237], [114, 251], [63, 251]], [[25, 236], [47, 239], [45, 251], [23, 249]], [[144, 234], [166, 237], [163, 253], [142, 249]], [[494, 226], [531, 226], [531, 239], [494, 239]], [[335, 226], [354, 226], [354, 237], [335, 237]], [[288, 226], [314, 226], [314, 237], [288, 237]], [[63, 226], [113, 226], [113, 236], [63, 236]], [[7, 227], [17, 227], [17, 234], [7, 234]], [[221, 225], [248, 225], [248, 235], [221, 235]], [[143, 225], [165, 222], [167, 234], [145, 237]], [[24, 224], [48, 224], [48, 238], [24, 238]], [[495, 213], [524, 213], [524, 224], [495, 224]], [[420, 212], [437, 212], [437, 225], [420, 225]], [[336, 212], [398, 212], [398, 223], [336, 223]], [[292, 212], [320, 212], [320, 223], [292, 223]], [[222, 212], [249, 212], [249, 223], [222, 223]], [[145, 212], [166, 212], [166, 223], [145, 223]], [[61, 211], [113, 209], [114, 222], [62, 224]], [[26, 211], [48, 211], [48, 223], [26, 223]], [[337, 199], [383, 199], [383, 209], [337, 209]], [[65, 200], [87, 200], [87, 207], [65, 207]], [[493, 197], [541, 197], [541, 211], [493, 211]], [[445, 202], [455, 196], [462, 206], [452, 212]], [[178, 198], [205, 198], [205, 208], [178, 208]], [[146, 199], [157, 199], [157, 208], [146, 208]], [[32, 194], [43, 204], [33, 214], [22, 203]], [[422, 193], [440, 201], [432, 215], [415, 207]], [[65, 186], [132, 186], [132, 196], [65, 196]], [[337, 185], [399, 185], [399, 196], [337, 196]], [[445, 190], [456, 182], [465, 191], [454, 200]], [[292, 188], [308, 182], [313, 193], [297, 200]], [[220, 183], [255, 183], [255, 197], [220, 197]], [[142, 184], [158, 184], [158, 197], [142, 197]], [[493, 182], [518, 182], [518, 197], [493, 197]], [[425, 180], [437, 191], [427, 202], [414, 190]], [[32, 179], [42, 189], [32, 199], [22, 189]], [[182, 179], [195, 185], [188, 198], [175, 192]], [[335, 172], [400, 169], [400, 183], [336, 185]], [[492, 170], [519, 170], [519, 185], [492, 185]], [[412, 177], [428, 164], [440, 178], [425, 190]], [[293, 171], [315, 171], [315, 185], [293, 185]], [[220, 170], [251, 170], [251, 184], [220, 184]], [[178, 172], [188, 172], [188, 183], [178, 183]], [[64, 172], [125, 170], [125, 181], [64, 182]], [[454, 168], [464, 176], [454, 185], [445, 176]], [[142, 172], [159, 168], [163, 180], [145, 185]], [[30, 165], [43, 174], [34, 186], [20, 177]], [[493, 160], [523, 160], [523, 170], [493, 170]], [[402, 161], [435, 161], [435, 168], [402, 168]], [[335, 159], [401, 159], [401, 169], [335, 169]], [[296, 159], [325, 159], [325, 170], [296, 170]], [[221, 158], [251, 158], [251, 169], [221, 169]], [[174, 161], [183, 156], [190, 167], [181, 172]], [[145, 158], [162, 158], [162, 170], [145, 170]], [[61, 158], [125, 157], [125, 168], [62, 169]], [[20, 161], [33, 154], [40, 167], [28, 174]], [[492, 143], [542, 143], [542, 157], [492, 157]], [[450, 144], [479, 144], [479, 157], [450, 157]], [[335, 143], [439, 143], [439, 156], [335, 156]], [[294, 143], [327, 143], [327, 157], [294, 157]], [[220, 143], [253, 143], [253, 157], [220, 157]], [[178, 145], [187, 145], [187, 156], [178, 156]], [[63, 144], [104, 144], [104, 155], [63, 155]], [[144, 140], [164, 145], [160, 159], [141, 154]], [[31, 137], [44, 149], [31, 162], [17, 149]], [[286, 135], [291, 135], [291, 140], [286, 140]], [[177, 133], [193, 133], [193, 144], [177, 144]], [[336, 132], [388, 132], [388, 141], [336, 141]], [[492, 131], [525, 131], [525, 141], [492, 141]], [[450, 131], [477, 131], [477, 141], [450, 141]], [[292, 131], [321, 131], [321, 141], [292, 141]], [[218, 132], [255, 130], [256, 141], [219, 144]], [[63, 131], [95, 131], [95, 141], [63, 141]], [[417, 130], [437, 130], [437, 141], [417, 141]], [[145, 130], [159, 130], [159, 143], [145, 143]], [[30, 124], [43, 133], [32, 147], [19, 138]], [[493, 118], [535, 118], [535, 129], [493, 129]], [[336, 118], [388, 118], [388, 129], [336, 129]], [[218, 118], [255, 118], [255, 128], [218, 128]], [[451, 117], [478, 117], [478, 129], [451, 129]], [[418, 117], [438, 117], [438, 130], [418, 130]], [[177, 116], [209, 116], [209, 130], [177, 130]], [[145, 117], [162, 117], [162, 130], [145, 130]], [[62, 116], [88, 116], [88, 131], [62, 131]], [[19, 121], [33, 111], [43, 124], [29, 134]], [[491, 107], [523, 107], [523, 113], [491, 113]], [[449, 107], [477, 107], [477, 113], [449, 113]], [[420, 107], [436, 107], [436, 113], [420, 113]], [[295, 107], [319, 107], [319, 114], [295, 114]], [[220, 107], [242, 107], [242, 113], [220, 113]], [[176, 107], [203, 107], [203, 113], [176, 113]], [[145, 107], [161, 107], [161, 114], [145, 114]], [[334, 105], [372, 105], [372, 114], [334, 114]], [[63, 106], [86, 106], [86, 113], [63, 113]], [[483, 89], [522, 89], [522, 99], [483, 99]], [[331, 88], [380, 88], [380, 99], [331, 99]], [[276, 88], [325, 88], [325, 99], [276, 99]], [[214, 88], [246, 88], [246, 99], [214, 99]], [[411, 86], [474, 86], [474, 100], [411, 100]], [[6, 86], [102, 86], [102, 100], [6, 100]], [[415, 66], [461, 66], [461, 77], [415, 77]], [[288, 66], [333, 66], [333, 77], [288, 77]], [[157, 64], [206, 64], [206, 78], [157, 78]], [[416, 48], [523, 49], [523, 63], [415, 62]], [[288, 49], [375, 49], [375, 63], [288, 63]], [[159, 49], [269, 49], [269, 62], [159, 62]], [[24, 53], [36, 46], [45, 59], [33, 67]], [[416, 36], [481, 36], [481, 46], [416, 46]], [[25, 38], [39, 32], [46, 46], [33, 52]], [[157, 34], [205, 34], [205, 47], [157, 47]], [[412, 4], [527, 4], [527, 17], [412, 17]], [[146, 4], [345, 2], [345, 15], [146, 17]]] +test_add_20.jpg [[[31, 346], [605, 346], [605, 370], [31, 370]], [[217, 294], [510, 294], [510, 322], [217, 322]], [[473, 271], [525, 271], [525, 286], [473, 286]], [[220, 267], [287, 267], [287, 286], [220, 286]], [[219, 239], [484, 239], [484, 263], [219, 263]], [[221, 217], [303, 217], [303, 234], [221, 234]], [[402, 192], [417, 192], [417, 205], [402, 205]], [[222, 187], [341, 187], [341, 207], [222, 207]], [[221, 162], [287, 162], [287, 180], [221, 180]], [[375, 122], [475, 124], [475, 146], [375, 143]], [[222, 124], [356, 122], [356, 143], [222, 146]], [[218, 81], [352, 84], [352, 116], [218, 113]], [[440, 35], [605, 35], [605, 60], [440, 60]], [[72, 16], [398, 16], [398, 44], [72, 44]]] +test_add_3.jpg [[[169, 327], [337, 326], [337, 341], [169, 342]], [[170, 288], [307, 290], [307, 312], [170, 310]], [[171, 221], [323, 221], [323, 234], [171, 234]], [[340, 221], [449, 217], [449, 231], [341, 234]], [[169, 201], [372, 201], [372, 214], [169, 214]], [[170, 183], [418, 183], [418, 196], [170, 196]], [[170, 149], [416, 149], [416, 163], [170, 163]], [[171, 119], [418, 119], [418, 140], [171, 140]], [[326, 64], [478, 64], [478, 91], [326, 91]], [[173, 64], [306, 60], [306, 89], [174, 93]]] +test_add_4.png [] +test_add_5.png [[[48, 164], [108, 164], [108, 174], [48, 174]], [[52, 121], [169, 121], [169, 134], [52, 134]], [[50, 102], [165, 102], [165, 118], [50, 118]], [[52, 83], [164, 83], [164, 100], [52, 100]], [[51, 68], [166, 68], [166, 84], [51, 84]], [[51, 50], [145, 47], [145, 64], [52, 67]]] +test_add_6.jpg [[[123, 223], [219, 227], [218, 251], [122, 247]], [[172, 172], [186, 186], [172, 200], [158, 186]]] +test_add_7.jpg [[[48, 938], [174, 936], [174, 962], [48, 964]], [[227, 873], [629, 876], [628, 953], [226, 949]], [[56, 745], [638, 745], [638, 790], [56, 790]], [[150, 674], [545, 678], [544, 721], [150, 718]], [[73, 504], [633, 504], [633, 601], [73, 601]], [[59, 270], [655, 279], [652, 441], [56, 432]], [[513, 193], [553, 193], [553, 223], [513, 223]], [[61, 175], [532, 175], [532, 239], [61, 239]], [[533, 178], [642, 178], [642, 236], [533, 236]]] +test_add_8.jpg [[[251, 586], [454, 580], [454, 606], [252, 613]], [[107, 533], [457, 527], [457, 560], [108, 566]], [[336, 494], [384, 494], [384, 507], [336, 507]], [[27, 307], [355, 297], [356, 320], [28, 330]], [[22, 259], [445, 251], [445, 274], [23, 282]], [[78, 209], [445, 205], [445, 225], [78, 229]], [[160, 23], [319, 30], [317, 79], [158, 72]]] +test_add_9.png [[[266, 687], [486, 687], [486, 696], [266, 696]], [[196, 668], [554, 668], [554, 681], [196, 681]], [[154, 596], [597, 596], [597, 606], [154, 606]], [[215, 578], [541, 578], [541, 588], [215, 588]], [[134, 560], [615, 560], [615, 570], [134, 570]], [[85, 543], [665, 543], [665, 553], [85, 553]], [[96, 522], [653, 522], [653, 535], [96, 535]], [[362, 449], [389, 449], [389, 460], [362, 460]], [[238, 376], [513, 376], [513, 389], [238, 389]], [[177, 356], [574, 356], [574, 368], [177, 368]], [[344, 281], [408, 283], [407, 297], [343, 294]], [[257, 205], [493, 205], [493, 219], [257, 219]]] diff --git a/tests/test.sh b/tests/test.sh index 6c34d0797a988f6ca597c43108d00390faa188d0..1a19c379077b53168bebf10ee01bcae8412cd3cf 100644 --- a/tests/test.sh +++ b/tests/test.sh @@ -1,6 +1,6 @@ #!/bin/bash FILENAME=$1 -# MODE be one of ['lite_train_infer' 'whole_infer' 'whole_train_infer', 'infer'] +# MODE be one of ['lite_train_infer' 'whole_infer' 'whole_train_infer', 'infer', 'cpp_infer'] MODE=$2 dataline=$(cat ${FILENAME}) @@ -145,30 +145,57 @@ benchmark_value=$(func_parser_value "${lines[49]}") infer_key1=$(func_parser_key "${lines[50]}") infer_value1=$(func_parser_value "${lines[50]}") # parser serving -trans_model_py=$(func_parser_value "${lines[52]}") -infer_model_dir_key=$(func_parser_key "${lines[53]}") -infer_model_dir_value=$(func_parser_value "${lines[53]}") -model_filename_key=$(func_parser_key "${lines[54]}") -model_filename_value=$(func_parser_value "${lines[54]}") -params_filename_key=$(func_parser_key "${lines[55]}") -params_filename_value=$(func_parser_value "${lines[55]}") -serving_server_key=$(func_parser_key "${lines[56]}") -serving_server_value=$(func_parser_value "${lines[56]}") -serving_client_key=$(func_parser_key "${lines[57]}") -serving_client_value=$(func_parser_value "${lines[57]}") -serving_dir_value=$(func_parser_value "${lines[58]}") -web_service_py=$(func_parser_value "${lines[59]}") -web_use_gpu_key=$(func_parser_key "${lines[60]}") -web_use_gpu_list=$(func_parser_value "${lines[60]}") -web_use_mkldnn_key=$(func_parser_key "${lines[61]}") -web_use_mkldnn_list=$(func_parser_value "${lines[61]}") -web_cpu_threads_key=$(func_parser_key "${lines[62]}") -web_cpu_threads_list=$(func_parser_value "${lines[62]}") -web_use_trt_key=$(func_parser_key "${lines[63]}") -web_use_trt_list=$(func_parser_value "${lines[63]}") -web_precision_key=$(func_parser_key "${lines[64]}") -web_precision_list=$(func_parser_value "${lines[64]}") -pipeline_py=$(func_parser_value "${lines[65]}") +trans_model_py=$(func_parser_value "${lines[67]}") +infer_model_dir_key=$(func_parser_key "${lines[68]}") +infer_model_dir_value=$(func_parser_value "${lines[68]}") +model_filename_key=$(func_parser_key "${lines[69]}") +model_filename_value=$(func_parser_value "${lines[69]}") +params_filename_key=$(func_parser_key "${lines[70]}") +params_filename_value=$(func_parser_value "${lines[70]}") +serving_server_key=$(func_parser_key "${lines[71]}") +serving_server_value=$(func_parser_value "${lines[71]}") +serving_client_key=$(func_parser_key "${lines[72]}") +serving_client_value=$(func_parser_value "${lines[72]}") +serving_dir_value=$(func_parser_value "${lines[73]}") +web_service_py=$(func_parser_value "${lines[74]}") +web_use_gpu_key=$(func_parser_key "${lines[75]}") +web_use_gpu_list=$(func_parser_value "${lines[75]}") +web_use_mkldnn_key=$(func_parser_key "${lines[76]}") +web_use_mkldnn_list=$(func_parser_value "${lines[76]}") +web_cpu_threads_key=$(func_parser_key "${lines[77]}") +web_cpu_threads_list=$(func_parser_value "${lines[77]}") +web_use_trt_key=$(func_parser_key "${lines[78]}") +web_use_trt_list=$(func_parser_value "${lines[78]}") +web_precision_key=$(func_parser_key "${lines[79]}") +web_precision_list=$(func_parser_value "${lines[79]}") +pipeline_py=$(func_parser_value "${lines[80]}") + + +if [ ${MODE} = "cpp_infer" ]; then + # parser cpp inference model + cpp_infer_model_dir_list=$(func_parser_value "${lines[53]}") + cpp_infer_is_quant=$(func_parser_value "${lines[54]}") + # parser cpp inference + inference_cmd=$(func_parser_value "${lines[55]}") + cpp_use_gpu_key=$(func_parser_key "${lines[56]}") + cpp_use_gpu_list=$(func_parser_value "${lines[56]}") + cpp_use_mkldnn_key=$(func_parser_key "${lines[57]}") + cpp_use_mkldnn_list=$(func_parser_value "${lines[57]}") + cpp_cpu_threads_key=$(func_parser_key "${lines[58]}") + cpp_cpu_threads_list=$(func_parser_value "${lines[58]}") + cpp_batch_size_key=$(func_parser_key "${lines[59]}") + cpp_batch_size_list=$(func_parser_value "${lines[59]}") + cpp_use_trt_key=$(func_parser_key "${lines[60]}") + cpp_use_trt_list=$(func_parser_value "${lines[60]}") + cpp_precision_key=$(func_parser_key "${lines[61]}") + cpp_precision_list=$(func_parser_value "${lines[61]}") + cpp_infer_model_key=$(func_parser_key "${lines[62]}") + cpp_image_dir_key=$(func_parser_key "${lines[63]}") + cpp_infer_img_dir=$(func_parser_value "${lines[63]}") + cpp_save_log_key=$(func_parser_key "${lines[64]}") + cpp_benchmark_key=$(func_parser_key "${lines[65]}") + cpp_benchmark_value=$(func_parser_value "${lines[65]}") +fi LOG_PATH="./tests/output" @@ -312,6 +339,63 @@ function func_serving(){ kill $PID sleep 2s ps ux | grep -E 'web_service|pipeline' | awk '{print $2}' | xargs kill -s 9 +function func_cpp_inference(){ + IFS='|' + _script=$1 + _model_dir=$2 + _log_path=$3 + _img_dir=$4 + _flag_quant=$5 + # inference + for use_gpu in ${cpp_use_gpu_list[*]}; do + if [ ${use_gpu} = "False" ] || [ ${use_gpu} = "cpu" ]; then + for use_mkldnn in ${cpp_use_mkldnn_list[*]}; do + if [ ${use_mkldnn} = "False" ] && [ ${_flag_quant} = "True" ]; then + continue + fi + for threads in ${cpp_cpu_threads_list[*]}; do + for batch_size in ${cpp_batch_size_list[*]}; do + _save_log_path="${_log_path}/cpp_infer_cpu_usemkldnn_${use_mkldnn}_threads_${threads}_batchsize_${batch_size}.log" + set_infer_data=$(func_set_params "${cpp_image_dir_key}" "${_img_dir}") + set_benchmark=$(func_set_params "${cpp_benchmark_key}" "${cpp_benchmark_value}") + set_batchsize=$(func_set_params "${cpp_batch_size_key}" "${batch_size}") + set_cpu_threads=$(func_set_params "${cpp_cpu_threads_key}" "${threads}") + set_model_dir=$(func_set_params "${cpp_infer_model_key}" "${_model_dir}") + command="${_script} ${cpp_use_gpu_key}=${use_gpu} ${cpp_use_mkldnn_key}=${use_mkldnn} ${set_cpu_threads} ${set_model_dir} ${set_batchsize} ${set_infer_data} ${set_benchmark} > ${_save_log_path} 2>&1 " + eval $command + last_status=${PIPESTATUS[0]} + eval "cat ${_save_log_path}" + status_check $last_status "${command}" "${status_log}" + done + done + done + elif [ ${use_gpu} = "True" ] || [ ${use_gpu} = "gpu" ]; then + for use_trt in ${cpp_use_trt_list[*]}; do + for precision in ${cpp_precision_list[*]}; do + if [[ ${_flag_quant} = "False" ]] && [[ ${precision} =~ "int8" ]]; then + continue + fi + if [[ ${precision} =~ "fp16" || ${precision} =~ "int8" ]] && [ ${use_trt} = "False" ]; then + continue + fi + if [[ ${use_trt} = "False" || ${precision} =~ "int8" ]] && [ ${_flag_quant} = "True" ]; then + continue + fi + for batch_size in ${cpp_batch_size_list[*]}; do + _save_log_path="${_log_path}/cpp_infer_gpu_usetrt_${use_trt}_precision_${precision}_batchsize_${batch_size}.log" + set_infer_data=$(func_set_params "${cpp_image_dir_key}" "${_img_dir}") + set_benchmark=$(func_set_params "${cpp_benchmark_key}" "${cpp_benchmark_value}") + set_batchsize=$(func_set_params "${cpp_batch_size_key}" "${batch_size}") + set_tensorrt=$(func_set_params "${cpp_use_trt_key}" "${use_trt}") + set_precision=$(func_set_params "${cpp_precision_key}" "${precision}") + set_model_dir=$(func_set_params "${cpp_infer_model_key}" "${_model_dir}") + command="${_script} ${cpp_use_gpu_key}=${use_gpu} ${set_tensorrt} ${set_precision} ${set_model_dir} ${set_batchsize} ${set_infer_data} ${set_benchmark} > ${_save_log_path} 2>&1 " + eval $command + last_status=${PIPESTATUS[0]} + eval "cat ${_save_log_path}" + status_check $last_status "${command}" "${status_log}" + + done done done else @@ -320,7 +404,6 @@ function func_serving(){ done } - if [ ${MODE} = "infer" ]; then GPUID=$3 if [ ${#GPUID} -le 0 ];then @@ -355,6 +438,25 @@ if [ ${MODE} = "infer" ]; then Count=$(($Count + 1)) done +elif [ ${MODE} = "cpp_infer" ]; then + GPUID=$3 + if [ ${#GPUID} -le 0 ];then + env=" " + else + env="export CUDA_VISIBLE_DEVICES=${GPUID}" + fi + # set CUDA_VISIBLE_DEVICES + eval $env + export Count=0 + IFS="|" + infer_quant_flag=(${cpp_infer_is_quant}) + for infer_model in ${cpp_infer_model_dir_list[*]}; do + #run inference + is_quant=${infer_quant_flag[Count]} + func_cpp_inference "${inference_cmd}" "${infer_model}" "${LOG_PATH}" "${cpp_infer_img_dir}" ${is_quant} + Count=$(($Count + 1)) + done + elif [ ${MODE} = "serving_infer" ]; then GPUID=$3 if [ ${#GPUID} -le 0 ];then @@ -368,6 +470,7 @@ elif [ ${MODE} = "serving_infer" ]; then IFS="|" #run serving func_serving "${web_service_cmd}" + else IFS="|" export Count=0 diff --git a/tools/infer/predict_det.py b/tools/infer/predict_det.py index 3de00d83a8f9f55af9b89d5d2cd5c877399c5930..6347ca6dc719f0d489736dbf285eedd775d3790e 100755 --- a/tools/infer/predict_det.py +++ b/tools/infer/predict_det.py @@ -30,7 +30,7 @@ from ppocr.utils.logging import get_logger from ppocr.utils.utility import get_image_file_list, check_and_read_gif from ppocr.data import create_operators, transform from ppocr.postprocess import build_post_process - +import json logger = get_logger() @@ -101,6 +101,7 @@ class TextDetector(object): if args.benchmark: import auto_log pid = os.getpid() + gpu_id = utility.get_infer_gpuid() self.autolog = auto_log.AutoLogger( model_name="det", model_precision=args.precision, @@ -110,7 +111,7 @@ class TextDetector(object): inference_config=self.config, pids=pid, process_name=None, - gpu_ids=0, + gpu_ids=gpu_id if args.use_gpu else None, time_keys=[ 'preprocess_time', 'inference_time', 'postprocess_time' ], @@ -242,6 +243,7 @@ if __name__ == "__main__": if not os.path.exists(draw_img_save): os.makedirs(draw_img_save) + save_results = [] for image_file in image_file_list: img, flag = check_and_read_gif(image_file) if not flag: @@ -255,8 +257,11 @@ if __name__ == "__main__": if count > 0: total_time += elapse count += 1 - - logger.info("Predict time of {}: {}".format(image_file, elapse)) + save_pred = os.path.basename(image_file) + "\t" + str( + json.dumps(np.array(dt_boxes).astype(np.int32).tolist())) + "\n" + save_results.append(save_pred) + logger.info(save_pred) + logger.info("The predict time of {}: {}".format(image_file, elapse)) src_im = utility.draw_text_det_res(dt_boxes, image_file) img_name_pure = os.path.split(image_file)[-1] img_path = os.path.join(draw_img_save, @@ -264,5 +269,8 @@ if __name__ == "__main__": cv2.imwrite(img_path, src_im) logger.info("The visualized image saved in {}".format(img_path)) + with open(os.path.join(draw_img_save, "det_results.txt"), 'w') as f: + f.writelines(save_results) + f.close() if args.benchmark: text_detector.autolog.report() diff --git a/tools/infer/predict_e2e.py b/tools/infer/predict_e2e.py index cd6c2005a7cc77c356e3f004cd586a84676ea7fa..5029d6059346a00062418d8d1b6cb029b0110643 100755 --- a/tools/infer/predict_e2e.py +++ b/tools/infer/predict_e2e.py @@ -74,7 +74,7 @@ class TextE2E(object): self.preprocess_op = create_operators(pre_process_list) self.postprocess_op = build_post_process(postprocess_params) - self.predictor, self.input_tensor, self.output_tensors = utility.create_predictor( + self.predictor, self.input_tensor, self.output_tensors, _ = utility.create_predictor( args, 'e2e', logger) # paddle.jit.load(args.det_model_dir) # self.predictor.eval() diff --git a/tools/infer/predict_rec.py b/tools/infer/predict_rec.py index bb4a31706471b9b1745519ac9f390d01b60d5d44..7401a16ee662ceed1f8010adc3db0769e3efadb6 100755 --- a/tools/infer/predict_rec.py +++ b/tools/infer/predict_rec.py @@ -68,6 +68,7 @@ class TextRecognizer(object): if args.benchmark: import auto_log pid = os.getpid() + gpu_id = utility.get_infer_gpuid() self.autolog = auto_log.AutoLogger( model_name="rec", model_precision=args.precision, @@ -77,7 +78,7 @@ class TextRecognizer(object): inference_config=self.config, pids=pid, process_name=None, - gpu_ids=0 if args.use_gpu else None, + gpu_ids=gpu_id if args.use_gpu else None, time_keys=[ 'preprocess_time', 'inference_time', 'postprocess_time' ], @@ -87,8 +88,8 @@ class TextRecognizer(object): def resize_norm_img(self, img, max_wh_ratio): imgC, imgH, imgW = self.rec_image_shape assert imgC == img.shape[2] - if self.character_type == "ch": - imgW = int((32 * max_wh_ratio)) + max_wh_ratio = max(max_wh_ratio, imgW / imgH) + imgW = int((32 * max_wh_ratio)) h, w = img.shape[:2] ratio = w / float(h) if math.ceil(imgH * ratio) > imgW: @@ -277,7 +278,7 @@ def main(args): if args.warmup: img = np.random.uniform(0, 255, [32, 320, 3]).astype(np.uint8) for i in range(2): - res = text_recognizer([img]) + res = text_recognizer([img] * int(args.rec_batch_num)) for image_file in image_file_list: img, flag = check_and_read_gif(image_file) diff --git a/tools/infer/utility.py b/tools/infer/utility.py index 1c82280099f17f6d3bf848669e47439505f10576..7f60773c3e76aa4bf66caeb29dc2968be49cc51a 100755 --- a/tools/infer/utility.py +++ b/tools/infer/utility.py @@ -35,7 +35,7 @@ def init_args(): parser.add_argument("--use_gpu", type=str2bool, default=True) parser.add_argument("--ir_optim", type=str2bool, default=True) parser.add_argument("--use_tensorrt", type=str2bool, default=False) - parser.add_argument("--min_subgraph_size", type=int, default=10) + parser.add_argument("--min_subgraph_size", type=int, default=15) parser.add_argument("--precision", type=str, default="fp32") parser.add_argument("--gpu_mem", type=int, default=500) @@ -159,6 +159,11 @@ def create_predictor(args, mode, logger): precision = inference.PrecisionType.Float32 if args.use_gpu: + gpu_id = get_infer_gpuid() + if gpu_id is None: + raise ValueError( + "Not found GPU in current device. Please check your device or set args.use_gpu as False" + ) config.enable_use_gpu(args.gpu_mem, 0) if args.use_tensorrt: config.enable_tensorrt_engine( @@ -280,6 +285,20 @@ def create_predictor(args, mode, logger): return predictor, input_tensor, output_tensors, config +def get_infer_gpuid(): + cmd = "nvidia-smi" + res = os.popen(cmd).readlines() + if len(res) == 0: + return None + cmd = "env | grep CUDA_VISIBLE_DEVICES" + env_cuda = os.popen(cmd).readlines() + if len(env_cuda) == 0: + return 0 + else: + gpu_id = env_cuda[0].strip().split("=")[1] + return int(gpu_id[0]) + + def draw_e2e_res(dt_boxes, strs, img_path): src_im = cv2.imread(img_path) for box, str in zip(dt_boxes, strs): diff --git a/tools/program.py b/tools/program.py index 595fe4cb96c0379b1a33504e0ebdd85e70086340..e7742a8f608db679ff0c71de007a819e8ba3567f 100755 --- a/tools/program.py +++ b/tools/program.py @@ -186,9 +186,11 @@ def train(config, model.train() use_srn = config['Architecture']['algorithm'] == "SRN" - try: + use_nrtr = config['Architecture']['algorithm'] == "NRTR" + + try: model_type = config['Architecture']['model_type'] - except: + except: model_type = None if 'start_epoch' in best_model_dict: @@ -213,7 +215,7 @@ def train(config, images = batch[0] if use_srn: model_average = True - if use_srn or model_type == 'table': + if use_srn or model_type == 'table' or use_nrtr: preds = model(images, data=batch[1:]) else: preds = model(images) @@ -398,7 +400,7 @@ def preprocess(is_train=False): alg = config['Architecture']['algorithm'] assert alg in [ 'EAST', 'DB', 'SAST', 'Rosetta', 'CRNN', 'STARNet', 'RARE', 'SRN', - 'CLS', 'PGNet', 'Distillation', 'TableAttn' + 'CLS', 'PGNet', 'Distillation', 'NRTR', 'TableAttn' ] device = 'gpu:{}'.format(dist.ParallelEnv().dev_id) if use_gpu else 'cpu'