2022-04-28 06:39:26 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								# SAST
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								-  [1. 算法简介 ](#1 ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								-  [2. 环境配置 ](#2 ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								-  [3. 模型训练、评估、预测 ](#3 ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    -  [3.1 训练 ](#3-1 )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    -  [3.2 评估 ](#3-2 )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    -  [3.3 预测 ](#3-3 )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								-  [4. 推理部署 ](#4 ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    -  [4.1 Python推理 ](#4-1 )
							 
						 
					
						
							
								
									
										
										
										
											2022-04-28 11:31:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    -  [4.2 C++推理 ](#4-2 )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    -  [4.3 Serving服务化部署 ](#4-3 )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    -  [4.4 更多推理部署 ](#4-4 )
							 
						 
					
						
							
								
									
										
										
										
											2022-04-28 06:39:26 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								-  [5. FAQ ](#5 ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								< a  name = "1" > < / a >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								## 1. 算法简介
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								论文信息:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								>  [A Single-Shot Arbitrarily-Shaped Text Detector based on Context Attended Multi-Task Learning](https://arxiv.org/abs/1908.05498)
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								>  Wang, Pengfei and Zhang, Chengquan and Qi, Fei and Huang, Zuming and En, Mengyi and Han, Junyu and Liu, Jingtuo and Ding, Errui and Shi, Guangming
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								>  ACM MM, 2019
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								在ICDAR2015文本检测公开数据集上, : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								|模型|骨干网络|配置文件|precision|recall|Hmean|下载链接|
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								| --- | --- | --- | --- | --- | --- | --- |
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								|SAST|ResNet50_vd|[configs/det/det_r50_vd_sast_icdar15.yml ](../../configs/det/det_r50_vd_sast_icdar15.yml )|91.39%|83.77%|87.42%|[训练模型 ](https://paddleocr.bj.bcebos.com/dygraph_v2.0/en/det_r50_vd_sast_icdar15_v2.0_train.tar )|
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								在Total-text文本检测公开数据集上, : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								|模型|骨干网络|配置文件|precision|recall|Hmean|下载链接|
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								| --- | --- | --- | --- | --- | --- | --- |
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								|SAST|ResNet50_vd|[configs/det/det_r50_vd_sast_totaltext.yml ](../../configs/det/det_r50_vd_sast_totaltext.yml )|89.63%|78.44%|83.66%|[训练模型 ](https://paddleocr.bj.bcebos.com/dygraph_v2.0/en/det_r50_vd_sast_totaltext_v2.0_train.tar )|
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								< a  name = "2" > < / a >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								## 2. 环境配置
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								请先参考[《运行环境准备》 ](./environment.md )配置PaddleOCR运行环境, 《项目克隆》 ](./clone.md )克隆项目代码。
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								< a  name = "3" > < / a >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								## 3. 模型训练、评估、预测
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								请参考[文本检测训练教程 ](./detection.md )。PaddleOCR对代码进行了模块化, 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								< a  name = "4" > < / a >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								## 4. 推理部署
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								< a  name = "4-1" > < / a >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								### 4.1 Python推理
  
						 
					
						
							
								
									
										
										
										
											2022-04-28 11:31:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
										 
							
							
								#### (1). 四边形文本检测模型( )   
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								首先将SAST文本检测训练过程中保存的模型, , 模型下载地址 ](https://paddleocr.bj.bcebos.com/dygraph_v2.0/en/det_r50_vd_sast_icdar15_v2.0_train.tar )),可以使用如下命令进行转换:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								python3 tools/export_model.py -c configs/det/det_r50_vd_sast_icdar15.yml -o Global.pretrained_model=./det_r50_vd_sast_icdar15_v2.0_train/best_accuracy  Global.save_inference_dir=./inference/det_sast_ic15
							 
						 
					
						
							
								
									
										
										
										
											2022-04-28 06:39:26 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2022-04-28 11:31:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
										 
							
							
								**SAST文本检测模型推理, `--det_algorithm="SAST"` **,可以执行如下命令:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								python3 tools/infer/predict_det.py --det_algorithm="SAST" --image_dir="./doc/imgs_en/img_10.jpg" --det_model_dir="./inference/det_sast_ic15/"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								可视化文本检测结果默认保存到`./inference_results` 文件夹里面,结果文件的名称前缀为'det_res'。结果示例如下:
							 
						 
					
						
							
								
									
										
										
										
											2022-04-28 06:39:26 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-28 11:31:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								#### (2). 弯曲文本检测模型( )   
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								首先将SAST文本检测训练过程中保存的模型, , ( 模型下载地址 ](https://paddleocr.bj.bcebos.com/dygraph_v2.0/en/det_r50_vd_sast_totaltext_v2.0_train.tar )),可以使用如下命令进行转换:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								python3 tools/export_model.py -c configs/det/det_r50_vd_sast_totaltext.yml -o Global.pretrained_model=./det_r50_vd_sast_totaltext_v2.0_train/best_accuracy  Global.save_inference_dir=./inference/det_sast_tt
							 
						 
					
						
							
								
									
										
										
										
											2022-04-28 06:39:26 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-11-15 14:25:39 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
										 
							
							
								SAST文本检测模型推理, `--det_algorithm="SAST"` ,同时,还需要增加参数`--det_box_type=poly` ,可以执行如下命令:
							 
						 
					
						
							
								
									
										
										
										
											2022-04-28 11:31:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2022-11-15 14:25:39 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								python3 tools/infer/predict_det.py --det_algorithm="SAST" --image_dir="./doc/imgs_en/img623.jpg" --det_model_dir="./inference/det_sast_tt/" --det_box_type='poly'
							 
						 
					
						
							
								
									
										
										
										
											2022-04-28 11:31:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2022-04-28 06:39:26 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								可视化文本检测结果默认保存到`./inference_results` 文件夹里面,结果文件的名称前缀为'det_res'。结果示例如下:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-28 11:31:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								**注意**: , , , , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								< a  name = "4-2" > < / a >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								### 4.2 C++推理
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								暂未支持
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								< a  name = "4-3" > < / a >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								### 4.3 Serving服务化部署
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								暂未支持
							 
						 
					
						
							
								
									
										
										
										
											2022-04-28 06:39:26 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-28 11:31:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								< a  name = "4-4" > < / a >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								### 4.4 更多推理部署
  
						 
					
						
							
								
									
										
										
										
											2022-04-28 06:39:26 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-28 11:31:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								暂未支持
							 
						 
					
						
							
								
									
										
										
										
											2022-04-28 06:39:26 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								< a  name = "5" > < / a >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								## 5. FAQ
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								## 引用
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								```bibtex
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								@inproceedings {wang2019single, 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  title={A Single-Shot Arbitrarily-Shaped Text Detector based on Context Attended Multi-Task Learning},
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  author={Wang, Pengfei and Zhang, Chengquan and Qi, Fei and Huang, Zuming and En, Mengyi and Han, Junyu and Liu, Jingtuo and Ding, Errui and Shi, Guangming},
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  booktitle={Proceedings of the 27th ACM International Conference on Multimedia},
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  pages={1277--1285},
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  year={2019}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								```