Techno Blender
Digitally Yours.

Deploy your first computer vision app for AWS Panorama in five minutes | by Janos Tolgyesi | Oct, 2022

0 45


Learn how to set up your first Panorama application the easy way

An eagle flying in the sky
Photo by Rachel McDermott on Unsplash

I published a step-by-step guide here on Towards Data Science on deploying an object-detector application on AWS Panorama almost a year ago. The article was quite long (17 minutes to read!) and involved a lot of delicate steps. Creating a Panorama application with official tools is not easy: you should use a fixed and complex project structure, remember many parameters regarding your project, and pass them to the tools each time you invoke them. Then files and folders must be named in a particular way, and you must maintain consistent copies of the same information (for example, the deep-learning model properties) in different parts of the project. All these “housekeeping” tasks do not deliver real business value: they serve only to keep the project and the boilerplate code up to date.

In the last few months, I have built and deployed a dozen of Panorama applications, experiencing this burden on my own. Obviously, some repeating tasks and patterns emerged that pushed me to automate the setup and deployment process of any Panorama app as much as possible. I am pleased to introduce cookiecutter-panorama, an AWS Panorama project generator tool and build system. Let’s dive deeper, starting with the definition of an AWS Panorama app.

In case you missed the previous episodes, AWS Panorama is a hardware and software platform that enables running computer vision (CV) applications analyzing video streams from on-premises internet protocol (IP) cameras.

A Panorama Application is a collection of packaged deep learning models, business logic code, and a manifest structure (also called “application graph”) that defines the data pipeline between these components.

In the case of “classic” Panorama applications, the deep learning model (trained in Pytorch, Tensorflow, or MXNet) is packaged in an artifact called “model asset” by the build process of the app. Similarly, your business logic code (written in Python, using the Panorama Application SDK) is packaged in the “code asset” artifact. These artifacts are registered and uploaded to your AWS account. Whenever you want to deploy your CV application to a Panorama appliance, you must provide the manifest structure that refers to these artifacts and describes how the device should connect them.

So, a Panorama application is loosely coupled to a set of deep learning and business logic packages bound together by the manifest file. The developer must constantly synchronize the references in the application manifest file and within the packages. This is one of the biggest maintenance tasks that cookiecutter-panorama can automate.

Let’s talk about how to make cookies!

Uncooked gingerbread dough being cut into different shapes by cookie cutters
Photo by Anshu A on Unsplash

Cookiecutter is a command-line utility that creates projects from cookiecutters (project templates). It became the de-facto standard for generating projects in the Python ecosystem because of its beautifully simple design matches with compelling features. Currently, there are more than 7000 cookiecutter project templates published on GitHub. Cookiecutter-panorama adds the Panorama application template to this pantheon.

First, install the cookiecutter command-line tool with pip (pip install cookiecutter), conda (conda install -c conda-forge cookiecutter) or pipx (pipx install cookiecutter, the recommended way).

The launch of a Space-X rocket
Photo by SpaceX on Unsplash

Creating a Panorama application project is as simple as:

$ cookiecutter https://github.com/mrtj/cookiecutter-panorama.git

The template engine will ask you the value of a bunch of parameters. However, it also provides reasonable default values that you can leave as they are in most cases and confirm the option.

You have to set up only two parameters: project_name and s3_working_bucket. The latter should be the name of an existing S3 bucket in your account where you have read/write privileges. You can find a detailed description of the parameters in the README file of cookiecutter-panorama.

$ cookiecutter https://github.com/mrtj/cookiecutter-panorama.git
project_name [Panorama Video Processor]: ↲
project_slug [panorama_video_processor]: ↲
s3_working_bucket [my_bucket]: my_real_bucket
s3_working_path [s3://my_real_bucket/panorama_projects/panorama_video_processor]: ↲
camera_node_name [camera_input]: ↲
display_node_name [display_output]: ↲
code_package_name [panorama_video_processor_logic]: ↲
code_package_version [1.0]: ↲
code_asset_name [panorama_video_processor_logic_asset]: ↲
code_node_name [panorama_video_processor_logic_node]: ↲
model_package_name [panorama_video_processor_model]: ↲
model_package_version [1.0]: ↲
model_asset_name [panorama_video_processor_model_asset]: ↲
model_node_name [panorama_video_processor_model_node]: ↲
model_input_name [input0]: ↲
model_processing_width [224]: ↲
model_processing_height [224]: ↲

Cookiecutter will generate your project in a directory named the project_slug parameter, in the above case panorama_video_processor:

$ cd panorama_video_processor

Once the project has been generated, you can start interacting with the Makefile. The build system provides a rich set of functionalities: configure a git repository, build the application container and the deep learning model, upload the packages to your AWS account ready to be deployed to the Panorama appliance, run your application on your development workstation with Test Utility, safeguard you from leaking your AWS account id in public git repositories, etc. For a complete list of features, refer to the README file generated within the Panorama project. Here is a preview.

A construction site with cranes
Photo by EJ Yao on Unsplash

Some tasks provided by cookiecutter-panorama you can benefit:

  • make init-repo: initialize a git repository
  • Install the required build tools: aws-cli, panorama-cli and docker. Configure the aws-cli to the credentials of the account where the Panorama appliance is registered.
  • make import: import the project to your AWS account
  • make build: build the project and create a dummy deep learning model that you can replace later with an actual model. The dummy model will calculate the mean of the RGB channels of the input video frame using the model package infrastructure and the real GPU of the Panorama appliance.
  • make package: upload the compiled application container and packaged deep learning model to your AWS account. This script will also output the path of the compiled manifest JSON.

Then you can pick up the manifest JSON, head to AWS Panorama Console and deploy your application!

Questions? Issues? Suggestions? Open an issue in the cookiecutter-panorama github project, or reach out using the contacts below!

Janos Tolgyesi is an AWS Community Builder and Machine Learning Team Leader at Neosperience with 5+ years of expertise in ML technologies and 8+ years on AWS. He loves building things, let it be a video analytics application on the edge, or a user profiler based on clickstream events. You can find me on Twitter, Medium, and LinkedIn.

The open-source project of cookiecutter-panorama was supported by Neosperience.

I would like to express my special thanks to Luca Bianchi for proofreading this article.




Learn how to set up your first Panorama application the easy way

An eagle flying in the sky
Photo by Rachel McDermott on Unsplash

I published a step-by-step guide here on Towards Data Science on deploying an object-detector application on AWS Panorama almost a year ago. The article was quite long (17 minutes to read!) and involved a lot of delicate steps. Creating a Panorama application with official tools is not easy: you should use a fixed and complex project structure, remember many parameters regarding your project, and pass them to the tools each time you invoke them. Then files and folders must be named in a particular way, and you must maintain consistent copies of the same information (for example, the deep-learning model properties) in different parts of the project. All these “housekeeping” tasks do not deliver real business value: they serve only to keep the project and the boilerplate code up to date.

In the last few months, I have built and deployed a dozen of Panorama applications, experiencing this burden on my own. Obviously, some repeating tasks and patterns emerged that pushed me to automate the setup and deployment process of any Panorama app as much as possible. I am pleased to introduce cookiecutter-panorama, an AWS Panorama project generator tool and build system. Let’s dive deeper, starting with the definition of an AWS Panorama app.

In case you missed the previous episodes, AWS Panorama is a hardware and software platform that enables running computer vision (CV) applications analyzing video streams from on-premises internet protocol (IP) cameras.

A Panorama Application is a collection of packaged deep learning models, business logic code, and a manifest structure (also called “application graph”) that defines the data pipeline between these components.

In the case of “classic” Panorama applications, the deep learning model (trained in Pytorch, Tensorflow, or MXNet) is packaged in an artifact called “model asset” by the build process of the app. Similarly, your business logic code (written in Python, using the Panorama Application SDK) is packaged in the “code asset” artifact. These artifacts are registered and uploaded to your AWS account. Whenever you want to deploy your CV application to a Panorama appliance, you must provide the manifest structure that refers to these artifacts and describes how the device should connect them.

So, a Panorama application is loosely coupled to a set of deep learning and business logic packages bound together by the manifest file. The developer must constantly synchronize the references in the application manifest file and within the packages. This is one of the biggest maintenance tasks that cookiecutter-panorama can automate.

Let’s talk about how to make cookies!

Uncooked gingerbread dough being cut into different shapes by cookie cutters
Photo by Anshu A on Unsplash

Cookiecutter is a command-line utility that creates projects from cookiecutters (project templates). It became the de-facto standard for generating projects in the Python ecosystem because of its beautifully simple design matches with compelling features. Currently, there are more than 7000 cookiecutter project templates published on GitHub. Cookiecutter-panorama adds the Panorama application template to this pantheon.

First, install the cookiecutter command-line tool with pip (pip install cookiecutter), conda (conda install -c conda-forge cookiecutter) or pipx (pipx install cookiecutter, the recommended way).

The launch of a Space-X rocket
Photo by SpaceX on Unsplash

Creating a Panorama application project is as simple as:

$ cookiecutter https://github.com/mrtj/cookiecutter-panorama.git

The template engine will ask you the value of a bunch of parameters. However, it also provides reasonable default values that you can leave as they are in most cases and confirm the option.

You have to set up only two parameters: project_name and s3_working_bucket. The latter should be the name of an existing S3 bucket in your account where you have read/write privileges. You can find a detailed description of the parameters in the README file of cookiecutter-panorama.

$ cookiecutter https://github.com/mrtj/cookiecutter-panorama.git
project_name [Panorama Video Processor]: ↲
project_slug [panorama_video_processor]: ↲
s3_working_bucket [my_bucket]: my_real_bucket
s3_working_path [s3://my_real_bucket/panorama_projects/panorama_video_processor]: ↲
camera_node_name [camera_input]: ↲
display_node_name [display_output]: ↲
code_package_name [panorama_video_processor_logic]: ↲
code_package_version [1.0]: ↲
code_asset_name [panorama_video_processor_logic_asset]: ↲
code_node_name [panorama_video_processor_logic_node]: ↲
model_package_name [panorama_video_processor_model]: ↲
model_package_version [1.0]: ↲
model_asset_name [panorama_video_processor_model_asset]: ↲
model_node_name [panorama_video_processor_model_node]: ↲
model_input_name [input0]: ↲
model_processing_width [224]: ↲
model_processing_height [224]: ↲

Cookiecutter will generate your project in a directory named the project_slug parameter, in the above case panorama_video_processor:

$ cd panorama_video_processor

Once the project has been generated, you can start interacting with the Makefile. The build system provides a rich set of functionalities: configure a git repository, build the application container and the deep learning model, upload the packages to your AWS account ready to be deployed to the Panorama appliance, run your application on your development workstation with Test Utility, safeguard you from leaking your AWS account id in public git repositories, etc. For a complete list of features, refer to the README file generated within the Panorama project. Here is a preview.

A construction site with cranes
Photo by EJ Yao on Unsplash

Some tasks provided by cookiecutter-panorama you can benefit:

  • make init-repo: initialize a git repository
  • Install the required build tools: aws-cli, panorama-cli and docker. Configure the aws-cli to the credentials of the account where the Panorama appliance is registered.
  • make import: import the project to your AWS account
  • make build: build the project and create a dummy deep learning model that you can replace later with an actual model. The dummy model will calculate the mean of the RGB channels of the input video frame using the model package infrastructure and the real GPU of the Panorama appliance.
  • make package: upload the compiled application container and packaged deep learning model to your AWS account. This script will also output the path of the compiled manifest JSON.

Then you can pick up the manifest JSON, head to AWS Panorama Console and deploy your application!

Questions? Issues? Suggestions? Open an issue in the cookiecutter-panorama github project, or reach out using the contacts below!

Janos Tolgyesi is an AWS Community Builder and Machine Learning Team Leader at Neosperience with 5+ years of expertise in ML technologies and 8+ years on AWS. He loves building things, let it be a video analytics application on the edge, or a user profiler based on clickstream events. You can find me on Twitter, Medium, and LinkedIn.

The open-source project of cookiecutter-panorama was supported by Neosperience.

I would like to express my special thanks to Luca Bianchi for proofreading this article.

FOLLOW US ON GOOGLE NEWS

Read original article here

Denial of responsibility! Techno Blender is an automatic aggregator of the all world’s media. In each content, the hyperlink to the primary source is specified. All trademarks belong to their rightful owners, all materials to their authors. If you are the owner of the content and do not want us to publish your materials, please contact us by email – [email protected]. The content will be deleted within 24 hours.

Leave a comment