基于CRAFT实现的快速准确文本检测库
craft-text-detector的Python项目详细描述
CRAFT:用于文本检测的字符区域感知
打包,基于Pythorch,易于使用,跨平台版本的CRAFT text detector | Paper
概述
工艺文本检测器的Pythorch实现,通过探索每个字符区域和字符之间的亲和力来有效地检测文本区域。在对字符区域和相似度进行阈值化后,只需在二值映射图上寻找最小边界矩形,即可得到文本的边界框。在
入门
安装
- 使用conda for Linux、Mac和Windows安装(首选):
conda install -c fcakyon craft-text-detector
- 使用pip for Linux和Mac安装:
基本用法
# import Craft classfromcraft_text_detectorimportCraft# set image path and export folder directoryimage_path='figures/idcard.png'output_dir='outputs/'# create a craft instancecraft=Craft(output_dir=output_dir,crop_type="poly",cuda=False)# apply craft text detection and export detected regions to output directoryprediction_result=craft.detect_text(image_path)# unload models from ram/gpucraft.unload_craftnet_model()craft.unload_refinenet_model()
高级用法
# import craft functionsfromcraft_text_detectorimport(read_image,load_craftnet_model,load_refinenet_model,get_prediction,export_detected_regions,export_extra_results,empty_cuda_cache)# set image path and export folder directoryimage_path='figures/idcard.png'output_dir='outputs/'# read imageimage=read_image(image_path)# load modelsrefine_net=load_refinenet_model(cuda=True)craft_net=load_craftnet_model(cuda=True)# perform predictionprediction_result=get_prediction(image=image,craft_net=craft_net,refine_net=refine_net,text_threshold=0.7,link_threshold=0.4,low_text=0.4,cuda=True,long_size=1280)# export detected text regionsexported_file_paths=export_detected_regions(image_path=image_path,image=image,regions=prediction_result["boxes"],output_dir=output_dir,rectify=True)# export heatmap, detection points, box visualizationexport_extra_results(image_path=image_path,image=image,regions=prediction_result["boxes"],heatmaps=prediction_result["heatmaps"],output_dir=output_dir)# unload models from gpuempty_cuda_cache()
- 项目
标签: