50 8 Shipping 382 1097 97 23 5 Total 423 1125 56 18 1 i 260 1397 62 62
51 1 253 1584 335 12 2 my 561 1510 33 18 6 client 602 1505 62 18
52 1 664 955 145 201 0 764 1332 44 98
53
54 01 Introduction to Pytesseract Google Colab Notebook for OCR using Pytesseract • https://bhadreshpsavani.medium.com/how-to-use-tesseract-library-for-ocr-in-googlecolab-notebook-5da5470e4fe0 • https://nanonets.com/blog/ocr-with-tesseract/ • 02 Installation • install tesseract-ocr on linux เเละ libtesseract-dev เพื่อใช command line on terminal • install pytesseract สำหรับการเขียนดวย ภาษา python • *install tesseract-ocr-tha for thai * *หมายเหตุ * ใน colab ตอง install ใหมทุกครั้ง เเละหลังจาก install ดวย cell ดานลางจำเปนตอง Restart Runtime ใหม
55
56
57
58 03 Load Example Image file • upload image file ดวย google.colab.files.upload • download file exmaple ที่ link ... (link images) เลือกไฟลthai_2.JPG <matplotlib.image.AxesImage at 0x7f14f844b520>
59 04 OCR Tesseract Functions โดยเเตละฟงกชันจะระบุพารามิเตอรภาษา lang='tha' เชน pytesseract.image_to_string(image, lang="tha") 4.1 image_to_string Text Extraction การดึงขอความ
60 <matplotlib.image.AxesImage at 0x7f14f829d850> 4.3 image_to_data การดึงขอมูลประกอบ 'level', 'page_num', 'block_num', 'par_num', 'line_num', 'word_num', 'left', 'top', 'width', 'height', 'conf', 'text'
61 01 Introduction to Deep Layout parsering • https://layoutparser.readthedocs.io/en/latest/example/deep_layout_parsing/index.html • https://github.com/Layout-Parser/layout-parser 02 Installation • install tesseract original and thai as example 01-02 • install layoutparser • install ocr for layout parser • install layout detection by EfficientDet (effdet) https://arxiv.org/abs/1911.09070v7 • install layout detection by detectron2 https://github.com/facebookresearch/detectron2 *หมายเหตุ * ใน colab ตอง install ใหมทุกครั้ง เเละหลังจาก install ดวย cell ดานลางจำเปนตอง Restart Runtime ใหม
62
63
64 4 Layout Detection 4.1 layout detection with efficientdet Load model pretrained โดยใช effcientdet
65
66
67
68
69
70
71 Keras: the Python deep learning API Keras OCR A packaged and flexible version of the CRAFT text detector and Keras CRNN recognition model based on the project https://github.com/faustomorales/keras-ocr
72
73
74 : Thai Food VISION Recognition (T-Food) บริการระบุชื่ออาหารไทยจากรูปภาพ ดวยเทคนิค Deep Learning ***จัดการและประมวลผลรูปภาพกราฟกใน Python ดวย Pillow https://python3.wannaphong.com/2014/11/image-processing-python.html
75
76
77
78 OUTPUT ผลลัพธที่ไดจาก ระบบรูจำอาหารไทยจะอยูในรูปแบบของ JSON Arrays ตามจำนวนปายที่พบในรูปภาพ ซึ่ง แตละอาเรยจะมีองคประกอบดังนี้ OK : "True" หรือ "False" filename : ชื่อของไฟลภาพที่เซิรฟเวอรรับมา ในกรณีที่ client สง query มาหลายภาพ อาจใชชื่อไฟลนี้ใน การเทียบวาเปนคำตอบจากภาพใด objects : เปนรายการของคำตอบที่นาจะเปน 10 อันดับแรก ในกรณีระบบพบวาคำตอบในรายการนี้มีความ นาจะเปนต่ำมาก (ต่ำกวา 0.1) ระบบจะตัดรายการคำตอบใหสั้นลง โดยจำนวนคำตอบที่นอยที่สุดคือ 1 คำตอบ (Array) label: ชื่อของอาหาร เปน utf-8 string ในกรณีที่คำตอบนี้มีความนาจะเปนต่ำกวา 0.8 ระบบจะเพิ่มคำวา "(นาจะ)" ไวหนาชื่อ และหากความนาจะเปนต่ำกวา 0.1 จะมีคำวา "(เดาวา)" นำหนาชื่ออาหารนี้ rank: ลำดับของคำตอบมีคาได 1-10 โดย 1 คือคำตอบที่เปนไปไดมากที่สุด li> result: ชื่ออาหารไทยที่ได score: คะแนนของคำตอบนี้ มีคาตั้งแต 0 -1
79 ภาพอาหารคือ : ผัดไทยกุงสด score=0.9416062
80 VISION : Thai License Plate Recognition: T-LPR ระบบรูจำปายทะเบียนรถยนตสามารถตรวจหาอักษรภาษาไทยและตัวเลขอารบิกบนปายทะเบียนรถ • lpr: https://api.aiforthai.in.th/lpr • lpr v.2: https://api.aiforthai.in.th/lpr-v2 ***จัดการและประมวลผลรูปภาพกราฟกใน Python ดวย Pillow https://python3.wannaphong.com/2014/11/image-processing-python.html
81 เรียกใช API ตองไปสมัครเพื่อขอ API keyกอน ไปที่ลิงคนี้https://aiforthai.in.th เพื่อขอ API key ในการใชงาน (Apikey ดานลางนี้เปน API key ตัวอยางเอาไว test ตัวอยางเฉยๆ) กรอกขอมูล เพื่อกำหนดคาใหกับตัวแปร
82 OUTPUT ผลลัพธที่ไดจาก ระบบรูจำปายทะเบียนรถยนต จะอยูในรูปแบบของ JSON Arrays ตามจำนวนปายที่พบใน รูปภาพ ซึ่งแตละอาเรยจะมีองคประกอบดังนี้ lpr : ชุดตัวอักษรและตัวเลขของปายทะเบียน (String) bbox : ตำแหนงบนรูปภาพที่พบปายทะเบียน (Array) xLeftTop: ตำแหนง x ของปายทะเบียนมุมซายบน yLeftTop: ตำแหนง y ของปายทะเบียนมุมซายบน xRightBottom: ตำแหนง x ของปายทะเบียนมุมขวาลาง yRightBottom: ตำแหนง y
83
84 แบบทดสอบ หลักสูตรการเขียนโปรแกรม Object Detection ด้วย Python คําสั ่ง จงทําแบบทดสอบต่อไปนี้ทุกข้อเพื่อประเมินผลสัมฤทธ์ิของผู้เข้าอบรมและประเมินการ ผ่านเกณฑ์การได้ประกาศนียบัตร 1) จงเขียนโปรแกรม Face Detection จากภาพหมู ใหไดผลลัพธดังนี้ 2) จงเขียนโปรแกรม Thai License Plate Recognition ใหไดผลลัพธดังนี้
85 3) จงเขียนโปรแกรม OCR ขอความภาษาอังกฤษใหไดผลลัพธดังภาพ แลวเเสดงผลข้อความที่ Confident สูง 4) จงเขียนโปรแกรม OCR ขอความภาษาไทยใหไดผลลัพธดังภาพ แล้วเเสดงผลข้อความที่ Confident สูง
86 Thank your for your attention