In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Most people do not understand the knowledge points of this article "how to use python's muggle_ocr library", so the editor summarizes the following contents, detailed contents, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to use python's muggle_ocr library" article.
Description
1. Muggle_ocr is a lightweight ocr recognition library, which is a picture verification code module with high recognition rate for python.
2. It is mainly used to identify various types of CAPTCHA codes, but the effect of text extraction is generally poor.
The installation command pip install muggle_ocr instance import muggle_ocr# initialization sdk;model_type contains two modes of ModelType.OCR/ModelType.Captcha, corresponding to the regular picture and the verification code sdk = muggle_ocr.SDK (model_type=muggle_ocr.ModelType.Captcha) with open (r "d:Desktop four-digit verification code .png", "rb") as f: img = f.read () text = sdk.predict (image_bytes=img) print (text)
Related instance expansion:
Import time# 1. Import package import muggle_ocr "" use preset model The preset model contains two kinds of [ModelType.OCR, ModelType.Captcha], in which ModelType.OCR is used to recognize ordinary printed text, and ModelType.Captcha is used to recognize 4-6 digits of simple English verification code "" # Open printed text picture with open (r "test1.png", "rb") as f: ocr_bytes = f.read () # Open CAPTCHA picture with open (r "test2.jpg" "rb") as f: captcha_bytes = f.read () # 2. Initialization; model_type optional: [ModelType.OCR, ModelType.Captcha] sdk = muggle_ocr.SDK (model_type=muggle_ocr.ModelType.OCR) # ModelType.Captcha recognizable optical printed text for i in range (5): st = time.time () # 3. Call the prediction function text = sdk.predict (image_bytes=ocr_bytes) print (text, time.time ()-st) # ModelType.Captcha to recognize 4-6 bit CAPTCHA sdk = muggle_ocr.SDK (model_type=muggle_ocr.ModelType.Captcha) for i in range (5): st = time.time () # 3. Call the prediction function text = sdk.predict (image_bytes=captcha_bytes) print (text, time.time ()-st) "after the training of the model based on https://github.com/kerlomz/captcha_trainer framework training using the custom model is completed, go to the [out] path of the export compilation model, and put the pb model under the [graph] path and the yaml configuration file under [model] under the same path. You can specify the conf_path parameter as the absolute or project relative path of the yaml configuration file. Other steps are the same, as shown in the following example: "" with open (r "test3.jpg", "rb") as f: B = f.read () sdk = muggle_ocr.SDK (conf_path= ". / ocr.yaml") text = sdk.predict (image_bytes=b) these are the contents of the article "how to use python's muggle_ocr Library" I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.