7行python代码实现核算检测批量复查

简介: 7行python代码实现核算检测批量复查

一、为什么要弄该系统?


众所周知,当前大势下,核酸检测,验证复查是每天都少不了的场景。但是检测设备昂贵,且有次数限制,有的还需要向卫生相关部门申请,那么有没有可能搭建一套自己的核酸检测复查系统呢?答案是肯定的。

image.png


二、PaddleHub快速部署


基本的思路是使用PaddleHub OCR模型对手机健康码等信息进行识别。可省去模型训练之烦恼,快速得到想要的效果,具体代码如下:


1.引入paddlehub包


import paddlehub as hub


2.引入 ocr 模型


调用chinese_ocr_db_crnn_server识别模型


三、代码


import paddlehub as hub, cv2, os, csv
if __name__ == '__main__':
    module = hub.Module(name="chinese_ocr_db_crnn_server")
    for root, dirs, all_list_path in os.walk("images"):
        results = module.recognize_text(images=[cv2.imread("images/" + image_path) for image_path in all_list_path],
                                        output_dir='ocr_result', visualization=True, box_thresh=0.5,
                                        text_thresh=0.5)  # use_gpu=True,
        for result in results:
            print(result)


四、检测效果


{'save_path': 'ocr_result\\ndarray_1650280393.5890908.jpg', 'data': [{'text': 'HOD SGmN ', 'confidence': 0.5865637063980103, 'text_box_position': [[50, 0], [309, 14], [300, 75], [42, 53]]}, {'text': '3.8', 'confidence': 0.9981439113616943, 'text_box_position': [[289, 19], [329, 9], [337, 34], [298, 43]]}, {'text': '*56023:35', 'confidence': 0.8589357733726501, 'text_box_position': [[781, 19], [1018, 19], [1018, 56], [781, 56]]}, {'text': 'HD2', 'confidence': 0.9982423782348633, 'text_box_position': [[59, 43], [115, 43], [115, 68], [59, 68]]}, {'text': 'K/s', 'confidence': 0.9931795597076416, 'text_box_position': [[298, 39], [334, 39], [334, 63], [298, 63]]}, {'text': '核酸与抗体检测结:', 'confidence': 0.9794898629188538, 'text_box_position': [[50, 129], [697, 129], [697, 173], [50, 173]]}, {'text': '查询人员:', 'confidence': 0.9450464844703674, 'text_box_position': [[53, 275], [244, 275], [244, 321], [53, 321]]}, {'text': '切换', 'confidence': 0.9991570711135864, 'text_box_position': [[911, 304], [1029, 304], [1029, 363], [911, 363]]}, {'text': '张三33**************11', 'confidence': 0.9848297834396362, 'text_box_position': [[90, 333], [663, 324], [663, 385], [90, 394]]}, {'text': '省内核酸结果', 'confidence': 0.9990420937538147, 'text_box_position': [[157, 519], [435, 519], [435, 563], [157, 563]]}, {'text': '采样时间:2022-04-0614时', 'confidence': 0.974065363407135, 'text_box_position': [[98, 641], [694, 641], [694, 684], [98, 684]]}, {'text': '检测时间:2022-04-0700时', 'confidence': 0.9998931884765625, 'text_box_position': [[98, 719], [694, 719], [694, 762], [98, 762]]}, {'text': '阴性', 'confidence': 0.9995075464248657, 'text_box_position': [[852, 716], [945, 706], [950, 758], [857, 767]]}, {'text': '四川大学华西医院', 'confidence': 0.9998956918716431, 'text_box_position': [[98, 794], [424, 794], [424, 838], [98, 838]]}, {'text': '抗体检测结果', 'confidence': 0.9995054602622986, 'text_box_position': [[157, 953], [435, 953], [435, 996], [157, 996]]}, {'text': '未查询到您的检测结果', 'confidence': 0.9969052672386169, 'text_box_position': [[101, 1128], [559, 1128], [559, 1172], [101, 1172]]}, {'text': '服务说明:', 'confidence': 0.9897974133491516, 'text_box_position': [[56, 1326], [284, 1326], [284, 1379], [56, 1379]]}, {'text': '1.本服务支持查询本人14日内核酸检测结果和既往', 'confidence': 0.9986771941184998, 'text_box_position': [[59, 1413], [1015, 1413], [1015, 1450], [59, 1450]]}, {'text': '血清特异性lgG抗体检测结果。', 'confidence': 0.9697466492652893, 'text_box_position': [[56, 1474], [615, 1474], [615, 1518], [56, 1518]]}, {'text': '2.相关查询结果基于国家卫生健康部门数据库,根', 'confidence': 0.9759125709533691, 'text_box_position': [[56, 1555], [1015, 1555], [1015, 1591], [56, 1591]]}, {'text': '据各地检测数据提供,正在不断汇聚更新中。', 'confidence': 0.9888159036636353, 'text_box_position': [[56, 1618], [891, 1618], [891, 1655], [56, 1655]]}, {'text': '四川省应对新型冠状病毒肺炎疫情应急指挥部', 'confidence': 0.978419840335846, 'text_box_position': [[196, 2191], [880, 2191], [880, 2220], [196, 2220]]}, {'text': '四川省大数据中心提供支持', 'confidence': 0.981896162033081, 'text_box_position': [[334, 2242], [745, 2242], [745, 2271], [334, 2271]]}]}
{'save_path': 'ocr_result\\ndarray_1650280437.9316654.jpg', 'data': [{'text': 'HOD SGmN ', 'confidence': 0.5919920206069946, 'text_box_position': [[50, 0], [309, 14], [300, 75], [42, 53]]}, {'text': '3.8', 'confidence': 0.9982979893684387, 'text_box_position': [[289, 19], [329, 9], [337, 34], [298, 43]]}, {'text': '*≥6023:35', 'confidence': 0.8562882542610168, 'text_box_position': [[781, 19], [1018, 19], [1018, 56], [781, 56]]}, {'text': 'HD2', 'confidence': 0.9981972575187683, 'text_box_position': [[59, 43], [115, 43], [115, 68], [59, 68]]}, {'text': 'K/s', 'confidence': 0.9931250214576721, 'text_box_position': [[298, 39], [334, 39], [334, 63], [298, 63]]}, {'text': '核酸与抗体检测结:', 'confidence': 0.9796482920646667, 'text_box_position': [[50, 129], [697, 129], [697, 173], [50, 173]]}, {'text': ':', 'confidence': 0.6901877522468567, 'text_box_position': [[711, 124], [902, 117], [905, 170], [714, 177]]}, {'text': '查询人员:', 'confidence': 0.9437354207038879, 'text_box_position': [[53, 275], [244, 275], [244, 321], [53, 321]]}, {'text': '切换', 'confidence': 0.9991297721862793, 'text_box_position': [[911, 304], [1029, 304], [1029, 363], [911, 363]]}, {'text': '李四\u300033**************11', 'confidence': 0.9692168235778809, 'text_box_position': [[81, 331], [663, 324], [663, 385], [81, 392]]}, {'text': '省内核酸结果', 'confidence': 0.9991196990013123, 'text_box_position': [[157, 519], [435, 519], [435, 563], [157, 563]]}, {'text': '采样时间:2022-04-0614时', 'confidence': 0.9742894172668457, 'text_box_position': [[98, 641], [694, 641], [694, 684], [98, 684]]}, {'text': '检测时间:2022-04-0700时', 'confidence': 0.9998957514762878, 'text_box_position': [[98, 719], [694, 719], [694, 762], [98, 762]]}, {'text': '阴性', 'confidence': 0.9994761943817139, 'text_box_position': [[852, 716], [945, 706], [950, 758], [857, 767]]}, {'text': '四川大学华西医院', 'confidence': 0.9760406017303467, 'text_box_position': [[98, 794], [424, 794], [424, 838], [98, 838]]}, {'text': '抗体检测结果', 'confidence': 0.9995043277740479, 'text_box_position': [[157, 953], [435, 953], [435, 996], [157, 996]]}, {'text': '未查询到您的检测结果', 'confidence': 0.9970100522041321, 'text_box_position': [[101, 1128], [559, 1128], [559, 1172], [101, 1172]]}, {'text': '服务说明:', 'confidence': 0.9902758598327637, 'text_box_position': [[56, 1326], [284, 1326], [284, 1379], [56, 1379]]}, {'text': '1.本服务支持查询本人14日内核酸检测结果和既往', 'confidence': 0.9990904927253723, 'text_box_position': [[59, 1413], [1015, 1413], [1015, 1450], [59, 1450]]}, {'text': '血清特异性lgG抗体检测结果。', 'confidence': 0.9744695425033569, 'text_box_position': [[56, 1474], [615, 1474], [615, 1518], [56, 1518]]}, {'text': '2.相关查询结果基于国家卫生健康部门数据库,根', 'confidence': 0.9748148918151855, 'text_box_position': [[56, 1555], [1015, 1555], [1015, 1591], [56, 1591]]}, {'text': '据各地检测数据提供,正在不断汇聚更新中。', 'confidence': 0.986540675163269, 'text_box_position': [[56, 1618], [891, 1618], [891, 1655], [56, 1655]]}, {'text': '四川省应对新型冠状病毒肺炎疫情应急指挥部', 'confidence': 0.9854202270507812, 'text_box_position': [[196, 2191], [880, 2191], [880, 2220], [196, 2220]]}, {'text': '四川省大数据中心提供支持', 'confidence': 0.9782963991165161, 'text_box_position': [[334, 2242], [745, 2242], [745, 2271], [334, 2271]]}]}
{'save_path': 'ocr_result\\ndarray_1650280482.2817101.jpg', 'data': [{'text': 'HOD SGmN ', 'confidence': 0.5919920206069946, 'text_box_position': [[50, 0], [309, 14], [300, 75], [42, 53]]}, {'text': '3.8', 'confidence': 0.9982979893684387, 'text_box_position': [[289, 19], [329, 9], [337, 34], [298, 43]]}, {'text': '*≥6023:35', 'confidence': 0.8562882542610168, 'text_box_position': [[781, 19], [1018, 19], [1018, 56], [781, 56]]}, {'text': 'HD2', 'confidence': 0.9981972575187683, 'text_box_position': [[59, 43], [115, 43], [115, 68], [59, 68]]}, {'text': 'K/s', 'confidence': 0.9931250214576721, 'text_box_position': [[298, 39], [334, 39], [334, 63], [298, 63]]}, {'text': '核酸与抗体检测结:', 'confidence': 0.9796482920646667, 'text_box_position': [[50, 129], [697, 129], [697, 173], [50, 173]]}, {'text': ':', 'confidence': 0.6901877522468567, 'text_box_position': [[711, 124], [902, 117], [905, 170], [714, 177]]}, {'text': '查询人员:', 'confidence': 0.9880987405776978, 'text_box_position': [[53, 275], [241, 275], [241, 321], [53, 321]]}, {'text': '切换', 'confidence': 0.9991297721862793, 'text_box_position': [[911, 304], [1029, 304], [1029, 363], [911, 363]]}, {'text': '王五33**************11', 'confidence': 0.9995682835578918, 'text_box_position': [[95, 333], [663, 326], [663, 385], [95, 392]]}, {'text': '省内核酸结果', 'confidence': 0.9991196990013123, 'text_box_position': [[157, 519], [435, 519], [435, 563], [157, 563]]}, {'text': '采样时间:2022-04-0614时', 'confidence': 0.9742894172668457, 'text_box_position': [[98, 641], [694, 641], [694, 684], [98, 684]]}, {'text': '检测时间:2022-04-0700时', 'confidence': 0.9998957514762878, 'text_box_position': [[98, 719], [694, 719], [694, 762], [98, 762]]}, {'text': '阴性', 'confidence': 0.9994761943817139, 'text_box_position': [[852, 716], [945, 706], [950, 758], [857, 767]]}, {'text': '四川大学华西医院', 'confidence': 0.9760406017303467, 'text_box_position': [[98, 794], [424, 794], [424, 838], [98, 838]]}, {'text': '抗体检测结果', 'confidence': 0.9995043277740479, 'text_box_position': [[157, 953], [435, 953], [435, 996], [157, 996]]}, {'text': '未查询到您的检测结果', 'confidence': 0.9970100522041321, 'text_box_position': [[101, 1128], [559, 1128], [559, 1172], [101, 1172]]}, {'text': '服务说明:', 'confidence': 0.9902758598327637, 'text_box_position': [[56, 1326], [284, 1326], [284, 1379], [56, 1379]]}, {'text': '1.本服务支持查询本人14日内核酸检测结果和既往', 'confidence': 0.9990904927253723, 'text_box_position': [[59, 1413], [1015, 1413], [1015, 1450], [59, 1450]]}, {'text': '血清特异性lgG抗体检测结果。', 'confidence': 0.9744695425033569, 'text_box_position': [[56, 1474], [615, 1474], [615, 1518], [56, 1518]]}, {'text': '2.相关查询结果基于国家卫生健康部门数据库,根', 'confidence': 0.9748148918151855, 'text_box_position': [[56, 1555], [1015, 1555], [1015, 1591], [56, 1591]]}, {'text': '据各地检测数据提供,正在不断汇聚更新中。', 'confidence': 0.986540675163269, 'text_box_position': [[56, 1618], [891, 1618], [891, 1655], [56, 1655]]}, {'text': '四川省应对新型冠状病毒肺炎疫情应急指挥部', 'confidence': 0.9854202270507812, 'text_box_position': [[196, 2191], [880, 2191], [880, 2220], [196, 2220]]}, {'text': '四川省大数据中心提供支持', 'confidence': 0.9782963991165161, 'text_box_position': [[334, 2242], [745, 2242], [745, 2271], [334, 2271]]}]}



image.pngimage.pngimage.png


五、其他


可以在学校等需要需要批量广泛核酸核查场景使用。识别结果可保存至excel表格,从而减轻工作量。


目录
相关文章
|
5月前
|
存储 算法 调度
【复现】【遗传算法】考虑储能和可再生能源消纳责任制的售电公司购售电策略(Python代码实现)
【复现】【遗传算法】考虑储能和可再生能源消纳责任制的售电公司购售电策略(Python代码实现)
286 26
|
5月前
|
测试技术 开发者 Python
Python单元测试入门:3个核心断言方法,帮你快速定位代码bug
本文介绍Python单元测试基础,详解`unittest`框架中的三大核心断言方法:`assertEqual`验证值相等,`assertTrue`和`assertFalse`判断条件真假。通过实例演示其用法,帮助开发者自动化检测代码逻辑,提升测试效率与可靠性。
481 1
|
5月前
|
机器学习/深度学习 算法 调度
基于多动作深度强化学习的柔性车间调度研究(Python代码实现)
基于多动作深度强化学习的柔性车间调度研究(Python代码实现)
300 1
|
4月前
|
测试技术 Python
Python装饰器:为你的代码施展“魔法”
Python装饰器:为你的代码施展“魔法”
316 100
|
4月前
|
开发者 Python
Python列表推导式:一行代码的艺术与力量
Python列表推导式:一行代码的艺术与力量
489 95
|
5月前
|
Python
Python的简洁之道:5个让代码更优雅的技巧
Python的简洁之道:5个让代码更优雅的技巧
307 104
|
5月前
|
开发者 Python
Python神技:用列表推导式让你的代码更优雅
Python神技:用列表推导式让你的代码更优雅
560 99
|
4月前
|
缓存 Python
Python装饰器:为你的代码施展“魔法
Python装饰器:为你的代码施展“魔法
239 88
|
5月前
|
IDE 开发工具 开发者
Python类型注解:提升代码可读性与健壮性
Python类型注解:提升代码可读性与健壮性
317 102
|
4月前
|
监控 机器人 编译器
如何将python代码打包成exe文件---PyInstaller打包之神
PyInstaller可将Python程序打包为独立可执行文件,无需用户安装Python环境。它自动分析代码依赖,整合解释器、库及资源,支持一键生成exe,方便分发。使用pip安装后,通过简单命令即可完成打包,适合各类项目部署。
910 68

推荐镜像

更多