Amazon Textract is a machine learning (ML) service that automatically extracts text, handwriting, layout elements, and data from scanned documents. It goes beyond simple optical character recognition (OCR) to identify, understand, and extract specific data from documents. Today, many companies manually extract data from scanned documents such as PDFs, images, tables, and forms, or through simple OCR software that requires manual configuration (which often must be updated when the form changes). To overcome these manual and expensive processes, Textract uses ML to read and process any type of document, accurately extracting text, handwriting, tables, and other data with no manual effort. You can use one of our pretrained or custom features to quickly automate document processing, whether you’re automating loans processing or extracting information from invoices and receipts. Textract provides you the ability to customize our pretrained features to meet the document processing needs specific to your business. Textract can extract the data in minutes instead of hours or days. "AWS Official documentation"
-
The process begins with the user uploading an expense image through the frontend application.
-
Following the upload, the user triggers the "extract information" action within the application.
-
The web application, in response to the user's action, initiates an HTTP request to an Api Gateway endpoint. This request includes essential image information encoded in base64 format.
-
The Api Gateway acts as an intermediary, forwarding the received request to a Lambda function within the Lambda function, the Boto3 SDK for Python facilitates interaction with the AWS Textract service. This involves sending the image data to Textract for processing and information extraction.
-
Upon receiving the processed results from AWS Textract, the Lambda function compiles the detected fields within the image. Subsequently, the Lambda function sends the response back to the frontend application, completing the flow.
To deploy the Api Gateway, the lambda function and the execution IAM role please execute the following SAM command in the root folder:
sam deploy --stack-name aws-textract \
--template-file template.yaml \
--capabilities CAPABILITY_NAMED_IAM \
--resolve-s3 \
--profile <your_aws_local_profile>
Remember to replace <your_aws_local_profile> for your AWS profile configured in case that you need to use a different profile instead of default profile.
Follow these steps to run the web application locally:
-
Navigate to the textract-web-app folder.
-
Ensure that Node.js is installed. It is recommended to use Node Version Manager (NVM) to manage different Node.js versions. If you don't have NVM installed, you can follow the installation guide here. The recommended Node.js version is v20.
-
Open a terminal and execute the command yarn install to install the project dependencies.
-
Once the installation is complete, run the command yarn dev. This will start the development server, and you can access the project by navigating to localhost:9090 in your web browser.
By following these steps, you should have the web application up and running on your local environment for testing and development purposes.