Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

OCR library to extract text & tables from PDF files and images. Convert any image or PDF to CSV / TXT / JSON / Searchable PDF.

License

NotificationsYou must be signed in to change notification settings

NanoNets/ocr-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 

Repository files navigation

https://img.shields.io/pypi/v/ocr-nanonets-wrapper.svg?color=green

This python package is an OCR library which reads all text & tables from image & PDF files using an OCR engine & provides intelligent post-processing options to save OCR results in formats you want.



Installation

The package requiresPython 3 to run.

You can usepip to install:

pip install ocr-nanonets-wrapper

Authentication

This software is perpetually free :)

You can get your free API key (with unlimited requests) by creating a free account onhttps://app.nanonets.com/#/keys.

fromnanonetsimportNANONETSOCRmodel=NANONETSOCR()model.set_token('REPLACE_API_KEY')

Usage

You can refer the code shared below ordirectly use code from here.

# InitialisefromnanonetsimportNANONETSOCRmodel=NANONETSOCR()# Authenticate# This software is perpetually free :)# You can get your free API key (with unlimited requests) by creating a free account on https://app.nanonets.com/#/keys?utm_source=wrapper.model.set_token('REPLACE_API_KEY')# PDF / Image to Raw OCR Engine Outputimportjsonpred_json=model.convert_to_prediction('INPUT_FILE')print(json.dumps(pred_json,indent=2))# PDF / Image to Stringstring=model.convert_to_string('INPUT_FILE')print(string)# PDF / Image to TXT Filemodel.convert_to_txt('INPUT_FILE',output_file_name='OUTPUTNAME.txt')# PDF / Image to Boxes# each element contains predicted word and bounding box information# bounding box information denotes the spatial position of each word in the fileboxes=model.convert_to_boxes('test.png')forboxinboxes:print(box)# PDF / Image to CSV# This method extracts tables from your file and prints them in a .csv file.# NOTE : This particular function is a trial offering 1000 pages of use.# To use this at scale, please create your own model at app.nanonets.com --> New Model --> Tables.model.convert_to_csv('INPUT_FILE',output_file_name='OUTPUTNAME.csv')# PDF / Image to Tables# This method extracts tables from your file and returns a json object.# NOTE : This particular function is a trial offering 1000 pages of use.# To use this at scale, please create your own model at app.nanonets.com --> New Model --> Tables.importjsontables_json=model.convert_to_tables('INPUT_FILE')print(json.dumps(tables_json,indent=2))# PDF / Image to Searchable PDFmodel.convert_to_searchable_pdf('INPUT_FILE',output_file_name='OUTPUTNAME.pdf')

Testing

To make getting started easier for you, there is a bunch of sample code along with sample input files.

  • Clone or download the repo and open the /tests folder.
  • all_tests.ipynb is a python notebook containing testing for all methods in the package.
  • convert_to_{METHOD}.py files are python files corresponding to each method in the package individually.

Note

convert_to_string() and convert_to_txt() methods have two optional parameters -

  1. formatting =
  • `lines and spaces` : default, all formatting enabled
  • `none` : space separated text with formatting removed
  • `lines` : space separated text with lines separated with newline character
  • `pages` : list of page wise space separated text
  1. line_threshold =
  • `low` : default
  • `high` : You can addline_threshold='high' as a parameter while calling the method which in few cases can improve reading flowcharts and diagrams.

Advanced Functions

If extracting flat fields, tables and line items from PDFs and images is your use case, I will strongly advice you to create your own model by signing up onapp.nanonets.com and using our advanced API. This will improve functionalities, accuracy and response times significantly. Once you have created your account and model, you can useAPI documentation present here to extract flat fields, tables and line items from any PDF or image.

Nanonets

We help businesses automate Manual Data Entry Using AI and reduce turn around times & manual effort required. More than 1000 enterprises use Nanonets for Intelligent Document Processing. We have generated incredible ROIs for our clients.

We provide OCR and IDP solutions customised for various use cases - invoice automation, Receipt OCR, purchase order automation, accounts payable automation, ID Card OCR and many more.

License

MIT

This software is perpetually free :)

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp