Text Extraction from Image
Extract Text from Image
If your images deal with invoices, receipts, passports or driver's licenses, check out Nanonets pre-trained image to text extractors for free.
Just select the appropriate extractor, upload the images, extract & export the text. Extract text from images now:
Table of Contents
- Extract text from image using Nanonets pre trained OCR models
- Extract text from image by building a custom Nanonets OCR model
- Train your own OCR models with NanoNets API
- Why Nanonets is the best OCR for text extraction from images
Extracting text from an image can be a cumbersome process. Most people just retype the text/data from the image; but this is both time-consuming and inefficient when you have a lot of images to deal with.
Image to text converters, often in-built as a sub-feature in image/document processing programs, offer a neat way to extract text from images.
Tools like Snagit & OneNote among others, leverage basic OCR capabilities to extract text from images. And online converters like Workbench or img2text also extract text from images with OCR. (What is OCR? - here's a detailed explainer on OCR)
While such tools do a good job, the extracted text/data is often presented in an unstructured manner that results in a lot of post processing. An AI-driven OCR like Nanonets can extract text from images and present the extracted data in a neat, organized & structured manner.
Nanonets extracts text from images accurately, at scale, and in multiple languages. Nanonets is the only text recognition OCR that presents extracted text in neatly structured formats that are entirely customizable. Captured data can be presented as tables, line items, or any other format.
Extract text from image using Nanonets pre trained OCR models
Nanonets has pre-trained OCR models for the specific image types listed below. Each pre-trained OCR model is trained to accurately relate text in the image type to an appropriate field like name, address, date, expiry etc. and present the extracted text in a neat and organized manner.
- Driver’s license (US)
Step 1: Select an appropriate OCR model
Login to Nanonets and select an OCR model that is appropriate to the image from which you want to extract text and data. If none of the pre-trained OCR models suit your requirements, you can skip ahead to find out how to create a custom OCR model.
Step 2: Add files
Add the files/images from which you want to extract text. You can add as many images as you like.
Step 3: Test
Allow a few seconds for the model to run and extract text from the image.
Step 4: Verify
Quickly verify the text extracted from each file, by checking the table view on the right. You can easily double-check whether the text has been correctly recognized and matched with an appropriate field or tag.
You can even choose to edit/correct the field values and labels at this stage. Nanonets is not bound by the template of the image.
The extracted data can be displayed in a “List View” or “JSON” format.
You can tick the checkbox beside each value or field you verify or click “Verify Data” to proceed instantly.
Step 5: Export
Once all the files have been verified. You can export the neatly organized data as an xml, xlsx or csv file.
Extract text from image by building a custom Nanonets OCR model
Building a custom OCR model with Nanonets is easy. You can typically build, train and deploy a model for any image or document type, in any language, all in under 25 minutes (depending on the number of files used to train the model).
Watch the video below to follow the first 4 steps in this method:
Step 1: Create your own OCR model
Login to Nanonets and click on “Create your own OCR model”.
Step 2: Upload training files/images
Upload sample files that will be used to train the OCR models. The accuracy of the OCR model you build will largely depend on the quality and quantity of the files/images uploaded at this stage
Step 3: Annotate text on the files/images
Now annotate each piece of text or data with an appropriate field or label. This crucial step will teach your OCR model to extract the appropriate text from images and associate it with custom fields that are relevant to your needs.
You can also add a new label to annotate the text or data. Remember, Nanonets is not bound by the template of the image!
Step 4: Train the custom OCR model
Once annotation is completed for all the training files/images, click on “Train Model”. Training usually takes between 20 mins-2 hours depending on the number of files and queued models for training. You can upgrade to a paid plan to get faster results at this stage (typically under 20 minutes).
Nanonets leverages deep learning to build various OCR models and tests them against each other for accuracy. Nanonets then picks out the best OCR model (based on your inputs and accuracy levels).
The “Model Metrics” tab shows the various measurements and comparative analyses that allowed Nanonets to pick the best OCR model among all that were built. You can retrain the model (by providing a wider range of training images and better annotation) to achieve higher levels of accuracy.
Or, if you’re satisfied with the accuracy, click on “Test” to test & verify whether this custom OCR model performs as expected on a sample of images or files from which text/data needs to be extracted.
Step 5: Test & verify data
Add a couple of sample images to test & verify the custom OCR model.
If the text has been recognized, extracted and presented appropriately then export the file. As you can see below, the extracted data has been organized and presented in a neat format.
Congratulations, you have now built and trained a custom OCR model to extract text from certain types of images!
Does your business deal with text recognition in digital documents, images or PDFs? Have you wondered how to extract text from images accurately?
Train your own OCR models with NanoNets API
Here’s a detailed guide to train your own OCR models using the Nanonets API. In the documentation, you will find ready to fire code samples in Python, Shell, Ruby, Golang, Java, and C#, as well as detailed API specs for different endpoints.
Here's a step-by-step guide to training your own model using the Nanonets API:
Step 1: Clone the Repo
git clone https://github.com/NanoNets/nanonets-ocr-sample-python cd nanonets-ocr-sample-python sudo pip install requests sudo pip install tqdm
Step 2: Get your free API Key
Get your free API Key from https://app.nanonets.com/#/keys
Step 3: Set the API key as an Environment Variable
Step 4: Create a New Model
Note: This generates a MODEL_ID that you need for the next step
Step 5: Add Model Id as Environment Variable
Step 6: Upload the Training Data
Collect the images of object you want to detect. Once you have dataset ready in folder
images (image files), start uploading the dataset.
Step 7: Train Model
Once the Images have been uploaded, begin training the Model
Step 8: Get Model State
The model takes ~30 minutes to train. You will get an email once the model is trained. In the meanwhile you check the state of the model
watch -n 100 python ./code/model-state.py
Step 9: Make Prediction
Once the model is trained. You can make predictions using the model
python ./code/prediction.py PATH_TO_YOUR_IMAGE.jpg
Why Nanonets is the best OCR for text extraction from images
The benefits of using Nanonets over other OCR APIs go beyond just better accuracy with respect to extracting text from images. Here are 7 reasons why you should consider using the Nanonets OCR for text recognition instead:
1. Working with custom data
Most OCR software are quite rigid on the type of data they can work with. Training an OCR model for a use case requires a large degree of flexibility with respect to its requirements and specifications; an OCR for invoice processing will vastly differ from an OCR for passports! Nanonets isn’t bound by such rigid limitations. Nanonets uses your own data to train OCR models that are best suited to meet the particular needs of your business.
2. Working with non-English or multiple languages
Since Nanonets focuses on training with custom data, it is uniquely placed to build a single OCR model that could extract text from images in any language or multiple languages at the same time.
3. Requires no post-processing
Text extracted using OCR models needs to be intelligently structured and presented in an intelligible format; otherwise considerable time and resources go into re-organizing the data into meaningful information. While most OCR tools simply grab and dump data from images, Nanonets extracts only the relevant data and automatically sorts them into intelligently structured fields making it easier to view and understand.
4. Learns continuously
Businesses often face dynamically changing requirements and needs. To overcome potential roadblocks, Nanonets allows you to easily re-train your models with new data. This allows your OCR model to adapt to unforeseen changes.
5. Handles common data constraints with ease
Nanonets leverages AI, ML & Deep Learning techniques to overcome common data constraints that greatly affect text recognition & extraction. Nanonets OCR can recognize and handle handwritten text, images of text in multiple languages at once, images with low resolution, images with new or cursive fonts and varying sizes, images with shadowy text, tilted text, random unstructured text, image noise, blurred images and more. Traditional OCR APIs are just not equipped to perform under such constraints; they require data at a very high level of fidelity which isn’t the norm in real life scenarios.
6. Requires no in-house team of developers
No need to worry about hiring developers and acquiring talent to personalize Nanonets API for your business requirements. Nanonets was built for hassle-free integration. You can also easily integrate Nanonets with most CRM, ERP or RPA software.
7. Customize, customize, customize
You can capture as many fields of text/data that you like with Nanonets OCR. You can even build custom validation rules that work for your specific text recognition and text extraction requirements. Nanonets is not bound by the template of your document at all. You can capture data in tables or line items or any other format!
Nanonets has many use cases that could optimize your business performance, save costs and boost growth. Find out how Nanonets' use cases can apply to your product.
Update June 2021: this post was originally published in Oct 2020 and has since been updated regularly.