AWS, Cloud Computing, Data Analytics

4 Mins Read

A Guide to Deploy OCR Flask App as an Amazon SageMaker Endpoint

Voiced by Amazon Polly

Introduction

In Amazon SageMaker, an endpoint refers to a hosted and scalable prediction service that allows you to deploy trained machine learning models for inference. Once you have trained a model using SageMaker or any other compatible framework, you can create an endpoint to make predictions or generate inferences on new, unseen data.

An endpoint is a real-time API endpoint that receives incoming inference requests and returns predictions based on the deployed model. It provides a scalable and highly available infrastructure for serving predictions, allowing you to handle high volumes of requests with low latency.

Pioneers in Cloud Consulting & Migration Services

  • Reduced infrastructural costs
  • Accelerated application deployment
Get Started

Features of Amazon SageMaker Endpoint

  1. Model Deployment: An endpoint allows you to deploy a trained model for serving predictions. You can deploy models trained using Amazon SageMaker’s built-in algorithms, custom models created with your training code, or even models brought from external sources.
  2. Real-time Inference: Once an endpoint is created, it becomes accessible via a unique endpoint URL. You can send inference requests to this URL, providing input data for the model. The endpoint processes the request and returns the corresponding predictions in real-time.
  3. Scalability and Availability: Amazon SageMaker endpoints are designed to handle production-level workloads. They can automatically scale horizontally to accommodate high traffic loads and provide high availability by distributing the workload across multiple instances.
  4. Cost Optimization: Endpoints in Amazon SageMaker can be managed using automatic scaling policies, allowing you to scale the underlying infrastructure based on the incoming traffic. This helps optimize costs by dynamically adjusting the resources based on demand.
  5. Monitoring and Management: Amazon SageMaker provides built-in monitoring capabilities for endpoints, allowing you to track performance metrics, monitor resource utilization, and set alarms for potential issues. You can also update and manage endpoints, enabling versioning, A/B testing, and seamless deployment of new model versions.

Steps to Deploy OCR Flask App as an Amazon SageMaker Endpoint

  1. Using Tesseract as an inference model and packaging it into a Flask application with multiple functions. OCR function is responsible for the OCR part.

step1

2. In the build source folder, we must package everything as a Dockerfile and build the container using BYOC techniques in Amazon SageMaker.

step2

3. Also, for Deploying our containers, we need to use the serve file, which communicates with the Amazon SageMaker environment and is responsible for building SageMaker Endpoints.

step3

4. Two more functions are required in the Flask app when packaging our image and running it as an Amazon SageMaker endpoint: ping and invocations functions.

5. Ping function is responsible for getting the health check status code 200 when connected with the Endpoint.

step5

6. Another function is the invocation function which consists of a training job/inference model. We get the OCR results using the tesseract library, which comes under the inference model.

step6

7. Once all these functions are packaged along with the nginx configuration file and wsgi file for gateway checks, we can build this repo as an image and launch it using Amazon SageMaker Endpoint.

8. While Creating the Amazon SageMaker endpoint, we require certain configurations to create and launch the endpoint. We are using Amazon SageMaker SDK to create the model from our packaged image inside ECR.

9. Once the model is created, then the creation of the endpoint configuration step will take place.

step9

10. After creating the endpoint Configuration, the Create endpoint create step will occur.

step10

Conclusion

In this era of advancement of Machine learning services, data scientists and machine learning engineers require a feature that does most of the things with more effectiveness such that they can spend their time playing with data and understanding them to create a good model. To overcome this situation, BYOC in Amazon SageMaker enables them to easily deploy their models as an endpoint without custom dependency on other people. By leveraging BYOC and the SageMaker platform, developers and data scientists can harness the benefits of managed infrastructure, scalability, and integration with other AWS services, while still having the flexibility to utilize custom code and configurations for their machine learning workflows. Deploying the OCR Flask apps generates a revolution in gathering text from an unstructured source format.

Empowering organizations to become ‘data driven’ enterprises with our Cloud experts.

  • Reduced infrastructure costs
  • Timely data-driven decisions
Get Started

About CloudThat

CloudThat is a leading provider of Cloud Training and Consulting services with a global presence in India, the USA, Asia, Europe, and Africa. Specializing in AWS, Microsoft Azure, GCP, VMware, Databricks, and more, the company serves mid-market and enterprise clients, offering comprehensive expertise in Cloud Migration, Data Platforms, DevOps, IoT, AI/ML, and more.

CloudThat is the first Indian Company to win the prestigious Microsoft Partner 2024 Award and is recognized as a top-tier partner with AWS and Microsoft, including the prestigious ‘Think Big’ partner award from AWS and the Microsoft Superstars FY 2023 award in Asia & India. Having trained 850k+ professionals in 600+ cloud certifications and completed 500+ consulting projects globally, CloudThat is an official AWS Advanced Consulting Partner, Microsoft Gold Partner, AWS Training PartnerAWS Migration PartnerAWS Data and Analytics PartnerAWS DevOps Competency PartnerAWS GenAI Competency PartnerAmazon QuickSight Service Delivery PartnerAmazon EKS Service Delivery Partner AWS Microsoft Workload PartnersAmazon EC2 Service Delivery PartnerAmazon ECS Service Delivery PartnerAWS Glue Service Delivery PartnerAmazon Redshift Service Delivery PartnerAWS Control Tower Service Delivery PartnerAWS WAF Service Delivery PartnerAmazon CloudFront Service Delivery PartnerAmazon OpenSearch Service Delivery PartnerAWS DMS Service Delivery PartnerAWS Systems Manager Service Delivery PartnerAmazon RDS Service Delivery PartnerAWS CloudFormation Service Delivery PartnerAWS ConfigAmazon EMR and many more.

FAQs

1. What is WSGI?

ANS: – WSGI stands for Web Server Gateway Interface. It is a specification or protocol for how web servers and web applications should communicate and interact in Python.

2. What is Nginx configuration?

ANS: – Nginx is a popular open-source web server and reverse proxy server known for its high performance, stability, and scalability. The Nginx configuration refers to the settings and directives that determine how Nginx operates and handles incoming requests.

3. What is Endpoint Configuration?

ANS: – Endpoint Configuration is the setting to create the endpoints, which consists of different production variants and parameters such as All Traffic, Instance Type, model name, etc.

WRITTEN BY Arslan Eqbal

Share

Comments

    Click to Comment

Get The Most Out Of Us

Our support doesn't end here. We have monthly newsletters, study guides, practice questions, and more to assist you in upgrading your cloud career. Subscribe to get them all!