From b3dd73c716f3688dadb5dc67b6727946f5f7ae8b Mon Sep 17 00:00:00 2001 From: TonyLee1256 <163754792+TonyLee1256@users.noreply.github.com> Date: Sun, 21 Apr 2024 22:09:58 +0800 Subject: [PATCH 1/5] Update README_zh.md --- assets/README_zh.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/README_zh.md b/assets/README_zh.md index 0f4b560..8ce6c1d 100644 --- a/assets/README_zh.md +++ b/assets/README_zh.md @@ -113,7 +113,7 @@ TexTeller还支持对整张图片进行**公式检测+公式识别**,从而对 ### 下载权重 -中文英文文档公式检测 [[link](https://huggingface.co/TonyLee1256/texteller_det/resolve/main/rtdetr_r50vd_6x_coco.onnx?download=true)]:在3415张中文教材数据(130+版式)上训练得到 +中文英文文档公式检测 [[link](https://huggingface.co/TonyLee1256/texteller_det/resolve/main/rtdetr_r50vd_6x_coco.onnx?download=true)]:在3415张中文教材数据(130+版式)和8272张[IBEM数据集](https://zenodo.org/records/4757865)上,共11867张图片上训练得到 ### 公式检测 From 0079c07be2f7019a506e837b62bb73770375b47c Mon Sep 17 00:00:00 2001 From: TonyLee1256 <163754792+TonyLee1256@users.noreply.github.com> Date: Sun, 21 Apr 2024 22:12:22 +0800 Subject: [PATCH 2/5] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fb2b5a2..0a31338 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ TexTeller also supports **formula detection and recognition** on full images, al ### Download Weights -Chinese-English documentation formula detection [[link](https://huggingface.co/TonyLee1256/texteller_det/resolve/main/rtdetr_r50vd_6x_coco.onnx?download=true)]: Trained on 3415 Chinese textbook images (130+ layouts). +Chinese and English document formula detection [[link](https://huggingface.co/TonyLee1256/texteller_det/resolve/main/rtdetr_r50vd_6x_coco.onnx?download=true)]: Trained on a total of 11,867 images, consisting of 3,415 images from Chinese textbooks (130+ layouts) and 8,272 images from the IBEM dataset. ### Formula Detection From be19ed8d63e68fbb32b1bc1e8a39fdfc60c97965 Mon Sep 17 00:00:00 2001 From: TonyLee1256 <163754792+TonyLee1256@users.noreply.github.com> Date: Sun, 21 Apr 2024 22:14:23 +0800 Subject: [PATCH 3/5] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0a31338..5fd4c39 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ TexTeller also supports **formula detection and recognition** on full images, al ### Download Weights -Chinese and English document formula detection [[link](https://huggingface.co/TonyLee1256/texteller_det/resolve/main/rtdetr_r50vd_6x_coco.onnx?download=true)]: Trained on a total of 11,867 images, consisting of 3,415 images from Chinese textbooks (130+ layouts) and 8,272 images from the IBEM dataset. +Chinese and English document formula detection [[link](https://huggingface.co/TonyLee1256/texteller_det/resolve/main/rtdetr_r50vd_6x_coco.onnx?download=true)]: Trained on a total of 11,867 images, consisting of 3,415 images from Chinese textbooks (130+ layouts) and 8,272 images from the [IBEM dataset](https://zenodo.org/records/4757865). ### Formula Detection From 0bb11bebfc93efa1fb28de8a15f6c7c9d66f02ad Mon Sep 17 00:00:00 2001 From: TonyLee1256 <163754792+TonyLee1256@users.noreply.github.com> Date: Mon, 22 Apr 2024 00:07:41 +0800 Subject: [PATCH 4/5] Update infer_det.py --- src/infer_det.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/infer_det.py b/src/infer_det.py index a5047fc..b90a1c8 100644 --- a/src/infer_det.py +++ b/src/infer_det.py @@ -1,9 +1,11 @@ import os import argparse import glob +import subprocess from onnxruntime import InferenceSession from pathlib import Path + from models.det_model.inference import PredictConfig, predict_image @@ -12,8 +14,8 @@ parser.add_argument("--infer_cfg", type=str, help="infer_cfg.yml", default="./models/det_model/model/infer_cfg.yml") parser.add_argument('--onnx_file', type=str, help="onnx model file path", default="./models/det_model/model/rtdetr_r50vd_6x_coco.onnx") -parser.add_argument("--image_dir", type=str) -parser.add_argument("--image_file", type=str, required=True) +parser.add_argument("--image_dir", type=str, default='./testImgs') +parser.add_argument("--image_file", type=str) parser.add_argument("--imgsave_dir", type=str, default="./detect_results") @@ -47,6 +49,10 @@ def get_test_images(infer_dir, infer_img): return images +def download_file(url, filename): + print(f"Downloading {filename}...") + subprocess.run(["wget", "-q", "--show-progress", "-O", filename, url], check=True) + print("Download complete.") if __name__ == '__main__': cur_path = os.getcwd() @@ -54,6 +60,15 @@ if __name__ == '__main__': os.chdir(script_dirpath) FLAGS = parser.parse_args() + + if not os.path.exists(FLAGS.infer_cfg): + infer_cfg_url = "https://huggingface.co/TonyLee1256/texteller_det/resolve/main/infer_cfg.yml?download=true" + download_file(infer_cfg_url, FLAGS.infer_cfg) + + if not os.path.exists(FLAGS.onnx_file): + onnx_file_url = "https://huggingface.co/TonyLee1256/texteller_det/resolve/main/rtdetr_r50vd_6x_coco.onnx?download=true" + download_file(onnx_file_url, FLAGS.onnx_file) + # load image list img_list = get_test_images(FLAGS.image_dir, FLAGS.image_file) # load predictor From 1a7939190fcb95ccc15c47454645036189e0ec1d Mon Sep 17 00:00:00 2001 From: TonyLee1256 <163754792+TonyLee1256@users.noreply.github.com> Date: Mon, 22 Apr 2024 00:08:36 +0800 Subject: [PATCH 5/5] Update rec_infer_from_crop_imgs.py --- src/rec_infer_from_crop_imgs.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/rec_infer_from_crop_imgs.py b/src/rec_infer_from_crop_imgs.py index 73bfa73..89bef18 100644 --- a/src/rec_infer_from_crop_imgs.py +++ b/src/rec_infer_from_crop_imgs.py @@ -11,10 +11,16 @@ if __name__ == '__main__': os.chdir(Path(__file__).resolve().parent) parser = argparse.ArgumentParser() parser.add_argument( - '-img', + '-img_dir', type=str, - required=True, - help='path to the input image' + help='path to the input image', + default='./detect_results/subimages' + ) + parser.add_argument( + '-output_dir', + type=str, + help='path to the output dir', + default='./rec_results' ) parser.add_argument( '--inference-mode',