Home

Awesome

FAST

PWC PWC PWC PWC

This repository is an official implementation of the FAST: Faster Arbitrarily-Shaped Text Detector with Minimalist Kernel Representation.

<details open> <summary>Text Detection</summary> </details>

News

Zero-shot Video Text Detection Demo

https://user-images.githubusercontent.com/23737120/212238686-64a68149-1c09-44cb-ba26-e1dfb609db9e.mp4

Catalog

Abstract

We propose an accurate and efficient scene text detection framework, termed FAST (i.e., Faster Arbitrarily-Shaped Text detector). Different from recent advanced text detectors that used complicated post-processing and hand-crafted network architectures, resulting in low inference speed, FAST has two new designs. (1) We design a minimalist kernel representation (only has 1-channel output) to model text with arbitrary shape, as well as a GPU-parallel post-processing to efficiently assemble text lines with a negligible time overhead. (2) We search the network architecture tailored for text detection, leading to more powerful features than most networks that are searched for image classification. Benefiting from these two designs, FAST achieves an excellent trade-off between accuracy and efficiency on several challenging datasets, including Total Text, CTW1500, ICDAR 2015, and MSRA-TD500. For example, FAST-T yields 81.6% F-measure at 152 FPS on Total-Text, outperforming the previous fastest method by 1.7 points and 70 FPS in terms of accuracy and speed. With TensorRT optimization, the inference speed can be further accelerated to over 600 FPS.

Method

<img width="1382" alt="image" src="https://user-images.githubusercontent.com/23737120/206380932-c226d94e-0c07-4ffe-94fe-07e65efa6068.png">

Usage

Installation

First, clone the repository locally:

git clone https://github.com/czczup/FAST

Then, install PyTorch 1.1.0+, torchvision 0.3.0+, and other requirements:

# for python3 (training and testing)
pip install editdistance
pip install Polygon3
pip install pyclipper
pip install Cython
pip install mmcv
pip install prefetch_generator
pip install scipy
pip install yacs
pip install tqdm
pip install opencv-python==4.6.0.66

# for python2 (evaluation)
# the evaluation code is from pan_pp.pytorch
pip2 install numpy==1.10
pip2 install scipy==1.2.2
pip2 install polygon2

Finally, compile codes of post-processing:

# build pse, pa, and ccl algorithms
sh ./compile.sh

Dataset

Please refer to dataset/README.md for dataset preparation.

Training

First, please download the pretrained checkpoints:

mkdir pretrained/
cd pretrained/
wget https://github.com/czczup/FAST/releases/download/release/fast_tiny_ic17mlt_640.pth
wget https://github.com/czczup/FAST/releases/download/release/fast_small_ic17mlt_640.pth
wget https://github.com/czczup/FAST/releases/download/release/fast_base_ic17mlt_640.pth
cd ../

Then, run the following command for training:

CUDA_VISIBLE_DEVICES=0,1,2,3 python train.py <config>

For example:

CUDA_VISIBLE_DEVICES=0,1,2,3 python train.py config/fast/tt/fast_base_tt_800_finetune_ic17mlt.py

Testing

Evaluate single checkpoint

python test.py <config> <checkpoint> --ema
cd eval/
./eval_{DATASET}.sh

For example:

python test.py config/fast/tt/fast_base_tt_800_finetune_ic17mlt.py download/fast_base_tt_800_finetune_ic17mlt.pth --ema
cd eval/
sh eval_tt.sh

It should give:

Precision:_0.900048239267_______/Recall:_0.851633393829/Hmean:_0.875171745978

Evaluate all checkpoints in one folder

python test_all.py <config> <checkpoint-dir> --dataset [{tt/ctw/ic15/msra}] --start-ep 1 --end-ep 60 --ema

Evaluate the speed

python test.py <config> --report-speed

For example:

python test.py config/fast/tt/fast_base_tt_800_finetune_ic17mlt.py --report-speed

Visulization

Run the following script to visulize the prediction results:

python visualize.py --dataset [{tt/ctw/ic15/msra}] --show-gt

visulization

Model Zoo

IC17-MLT Pretrained FAST Models

ModelBackbonePretrainResolution#ParamsConfigDownload
FAST-TTextNet-TImageNet-1K640x6408.5Mconfigckpt | log
FAST-STextNet-SImageNet-1K640x6409.7Mconfigckpt | log
FAST-BTextNet-BImageNet-1K640x64010.6Mconfigckpt | log
FAST-TTextNet-T-640x6408.5M-ckpt
FAST-STextNet-S-640x6409.7M-ckpt
FAST-BTextNet-B-640x64010.6M-ckpt

Results on Total-Text

MethodBackbonePrecisionRecallF-measureFPSConfigDownload
FAST-T-448TextNet-T86.577.281.6152.8configckpt | log
FAST-T-512TextNet-T87.380.083.5131.1configckpt | log
FAST-T-640TextNet-T87.181.484.295.5configckpt | log
FAST-S-512TextNet-S88.381.784.9115.5configckpt | log
FAST-S-640TextNet-S89.181.985.485.3configckpt | log
FAST-B-512TextNet-B89.682.485.893.2configckpt | log
FAST-B-640TextNet-B89.983.286.467.5configckpt | log
FAST-B-800TextNet-B90.085.287.546.0configckpt | log

Results on CTW1500

MethodBackbonePrecisionRecallF-measureFPSConfigDownload
FAST-T-512TextNet-T85.577.981.5129.1configckpt | log
FAST-S-512TextNet-S85.678.782.0112.9configckpt | log
FAST-B-512TextNet-B85.780.282.992.6configckpt | log
FAST-B-640TextNet-B87.880.984.266.5configckpt | log

Results on ICDAR 2015

MethodBackbonePrecisionRecallF-measureFPSConfigDownload
FAST-T-736TextNet-T86.077.981.760.9configckpt | log
FAST-S-736TextNet-S86.379.882.953.9configckpt | log
FAST-B-736TextNet-B88.081.784.742.7configckpt | log
FAST-B-896TextNet-B89.283.686.331.8configckpt | log
FAST-B-1280TextNet-B89.784.687.115.7configckpt | log

Results on MSRA-TD500

MethodBackbonePrecisionRecallF-measureFPSConfigDownload
FAST-T-512TextNet-T91.178.884.5137.2configckpt | log
FAST-T-736TextNet-T88.181.984.979.6configckpt | log
FAST-S-736TextNet-S91.681.786.472.0configckpt | log
FAST-B-736TextNet-B92.183.087.356.8configckpt | log

Citation

If this work is helpful for your research, please consider citing the following BibTeX entry.

@misc{chen2021fast,
  title={FAST: Faster Arbitrarily-Shaped Text Detector with Minimalist Kernel Representation}, 
  author={Zhe Chen and Jiahao Wang and Wenhai Wang and Guo Chen and Enze Xie and Ping Luo and Tong Lu},
  year={2021},
  eprint={2111.02394},
  archivePrefix={arXiv},
  primaryClass={cs.CV}
}

License

This project is released under the Apache 2.0 license.