Views
No views yet
1git clone https://github.com/Topdu/OpenOCR.git
2pip install onnxruntime
3cd OpenOCR
4huggingface-cli download topdu/unirec_0_1b_onnx --local-dir ./unirec_0_1b_onnxpython ./tools/depolyment/unirec_onnx/infer_onnx.py --image /path/to/image1conda create -n openocr python==3.10
2conda activate openocr
3# install gpu version torch >=1.13.0
4conda install pytorch==2.2.0 torchvision==0.17.0 torchaudio==2.2.0 pytorch-cuda=11.8 -c pytorch -c nvidia
5# or cpu version
6conda install pytorch torchvision torchaudio cpuonly -c pytorch
7git clone https://github.com/Topdu/OpenOCR.git1cd OpenOCR
2pip install -r requirements.txt
3# download model from modelscope
4modelscope download topdktu/unirec-0.1b --local_dir ./unirec-0.1b
5# or download model from huggingface
6huggingface-cli download topdu/unirec-0.1b --local-dir ./unirec-0.1bpython tools/infer_rec.py --c ./configs/rec/unirec/focalsvtr_ardecoder_unirec.yml --o Global.infer_img=/path/img_fold or /path/img_file1pip install gradio==4.20.0
2python demo_unirec.py1pip install PyMuPDF
2pip install pdf2image
3pip install numpy==1.26.4
4pip install albumentations==1.4.24
5pip install transformers==4.49.0
6pip install -U flash-attn --no-build-isolation1|-UniRec40M # Main directory for UniRec40M dataset
2|-OpenOCR # Directory for OpenOCR-related files
3|-evaluation # Directory for evaluation dataset1# downloading small data for quickly training
2huggingface-cli download topdu/UniRec40M --include "hiertext_lmdb/**" --repo-type dataset --local-dir ./UniRec40M/
3huggingface-cli download topdu/OpenOCR-Data --include "evaluation/**" --repo-type dataset --local-dir ./CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python -m torch.distributed.launch --master_port=23333 --nproc_per_node=8 tools/train_rec.py --c configs/rec/unirec/focalsvtr_ardecoder_unirec.ymldata.mdb.part_* (located in HWDB2Train, ch_pdf_lmdb, and en_pdf_lmdb) into a single data.mdb file. Execute the commands below step by step:1# downloading full data
2huggingface-cli download topdu/UniRec40M --repo-type dataset --local-dir ./UniRec40M/
3cd UniRec40M/HWDB2Train/image_lmdb & cat data.mdb.part_* > data.mdb
4cd UniRec40M/ch_pdf_lmdb & cat data.mdb.part_* > data.mdb
5cd UniRec40M/en_pdf_lmdb & cat data.mdb.part_* > data.mdbconfigs/rec/unirec/focalsvtr_ardecoder_unirec.yml file as follows:1...
2Train:
3 dataset:
4 name: NaSizeDataSet
5 divided_factor: ÷d_factor [64, 64] # w, h
6 max_side: &max_side [960, 1408] # [64*30, 64*44] # w, h [960, 1408] #
7 root_path: path/to/UniRec40M
8 add_return: True
9 zoom_min_factor: 4
10 use_zoom: True
11 all_data: True
12 test_data: False
13 use_aug: True
14 use_linedata: True
15 transforms:
16 - UniRecLabelEncode: # Class handling label
17 max_text_length: *max_text_length
18 vlmocr: True
19 tokenizer_path: *vlm_ocr_config # path to tokenizer, e.g. 'vocab.json', 'merges.txt'
20 - KeepKeys:
21 keep_keys: ['image', 'label', 'length'] # dataloader will return list in this order
22 sampler:
23 name: NaSizeSampler
24 # divide_factor: to ensure the width and height dimensions can be devided by downsampling multiple
25 min_bs: 1
26 max_bs: 24
27 loader:
28 shuffle: True
29 batch_size_per_card: 64
30 drop_last: True
31 num_workers: 8
32...1@article{du2025unirec,
2 title={UniRec-0.1B: Unified Text and Formula Recognition with 0.1B Parameters},
3 author={Yongkun Du and Zhineng Chen and Yazhen Xie and Weikang Bai and Hao Feng and Wei Shi and Yuchen Su and Can Huang and Yu-Gang Jiang},
4 journal={arXiv preprint arXiv:2512.21095},
5 year={2025}
6}