textract

What is OCR anyway and why the buzz? Artificial Intelligence (AI) enables entities with Human Intelligence (us) process data at a large scale — faster and cheaper. Unarguably, a large portion of data is saved digitally- easy to read and analyze. However there is a significant portion of data that is stored in physical documents — both type written and hand-written. How to analyze this category of data. This is where fascinating technology of Optical Character Recognition (OCR) comes in. Using OCR you are able to convert documents into text format of data suitable for editing and searching. This is what OCR is able to do.

无论如何,OCR是什么?为什么嗡嗡声? 人工智能(AI)使具有人类智能(us)的实体能够更快,更便宜地大规模处理数据。 毫无疑问,很大一部分数据都是数字保存的,易于读取和分析。 但是,有很大一部分数据存储在物理文档中-包括书面形式和手写形式。 如何分析此类数据。 这就是引人入胜的光学字符识别(OCR)技术的来源。使用OCR,您可以将文档转换为适合编辑和搜索的数据文本格式。 这就是OCR能够做到的。

Gerd Altmann from Gerd Altmann在 Pixabay Pixabay上发布

In the article we will focus on two well know OCR frameworks:

在本文中,我们将重点介绍两个众所周知的OCR框架:

  1. Tesseract OCR — free software, released under the Apache License, Version 2.0 - development has been sponsored by Google since 2006.

    Tesseract OCR是一种免费软件,根据Apache许可证2.0版发布,自2006年以来一直由Google赞助。

  2. Amazon Textract OCR — fully managed service from Amazon, uses machine learning to automatically extract text and data

    Amazon Textract OCR —来自Amazon的完全托管服务,使用机器学习自动提取文本和数据

We will compare the OCR capabilities of these two frameworks. Let's start by a simple image as below:

我们将比较这两个框架的OCR功能。 让我们从一个简单的图像开始,如下所示:

Image by Author — typewritten.jpg
由作者提供图像— typewriter.jpg
$ git clone https://github.com/mkukreja1/blogs.git

Download and Install Notebook blogs/ocr/OCR.ipynb

下载并安装Notebook博客/ocr/OCR.ipynb

!pip install opencv-python!pip install pytesseract!pip install pyenchantimport cv2import pytesseractimport refrom pytesseract import Outputimg_typewritten = cv2.imread('typewritten.jpg')custom_config = r'--oem 3 --psm 6'txt_typewritten=pytesseract.image_to_string(img_typewritten, config=custom_config)print(txt_typewritten)

OCR Output using Tesseract OCR:

使用Tesseract OCR的OCR输出:

BEST PICTURE FORD V FERRARITHE IRISHMANJOJO RABBITJOKERLITTLE WOMENMARRIAGE STORY1917ONCE UPON A TIME…IN HOLLYWOODPARASITE

最佳影片FORD V FERRARITHE IRISHMANJOJO RABBITJOKERLITTLE女子婚姻故事1917年一次…在好莱坞寄生虫中

OCR Output using Amazon Textract OCR:

使用Amazon Textract OCR的OCR输出:

Both frameworks performed exactly the same. Lets see how handwritten text compares.

两个框架的执行情况完全相同。 让我们看一下手写文本的比较。

Image by Author — handwritten.jpg
图片由作者— handwriting.jpg
img_handwritten = cv2.imread('handwritten.jpg')txt_handwritten=pytesseract.image_to_string(img_handwritten)print(txt_handwritten)

OCR Output using Tesseract OCR:

使用Tesseract OCR的OCR输出:

<>

<>

mhassadeyVWENS YEA) sore

mhassadeyVYENS YEA)疮

&&. a)OW!NS anéLp Real Estate Group

&&。 OW!NSanéLp房地产集团

RKSHIRE | AmbassadorH ATH. AWAY | Real EstatelomeServices

RKSHIRE | ATH大使。 离开房地产服务

Ky Ie,aa Nim So mul for meetWith me today | Ht wis qed CatchingWp and Vin glad 10 hear Mk Ke wellfor bu. | Lovie Brwoud 10 Seeing YouAA aiv Go| Cheers|

Ky Ie,aa Nim So mul今天与我见面| Ht wis qed CatchingWp和Vin很高兴10听到Mk Ke wellfor bu。 | Lovie Brwoud 10看到YouAA aiv Go | 干杯|

Megan Owens, Realtor 402–689–4984 www.ForSalebyMegan.

梅根·欧文斯(Megan Owens),房地产经纪人402–689–4984 www.ForSalebyMegan 。

MMS

彩信

com

com

OCR Output using Amazon Textract OCR:

使用Amazon Textract OCR的OCR输出:

Image by Author
图片作者

Amazon Textract OCR performed marginally better than Tesseract OCR for handwritten text.

Amazon Textract OCR在手写文本方面的表现略优于Tesseract OCR

Now we will try a busy image.

现在,我们将尝试繁忙的图像。

Image by Author — invoice-sample.jpg
图片由作者— invoice-sample.jpg
img_invoice = cv2.imread('invoice-sample.jpg')custom_config = r'--oem 3 --psm 6'txt_invoice=pytesseract.image_to_string(img_invoice, config=custom_config)print(txt_invoice)

OCR Output using Tesseract OCR:

使用Tesseract OCR的OCR输出:

http://mrsinvoice.comI 7Your Company LLC Address 123, State, My Country P 111–222–333, F 111–222–334BILL TO:P: 111–222–333, F: 111–222–334 a. zcient@eromplentContact Phone 101–102–103john Doe office ayment Terms ‘ash on DeliveryOffice Road 38P: 111–333–222, F: 122–222–334 Amount Due: $4,170office@example.netNO PRODUCTS / SERVICE QUANTITY / RATE / UNIT AMOUNTHOURS: PRICE1 aye 2 $20 $402 | Steering Wheel 5 $10 $503 | Engine oil 10 $15 $1504 | Brake Pad 24 $1000 $2,400Subtotal $275Tax (10%) $27.5Grand Total $302.5‘THANK YOU FOR YOUR BUSINESS

http://mrsinvoice.com I 7Your Company LLC地址123,State,My Country P 111–222–333,F 111–222–334BILL TO:P:111–222–333,F:111–222–334 a。 zcient @ eromplentContact电话101–102–103john Doe办公室付款条款'ash on DeliveryOffice Road 38P:111–333–222,F:122–222–334应付金额:$ 4,170 office@example.net没有产品/服务数量/价格/ UNIT AMOUNTHOURS:PRICE1 aye 2 $ 20 $ 402 | 方向盘5 $ 10 $ 503 | 机油10 $ 15 $ 1504 | 刹车片24 $ 1000 $ 2,400小计$ 275税(10%)$ 27.5总计$ 302.5'谢谢您的生意

OCR Output using Amazon Textract OCR:

使用Amazon Textract OCR的OCR输出:

Image By Author
图片作者

Amazon Textract identifies tables and forms in documents. This is neat.

Amazon Textract可以识别文档中的表格和表格。 这很整齐

Image By Author
图片作者

高级功能—拼写检查(Advanced Features — Spell Checking)

Results from an OCR scan are often fed into an NLP model. Therefore, it is important to have a high degree of accuracy of the resulting text. We can handle it two ways:

OCR扫描的结果通常被输入到NLP模型中。 因此,重要的是要高度保证结果文本的准确性。 我们可以通过两种方式处理它:

Pass every work through a spell-checker module like enchant

通过拼写检查器模块(如附魔)传递所有作品

Option 1 — if spell check failed — Mask/remove the word from the resulting text

选项1-如果拼写检查失败-从结果文本中屏蔽/删除单词

Option 2 — if spell check failed — Use spell-checker suggestions and edit the resulting text

选项2 –如果拼写检查失败–使用拼写检查器建议并编辑结果文本

Enchant module is very frequently used in Python to check the spelling of words based on dictionary. In addition to spell checking enchant can give suggestions to correct words.

Enchant模块在Python中非常常用,用于根据字典检查单词的拼写。 除拼写检查外,附魔还可以提供一些建议以纠正单词。

img = cv2.imread('invoice-sample.jpg')text = pytesseract.image_to_data(img, output_type='data.frame')text = text[text.conf != -1]lines = text.groupby('block_num')['text'].apply(list)print(lines[25])

[‘‘THANK’, ‘YOU’, ‘FOR’, ‘YOUR’, ‘BUSINESS.’]

[ “谢谢” ,“您”,“支持”,“您的”,“业务”。]

Note that the first word seems to have an spelling issue.

请注意,第一个单词似乎存在拼写问题。

import enchantdict_check = enchant.Dict("en_US")for word in lines[25]:    if (dict_check.check(word)):        print(word+ ' - Dictionary Check Valid')    else:        print(word+ ' - Dictionary Check Valid Invalid')        print('Valid Suggestions')        print(dict_check.suggest(word))

‘THANK — Dictionary Check Valid InvalidValid Suggestions[‘THANK’]YOU — Dictionary Check ValidFOR — Dictionary Check ValidYOUR — Dictionary Check ValidBUSINESS. — Dictionary Check Valid

'谢谢-字典检查Valid InvalidValid建议['THANK']您-字典检查ValidFOR-字典检查ValidYOUR-字典检查ValidBUSINESS。 —字典检查有效

Note that enchant found the first word invalid and was able to provide a alternative suggestion.

请注意,附魔发现第一个单词无效,并能够提供其他建议。

对NLP使用正则表达式 (Using Regular Expressions for NLP)

My early days in IT (almost 25 years ago) were filled with ups and downs. One day I would learn something new and feel on top of the world. Other days not so much. I remember the day when my manager asked me to work on a pattern-matching problem. I had to do the pattern-matching over data in Oracle. Since I had never done this before, I request him for pointers. The answer I got was was “This can be very easily done using REGEX”. I was a good follower, except there was nothing easy about using REGEX pattern matching). It took me a while to realize that my manager was kidding.

我在IT领域的初期(将近25年前)经历了风风雨雨。 有一天,我会学到一些新东西,并在世界之巅感到满意。 其他日子没有那么多。 我记得那天有一天我的经理要求我研究模式匹配问题。 我必须对Oracle中的数据进行模式匹配。 由于我以前从未做过此事,因此我要求他提供指示。 我得到的答案是“使用REGEX可以很容易地做到这一点”。 我是一个很好的追随者,除了使用REGEX模式匹配并不容易。 我花了一段时间才意识到我的经理在开玩笑。

I still fear using REGEX but can’t escape it…..it still is widely used in Data Science especially NLP. Learning REGEX takes time. I have frequently used websites like https://regex101.com/ for practice.

我仍然担心使用REGEX,但无法逃脱.....它仍然广泛用于数据科学,尤其是NLP。 学习REGEX需要时间。 我经常使用https://regex101.com/这样的网站进行练习。

For example if you want to extract all date fields from a document.

例如,如果要从文档中提取所有日期字段。

d = pytesseract.image_to_data(img, output_type=Output.DICT)keys = list(d.keys())date_pattern = '^(0[1-9]|[12][0-9]|3[01])/(0[1-9]|1[012])/(19|20)\d\d$'n_boxes = len(d['text'])for i in range(n_boxes):    if int(d['conf'][i]) > 60:        if re.match(date_pattern, d['text'][i]):            (x, y, w, h) = (d['left'][i], d['top'][i], d['width'][i], d['height'][i])            img_date = cv2.rectangle(img, (x, y), (x + w, y + h), (0, 255, 0), 2)            print(d['text'][i])

Output: 12/12/2001

输出:12/12/2001

You may even highlight the date fields in a given document

您甚至可以突出显示给定文档中的日期字段

cv2.imwrite('aimg_date.png', img_date)
Image by Author
图片作者

I hope this article was helpful in kick-starting your OCR and NLP knowledge. Topics like these are covered as part of the AWS Big Data Analytics course offered by Datafence Cloud Academy. The course is taught online by myself on weekends.

我希望本文对启动您的OCR和NLP知识有所帮助。 这些主题是Datafence Cloud Academy提供的AWS Big Data Analytics课程的一部分。 该课程由我本人在周末在线上教。

翻译自: https://towardsdatascience.com/compare-amazon-textract-with-tesseract-ocr-ocr-nlp-use-case-43ad7cd48748

textract


http://www.taodudu.cc/news/show-5881949.html

相关文章:

  • file java_Java中File常用的方法汇总
  • OBS架构分析
  • 论文学习:Feature Importance-aware Transferable Adversarial Attacks
  • 按位实现的队列轮询算法
  • CTCC第6站北京站:超级组王睿被罚江腾一冠军
  • Feature Importance-aware Transferable Adversarial Attacks
  • CC学习笔记3:FIA类:标识和鉴别
  • 在跑FIA时遇到的问题Restoring from checkpoint failed. This is most likely due to a Variable name or other gra
  • 华为无线AP4030,FIA--FAT模式更改
  • Java的fia_在Java代码中没有找到配置FIAGLE的合适方法
  • 计算机网络-08 FIA
  • Java的fia_acca报考条件之一的FIA到底是什么?
  • Cocos2d-x 安装详细步骤
  • Android Java调用cocos2d-js传参
  • Cocos2d-x 之贴图 Texture2D
  • cocos2d-js搓牌效果
  • cocos2d-x安装与配置
  • python 游戏引擎 cocos2d_【Cocos2dx游戏开发】Cocos2d-x简介
  • Cocos2d-x-4.0安装流程(踩坑后总结)
  • cocos2d-js 入门 (主要是HTML5)
  • Cocos2d游戏开发学习记录——2.使用Cocos2D Graphic实现僵尸的移动
  • 搞笑闹洞房
  • 周末了,转几个搞笑语句,大家进来轻松下。
  • 7个少根筋的笑话
  • 2008年评出的最搞笑的笑话
  • 鹦鹉笑话几则
  • 几个好笑的笑话
  • 搞笑的内涵型奇葩,特别出众
  • bitcoin-cli命令行组装交易并成功广播
  • 羽毛不是鸟的专利

textract_比较亚马逊textract与tesseract ocr ocr nlp用例相关推荐

  1. 长文丨亚马逊帝国的人工智能革命史

    2014年初,Srikanth Thirumalai 见到了亚马逊 CEO Jeff Bezos.Thirumalai 是一位计算机科学家,2005 年从 IBM 来到亚马逊,负责公司的推荐团队.他给 ...

  2. 只需3行代码自动生成高性能模型,支持4项任务,亚马逊发布开源库AutoGluon

    作者 | KYLE WIGGERS 编译 | AI科技大本营(ID:rgznai100) 构建涉及图像.文本和表格数据集的机器学习应用并不容易.它需要特征工程或使用数据领域知识来创建使AI算法起作用的 ...

  3. 亚马逊 CTO 回应人脸识别技术质疑:技术无罪,我们无责任

    https://www.leiphone.com/toutiao/LEaMCQPovBI6RmNu.html 雷锋网按:近日,亚马逊的高管接受 BBC 的采访,在采访中,高管们对目前具有争议的亚马逊产 ...

  4. 亚马逊一口气发布了9款机器学习产品

    AI前线导读: 今天,在拉斯维加斯举行的AWS re:invent进行到第三个日程,大会上,AWS CEO Andy Jassy在主题演讲上一口气做了二十个新发布,其中包括9款机器学习产品! 更多干货 ...

  5. 亚马逊云服务(AWS)中国与毕马威中国建立战略合作伙伴关系

    2020年9月10日,亚马逊通技术服务(北京)有限公司(AWS中国)与毕马威企业咨询(中国)有限公司(毕马威中国)宣布已签署战略合作协议. 双方将充分利用各自的全球品牌影响力和资源优势,强强联手,在机 ...

  6. 【观察】亚马逊云科技:从“三驾马车”到“四措并举”,释放中国数字经济新动能...

    2021年,在亚马逊云科技中国峰会上,亚马逊云科技宣布以"全球优势,植根本地"的全新中国战略,和"5+1+1"的优势能力打造中国业务的"三驾马车&qu ...

  7. 帆软所有销量为0的显示为空值_市场上最流行的9款跨境电商亚马逊销量预估工具精准度报告详解!...

    很多用户都知道JS产品的数据精准度是目前市场上最好的,今年我们继续做了"2019亚马逊销量预估准确度调研报告",将市场上的销量预估工具进行多维度对比分析,报告如下. 2019版报告 ...

  8. 详解亚马逊:物流为何是电商命脉

    在物流环节上,亚马逊(AMZN)主要涉及物流中心运营,商品配送环节主要采取和第三方快递公司合作完成.那么,亚马逊物流促销活 动反映在财务收支上的结果又如何?根据年报数据,2011年亚马逊收到来自用户支 ...

  9. 埃森哲、亚马逊和万事达卡抱团推出的区块链项目有何神通?

    据外媒报道,今日埃森哲宣布了一项新的区块链项目,该项目为基于区块链的循环供应链,将与万事达卡和亚马逊共同合作. 据官方介绍,这个基于区块链的循环供应链能够让客户识别供应链上的小规模供应商和种植者,例如 ...

最新文章

  1. idea中如何reimport_IDEA中导入新项目遇坑
  2. arduino串口绘图_一起打造一款光驱迷你绘图仪
  3. 【webservice】spring整合webservice RS风格
  4. 外挂学习之路(6)--- 选怪call
  5. java 事务的提出者_java中什么是事务
  6. 初识 Vue(01)---(输出 Hello World)
  7. 发明导诊机器人团队_牛!这个平均年龄21岁的团队竟然发明偏瘫康复机器人
  8. Android设备 D获取,如何获取Android设备名称(常用ADB命令介绍)
  9. java –cp_Java设置–用Java设置
  10. checksum建立的索引
  11. c语言简易计算器大作业报告,c语言计算器的实验报告
  12. opencv Library QUIRC is not linked解决办法
  13. 基于分布式的智联招聘数据的大屏可视化分析与预测
  14. css样式字体文本汇总
  15. 微信小程序获取头像昵称,限制头像大小
  16. [每日100问][2011-10-11]iphone开发笔记,今天你肿了么
  17. 2018年6月8日论文阅读
  18. oracle11g压力测试工具,ORACLE RDBMS 压力测试工具:orabm orastress
  19. iPhone 无需越狱修改wx+zfb+qq步数
  20. 如何使用Java将float转换为int

热门文章

  1. oracle rman本地备份,【学习笔记】Oracle RMAN 备份集存储到远程其它服务器实现方法...
  2. 基于激光雷达和单目视觉融合的SLAM和三维语义重建
  3. 下午一口气睡了五个小时
  4. 《上海市城镇私营企业职工养老保险办法》
  5. 基本数据类型与构造数据类型
  6. 12-南信大研究生院的登录-打印成绩单
  7. 金蝶K3WISE15.1最新部署步骤
  8. 这两软件可以让你变优秀
  9. 高仿qq聊天:qt界面
  10. 隐含参数与 Library Cache 与 Shared Pool Latch 原理