-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
app configuration, metrics, inbound ports, GPU access, samples
Showing
20 changed files
with
763 additions
and
378 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Using the GPU<a name="applications-gpuaccess"></a> | ||
|
||
You can access the graphics processor \(GPU\) on the AWS Panorama Appliance to use GPU\-accelerated libraries, or run machine learning models in your application code\. To turn on GPU access, you add GPU access as a requirement to the package configuration after building your application code container\. | ||
|
||
**Important** | ||
If you enable GPU access, you can't run model nodes in any application on the appliance\. For security purposes, GPU access is restricted when the appliance runs a model compiled with SageMaker Neo\. With GPU access, you must run your models in application code nodes, and all applications on the device share access to the GPU\. | ||
|
||
To turn on GPU access for your application, update the [package manifest](applications-packages.md) after you build the package with the AWS Panorama Application CLI\. The following example shows the `requirements` block that adds GPU access to the application code node\. | ||
|
||
**Example package\.json with requirements block** | ||
|
||
``` | ||
{ | ||
"nodePackage": { | ||
"envelopeVersion": "2021-01-01", | ||
"name": "SAMPLE_CODE", | ||
"version": "1.0", | ||
"description": "Computer vision application code.", | ||
"assets": [ | ||
{ | ||
"name": "code_asset", | ||
"implementations": [ | ||
{ | ||
"type": "container", | ||
"assetUri": "eba3xmpl71aa387e8f89be9a8c396416cdb80a717bb32103c957a8bf41440b12.tar.gz", | ||
"descriptorUri": "4abdxmpl5a6f047d2b3047adde44704759d13f0126c00ed9b4309726f6bb43400ba9.json", | ||
"requirements": [ | ||
{ | ||
"type": "hardware_access", | ||
"inferenceAccelerators": [ | ||
{ | ||
"deviceType": "nvhost_gpu", | ||
"accessType": "open" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
], | ||
"interfaces": [ | ||
... | ||
``` | ||
|
||
Update the package manifest between the build and packaging steps in your development workflow\. | ||
|
||
**To deploy an application with GPU access** | ||
|
||
1. To build the application container, use the `build-container` command\. | ||
|
||
``` | ||
$ panorama-cli build-container --container-asset-name code_asset --package-path packages/123456789012-SAMPLE_CODE-1.0 | ||
``` | ||
|
||
1. Add the `requirements` block to the package manifest\. | ||
|
||
1. To upload the container asset and package manifest, use the `package-application` command\. | ||
|
||
``` | ||
$ panorama-cli package-application | ||
``` | ||
|
||
1. Deploy the application\. | ||
|
||
For sample applications that use GPU access, visit the [aws\-panorama\-samples](https://github.com/aws-samples/aws-panorama-samples) GitHub repository\. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Application parameters<a name="applications-manifest-parameters"></a> | ||
|
||
Parameters are nodes that have a basic type and can be overridden during deployment\. A parameter can have a default value and a *decorator*, which instructs the application's user how to configure it\. | ||
|
||
**Parameter types** | ||
+ `string` – A string\. For example, `DEBUG`\. | ||
+ `int32` – An integer\. For example, `20` | ||
+ `float32` – A floating point number\. For example, `47.5` | ||
+ `boolean` – `true` or `false`\. | ||
|
||
The following example shows two parameters, a string and a number, which are sent to a code node as inputs\. | ||
|
||
**Example graph\.json – Parameters** | ||
|
||
``` | ||
"nodes": [ | ||
{ | ||
"name": "detection_threshold", | ||
"interface": "float32", | ||
"value": 20.0, | ||
"overridable": true, | ||
"decorator": { | ||
"title": "Threshold", | ||
"description": "The minimum confidence percentage for a positive classification." | ||
} | ||
}, | ||
{ | ||
"name": "log_level", | ||
"interface": "string", | ||
"value": "INFO", | ||
"overridable": true, | ||
"decorator": { | ||
"title": "Logging level", | ||
"description": "DEBUG, INFO, WARNING, ERROR, or CRITICAL." | ||
} | ||
} | ||
... | ||
], | ||
"edges": [ | ||
{ | ||
"producer": "detection_threshold", | ||
"consumer": "code_node.threshold" | ||
}, | ||
{ | ||
"producer": "log_level", | ||
"consumer": "code_node.log_level" | ||
} | ||
... | ||
] | ||
} | ||
``` | ||
|
||
You can modify parameters directly in the application manifest, or provide new values at deploy\-time with overrides\. For more information, see [Deploy\-time configuration with overrides](applications-overrides.md)\. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
# Application nodes<a name="applications-nodes"></a> | ||
|
||
Nodes are models, code, camera streams, output, and parameters\. A node has an interface, which defines its inputs and outputs\. The interface can be defined in a package in your account, a package provided by AWS Panorama, or a built\-in type\. | ||
|
||
In the following example, `code_node` and `model_node` refer to the sample code and model packages included with the sample application\. `camera_node` uses a package provided by AWS Panorama to create a placeholder for a camera stream that you specify during deployment\. | ||
|
||
**Example graph\.json – Nodes** | ||
|
||
``` | ||
"nodes": [ | ||
{ | ||
"name": "code_node", | ||
"interface": "123456789012::SAMPLE_CODE.interface" | ||
}, | ||
{ | ||
"name": "model_node", | ||
"interface": "123456789012::SQUEEZENET_PYTORCH_V1.interface" | ||
}, | ||
{ | ||
"name": "camera_node", | ||
"interface": "panorama::abstract_rtsp_media_source.rtsp_v1_interface", | ||
"overridable": true, | ||
"overrideMandatory": true, | ||
"decorator": { | ||
"title": "IP camera", | ||
"description": "Choose a camera stream." | ||
} | ||
} | ||
] | ||
``` | ||
|
||
## Edges<a name="applications-manifest-edges"></a> | ||
|
||
Edges map the output from one node to the input of another\. In the following example, the first edge maps the output from a camera stream node to the input of an application code node\. The names `video_in` and `video_out` are defined in the node packages' interfaces\. | ||
|
||
**Example graph\.json – edges** | ||
|
||
``` | ||
"edges": [ | ||
{ | ||
"producer": "camera_node.video_out", | ||
"consumer": "code_node.video_in" | ||
}, | ||
{ | ||
"producer": "code_node.video_out", | ||
"consumer": "output_node.video_in" | ||
}, | ||
``` | ||
|
||
In your application code, you use the `inputs` and `outputs` attributes to get images from the input stream, and send images to the output stream\. | ||
|
||
**Example application\.py – Video input and output** | ||
|
||
``` | ||
def process_streams(self): | ||
"""Processes one frame of video from one or more video streams.""" | ||
frame_start = time.time() | ||
self.frame_num += 1 | ||
logger.debug(self.frame_num) | ||
# Loop through attached video streams | ||
streams = self.inputs.video_in.get() | ||
for stream in streams: | ||
self.process_media(stream) | ||
... | ||
self.outputs.video_out.put(streams) | ||
``` | ||
|
||
## Abstract nodes<a name="applications-manifest-abstract"></a> | ||
|
||
In an application manifest, an abstract node refers to a package defined by AWS Panorama, which you can use as a placeholder in your application manifest\. AWS Panorama provides two types of abstract node\. | ||
|
||
**** | ||
+ **Camera stream** – Choose the camera stream that the application uses during deployment\. | ||
|
||
*Package name* – `panorama::abstract_rtsp_media_source` | ||
|
||
*Interface name* – `rtsp_v1_interface` | ||
+ **HDMI output** – Indicates that the application outputs video\. | ||
|
||
*Package name* – `panorama::hdmi_data_sink` | ||
|
||
*Interface name* – `hdmi0` | ||
|
||
The following example shows a basic set of packages, nodes, and edges for an application that processes camera streams and outputs video to a display\. The camera node, which uses the interface from the `abstract_rtsp_media_source` package in AWS Panorama, can accept multiple camera streams as input\. The output node, which references `hdmi_data_sink`, gives application code access to a video buffer that is output from the appliance's HDMI port\. | ||
|
||
**Example graph\.json – Abstract nodes** | ||
|
||
``` | ||
{ | ||
"nodeGraph": { | ||
"envelopeVersion": "2021-01-01", | ||
"packages": [ | ||
{ | ||
"name": "123456789012::SAMPLE_CODE", | ||
"version": "1.0" | ||
}, | ||
{ | ||
"name": "123456789012::SQUEEZENET_PYTORCH_V1", | ||
"version": "1.0" | ||
}, | ||
{ | ||
"name": "panorama::abstract_rtsp_media_source", | ||
"version": "1.0" | ||
}, | ||
{ | ||
"name": "panorama::hdmi_data_sink", | ||
"version": "1.0" | ||
} | ||
], | ||
"nodes": [ | ||
{ | ||
"name": "camera_node", | ||
"interface": "panorama::abstract_rtsp_media_source.rtsp_v1_interface", | ||
"overridable": true, | ||
"decorator": { | ||
"title": "IP camera", | ||
"description": "Choose a camera stream." | ||
} | ||
}, | ||
{ | ||
"name": "output_node", | ||
"interface": "panorama::hdmi_data_sink.hdmi0" | ||
} | ||
], | ||
"edges": [ | ||
{ | ||
"producer": "camera_node.video_out", | ||
"consumer": "code_node.video_in" | ||
}, | ||
{ | ||
"producer": "code_node.video_out", | ||
"consumer": "output_node.video_in" | ||
} | ||
] | ||
} | ||
} | ||
``` |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Deploy\-time configuration with overrides<a name="applications-overrides"></a> | ||
|
||
You configure parameters and abstract nodes during deployment\. If you use the AWS Panorama console to deploy, you can specify a value for each parameter and choose a camera stream as input\. If you use the AWS Panorama API to deploy applications, you specify these settings with an overrides document\. | ||
|
||
An overrides document is similar in structure to an application manifest\. For parameters with basic types, you define a node\. For camera streams, you define a node and a package that maps to a registered camera stream\. Then you define an override for each node that specifies the node from the application manifest that it replaces\. | ||
|
||
**Example overrides\.json** | ||
|
||
``` | ||
{ | ||
"nodeGraphOverrides": { | ||
"nodes": [ | ||
{ | ||
"name": "my_camera", | ||
"interface": "123456789012::exterior-south.exterior-south" | ||
}, | ||
{ | ||
"name": "my_region", | ||
"interface": "string", | ||
"value": "us-east-1" | ||
} | ||
], | ||
"packages": [ | ||
{ | ||
"name": "123456789012::exterior-south", | ||
"version": "1.0" | ||
} | ||
], | ||
"nodeOverrides": [ | ||
{ | ||
"replace": "camera_node", | ||
"with": [ | ||
{ | ||
"name": "my_camera" | ||
} | ||
] | ||
}, | ||
{ | ||
"replace": "region", | ||
"with": [ | ||
{ | ||
"name": "my_region" | ||
} | ||
] | ||
} | ||
], | ||
"envelopeVersion": "2021-01-01" | ||
} | ||
} | ||
``` | ||
|
||
In the preceding example, the document defines overrides for one string parameter and an abstract camera node\. The `nodeOverrides` tells AWS Panorama which nodes in this document override which in the application manifest\. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Package configuration<a name="applications-packages"></a> | ||
|
||
When you use the AWS Panorama Application CLI command `panorama-cli package-application`, the CLI uploads your application's assets to Amazon S3 and registers them with AWS Panorama\. Assets include binary files \(container images and models\) and descriptor files, which the AWS Panorama Appliance downloads during deployment\. To register a package's assets, you provide a separate package configuration file that defines the package, its assets, and its interface\. | ||
|
||
The following example shows a package configuration for a code node with one input and one output\. The video input provides access to image data from a camera stream\. The output node sends processed images out to a display\. | ||
|
||
**Example packages/1234567890\-SAMPLE\_CODE\-1\.0/package\.json** | ||
|
||
``` | ||
{ | ||
"nodePackage": { | ||
"envelopeVersion": "2021-01-01", | ||
"name": "SAMPLE_CODE", | ||
"version": "1.0", | ||
"description": "Computer vision application code.", | ||
"assets": [ | ||
{ | ||
"name": "code_asset", | ||
"implementations": [ | ||
{ | ||
"type": "container", | ||
"assetUri": "3d9bxmplbdb67a3c9730abb19e48d78780b507f3340ec3871201903d8805328a.tar.gz", | ||
"descriptorUri": "1872xmpl129481ed053c52e66d6af8b030f9eb69b1168a29012f01c7034d7a8f.json" | ||
} | ||
] | ||
} | ||
], | ||
"interfaces": [ | ||
{ | ||
"name": "interface", | ||
"category": "business_logic", | ||
"asset": "code_asset", | ||
"inputs": [ | ||
{ | ||
"name": "video_in", | ||
"type": "media" | ||
} | ||
], | ||
"outputs": [ | ||
{ | ||
"description": "Video stream output", | ||
"name": "video_out", | ||
"type": "media" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} | ||
``` | ||
|
||
The `assets` section specifies the names of artifacts that the AWS Panorama Application CLI uploaded to Amazon S3\. If you import a sample application or an application from another user, this section can be empty or refer to assets that aren't in your account\. When you run `panorama-cli package-application`, the AWS Panorama Application CLI populates this section with the correct values\. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,205 @@ | ||
# Serving inbound traffic<a name="applications-ports"></a> | ||
|
||
You can monitor or debug applications locally by running an HTTP server alongside your application code\. To serve external traffic, you map ports on the AWS Panorama Appliance to ports on your application container\. | ||
|
||
**Important** | ||
By default, the AWS Panorama Appliance does not accept incoming traffic on any ports\. Opening ports on the appliance has implicit security risk\. When you use this feature, you must take additional steps to [secure your appliance from external traffic](appliance-network.md) and secure communications between authorized clients and the appliance\. | ||
The sample code included with this guide is for demonstration purposes and does not implement authentication, authorization, or encryption\. | ||
|
||
You can open up ports in the range 8000\-9000 on the appliance\. These ports, when opened, can receive traffic from any routable client\. When you deploy your application, you specify which ports to open, and map ports on the appliance to ports on your application container\. The appliance software forwards traffic to the container, and sends responses back to the requestor\. Requests are received on the appliance port you specify and responses go out on a random ephemeral port\. | ||
|
||
## Configuring inbound ports<a name="applications-ports-configuration"></a> | ||
|
||
You specify port mappings in 3 places in your application configuration\. The code package's `package.json`, you specify the port that the code node listens on in a `network` block\. The following example declares that the node listens on port 80\. | ||
|
||
**Example [packages/123456789012\-DEBUG\_SERVER\-1\.0/package\.json](https://github.com/awsdocs/aws-panorama-developer-guide/blob/main/sample-apps/debug-server/packages/123456789012-DEBUG_SERVER-1.0/package.json)** | ||
|
||
``` | ||
"outputs": [ | ||
{ | ||
"description": "Video stream output", | ||
"name": "video_out", | ||
"type": "media" | ||
} | ||
], | ||
"network": { | ||
"inboundPorts": [ | ||
{ | ||
"port": 80, | ||
"description": "http" | ||
} | ||
] | ||
} | ||
``` | ||
|
||
In the application manifest, you declare a routing rule that maps a port on the appliance to a port on the application's code container\. The following example adds a rule that maps port 8080 on the device to port 80 on the `code_node` container\. | ||
|
||
**Example [graphs/my\-app/graph\.json](https://github.com/awsdocs/aws-panorama-developer-guide/blob/main/sample-apps/debug-server/graphs/my-app/graph.json)** | ||
|
||
``` | ||
{ | ||
"producer": "model_input_width", | ||
"consumer": "code_node.model_input_width" | ||
}, | ||
{ | ||
"producer": "model_input_order", | ||
"consumer": "code_node.model_input_order" | ||
} | ||
], | ||
"networkRoutingRules": [ | ||
{ | ||
"node": "code_node", | ||
"containerPort": 80, | ||
"hostPort": 8080, | ||
"decorator": { | ||
"title": "Listener port 8080", | ||
"description": "Container monitoring and debug." | ||
} | ||
} | ||
] | ||
``` | ||
|
||
When you deploy the application, you specify the same rules in the AWS Panorama console, or with an override document passed to the [CreateApplicationInstance](https://docs.aws.amazon.com/panorama/latest/api/API_CreateApplicationInstance.html) API\. You must provide this configuration at deploy time to confirm that you want to open ports on the appliance\. | ||
|
||
**Example [graphs/my\-app/override\.json](https://github.com/awsdocs/aws-panorama-developer-guide/blob/main/sample-apps/debug-server/graphs/my-app/override.json)** | ||
|
||
``` | ||
{ | ||
"replace": "camera_node", | ||
"with": [ | ||
{ | ||
"name": "exterior-north" | ||
} | ||
] | ||
} | ||
], | ||
"networkRoutingRules":[ | ||
{ | ||
"node": "code_node", | ||
"containerPort": 80, | ||
"hostPort": 8080 | ||
} | ||
], | ||
"envelopeVersion": "2021-01-01" | ||
} | ||
} | ||
``` | ||
|
||
If the device port specified in the application manifest is in use by another application, you can use the override document to choose a different port\. | ||
|
||
## Serving traffic<a name="applications-ports-serverthread"></a> | ||
|
||
With ports open on the container, you can open a socket or run a server to handle incoming requests\. The `debug-server` sample shows a basic implementation of an HTTP server running alongside computer vision application code\. | ||
|
||
**Important** | ||
The sample implementation is not secure for production use\. To avoid making your appliance vulnerable to attacks, you must implement appropriate security controls in your code and network configuration\. | ||
|
||
**Example [packages/123456789012\-DEBUG\_SERVER\-1\.0/application\.py](https://github.com/awsdocs/aws-panorama-developer-guide/blob/main/sample-apps/debug-server/packages/123456789012-DEBUG_SERVER-1.0/application.py) – HTTP server** | ||
|
||
``` | ||
# HTTP debug server | ||
def run_debugger(self): | ||
"""Process debug commands from local network.""" | ||
class ServerHandler(SimpleHTTPRequestHandler): | ||
# Store reference to application | ||
application = self | ||
# Get status | ||
def do_GET(self): | ||
"""Process GET requests.""" | ||
logger.info('Get request to {}'.format(self.path)) | ||
if self.path == '/status': | ||
self.send_200('OK') | ||
else: | ||
self.send_error(400) | ||
# Restart application | ||
def do_POST(self): | ||
"""Process POST requests.""" | ||
logger.info('Post request to {}'.format(self.path)) | ||
if self.path == '/restart': | ||
self.send_200('OK') | ||
ServerHandler.application.stop() | ||
else: | ||
self.send_error(400) | ||
# Send response | ||
def send_200(self, msg): | ||
"""Send 200 (success) response with message.""" | ||
self.send_response(200) | ||
self.send_header('Content-Type', 'text/plain') | ||
self.end_headers() | ||
self.wfile.write(msg.encode('utf-8')) | ||
try: | ||
# Run HTTP server | ||
self.server = HTTPServer(("", self.CONTAINER_PORT), ServerHandler) | ||
self.server.serve_forever(1) | ||
# Server shut down by run_cv loop | ||
logger.info("EXITING SERVER THREAD") | ||
except: | ||
logger.exception('Exception on server thread.') | ||
``` | ||
|
||
The server accepts GET requests at the `/status` path to retrieve some information about the application\. It also accepts a POST request to `/restart` to restart the application\. | ||
|
||
To demonstrate this functionality, the sample application runs an HTTP client on a separate thread\. The client calls the `/status` path over the local network shortly after startup, and restarts the application a few minutes later\. | ||
|
||
**Example [packages/123456789012\-DEBUG\_SERVER\-1\.0/application\.py](https://github.com/awsdocs/aws-panorama-developer-guide/blob/main/sample-apps/debug-server/packages/123456789012-DEBUG_SERVER-1.0/application.py) – HTTP client** | ||
|
||
``` | ||
# HTTP test client | ||
def run_client(self): | ||
"""Send HTTP requests to device port to demnostrate debug server functions.""" | ||
def client_get(): | ||
"""Get container status""" | ||
r = requests.get('http://{}:{}/status'.format(self.device_ip, self.DEVICE_PORT)) | ||
logger.info('Response: {}'.format(r.text)) | ||
return | ||
def client_post(): | ||
"""Restart application""" | ||
r = requests.post('http://{}:{}/restart'.format(self.device_ip, self.DEVICE_PORT)) | ||
logger.info('Response: {}'.format(r.text)) | ||
return | ||
# Call debug server | ||
while not self.terminate: | ||
try: | ||
time.sleep(30) | ||
client_get() | ||
time.sleep(300) | ||
client_post() | ||
except: | ||
logger.exception('Exception on client thread.') | ||
# stop signal received | ||
logger.info("EXITING CLIENT THREAD") | ||
``` | ||
|
||
The main loop manages the threads and restarts the application when they exit\. | ||
|
||
**Example [packages/123456789012\-DEBUG\_SERVER\-1\.0/application\.py](https://github.com/awsdocs/aws-panorama-developer-guide/blob/main/sample-apps/debug-server/packages/123456789012-DEBUG_SERVER-1.0/application.py) – Main loop** | ||
|
||
``` | ||
def main(): | ||
panorama = panoramasdk.node() | ||
while True: | ||
try: | ||
# Instantiate application | ||
logger.info('INITIALIZING APPLICATION') | ||
app = Application(panorama) | ||
# Create threads for stream processing, debugger, and client | ||
app.run_thread = threading.Thread(target=app.run_cv) | ||
app.server_thread = threading.Thread(target=app.run_debugger) | ||
app.client_thread = threading.Thread(target=app.run_client) | ||
# Start threads | ||
logger.info('RUNNING APPLICATION') | ||
app.run_thread.start() | ||
logger.info('RUNNING SERVER') | ||
app.server_thread.start() | ||
logger.info('RUNNING CLIENT') | ||
app.client_thread.start() | ||
# Wait for threads to exit | ||
app.run_thread.join() | ||
app.server_thread.join() | ||
app.client_thread.join() | ||
logger.info('RESTARTING APPLICATION') | ||
except: | ||
logger.exception('Exception during processing loop.') | ||
``` | ||
|
||
To deploy the sample application, see the [instructions in this guide's GitHub repository\.](https://github.com/awsdocs/aws-panorama-developer-guide/blob/main/sample-apps/debug-server/README.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Monitoring appliances and applications with Amazon CloudWatch<a name="monitoring-metrics"></a> | ||
|
||
When an appliance is online, AWS Panorama sends metrics to Amazon CloudWatch\. You can build graphs and dashboards with these metrics in the CloudWatch console to monitor appliance activity, and set alarms that notify you when devices go offline or applications encounter errors\. | ||
|
||
**To view metrics in the CloudWatch console** | ||
|
||
1. Open the [AWS Panorama console Metrics page](https://console.aws.amazon.com/cloudwatch/home#metricsV2:graph=~();namespace=~'PanoramaDeviceMetrics) \(`PanoramaDeviceMetrics` namespace\)\. | ||
|
||
1. Choose a dimension schema\. | ||
|
||
1. Choose metrics to add them to the graph\. | ||
|
||
1. To choose a different statistic and customize the graph, use the options on the **Graphed metrics** tab\. By default, graphs use the `Average` statistic for all metrics\. | ||
|
||
**Pricing** | ||
CloudWatch has an Always Free tier\. Beyond the free tier threshold, CloudWatch charges for metrics, dashboards, alarms, logs, and insights\. For details, see [CloudWatch pricing](https://aws.amazon.com/cloudwatch/pricing/)\. | ||
|
||
For more information about CloudWatch, see the [https://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/](https://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/)\. | ||
|
||
**Topics** | ||
+ [Using device metrics](#monitoring-cloudwatch-device) | ||
+ [Using application metrics](#monitoring-cloudwatch-application) | ||
+ [Configuring alarms](#monitoring-cloudwatch-alarms) | ||
|
||
## Using device metrics<a name="monitoring-cloudwatch-device"></a> | ||
|
||
When an appliance is online, it sends metrics to Amazon CloudWatch\. You can use these metrics to monitor device activity and trigger an alarm if devices go offline\. | ||
+ `DeviceActive` – Sent periodically when the device is active\. | ||
|
||
Dimensions – `DeviceId` and `DeviceName`\. | ||
|
||
View the `DeviceActive` metric with the `Average` statistic\. | ||
|
||
## Using application metrics<a name="monitoring-cloudwatch-application"></a> | ||
|
||
When an application encounters an error, it sends metrics to Amazon CloudWatch\. You can use these metrics to trigger an alarm if an application stops running\. | ||
+ `ApplicationErrors` – The number of application errors recorded\. | ||
|
||
Dimensions – `ApplicationInstanceName` and `ApplicationInstanceId`\. | ||
|
||
View the application metrics with the `Sum` statistic\. | ||
|
||
## Configuring alarms<a name="monitoring-cloudwatch-alarms"></a> | ||
|
||
To get notifications when a metric exceeds a threshold, create an alarm\. For example, you can create an alarm that sends a notification when the sum of the `ApplicationErrors` metric stays at 1 for 20 minutes\. | ||
|
||
**To create an alarm** | ||
|
||
1. Open the [Amazon CloudWatch console Alarms page](https://console.aws.amazon.com/cloudwatch/home#alarmsV2:)\. | ||
|
||
1. Choose **Create alarm**\. | ||
|
||
1. Choose **Select metric** and locate a metric for your device, such as `ApplicationErrors` for `applicationInstance-gk75xmplqbqtenlnmz4ehiu7xa`,`my-application`\. | ||
|
||
1. Follow the instructions to configure a condition, action, and name for the alarm\. | ||
|
||
For detailed instructions, see [Create a CloudWatch alarm](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/ConsoleAlarms.html) in the *Amazon CloudWatch User Guide*\. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,11 @@ | ||
# Building AWS Panorama applications<a name="panorama-applications"></a> | ||
# Managing AWS Panorama applications<a name="panorama-applications"></a> | ||
|
||
Applications run on the AWS Panorama Appliance to perform computer vision tasks on video streams\. You can build computer vision applications by combining Python code and machine learning models, and deploy them to the AWS Panorama Appliance over the internet\. Applications can send video to a display, or use the AWS SDK to send results to AWS services\. | ||
|
||
A [model](applications-models.md) analyzes images to detect people, vehicles, and other objects\. Based on images that it has seen during training, the model tells you what it thinks something is, and how confident it is in its guess\. You can train models with your own image data or get started with a sample\. | ||
|
||
The application's [code](gettingstarted-sample.md) process still images from a camera stream, sends them to a model, and processes the result\. A model might detect multiple objects and return their shapes and location\. The code can use this information to add text or graphics to the video, or to send results to an AWS service for storage or further processing\. | ||
|
||
To get images from a stream, interact with a model, and output video, application code uses [the AWS Panorama Application SDK](applications-panoramasdk.md)\. The application SDK is a Python library that supports models generated with PyTorch, Apache MXNet, and TensorFlow\. | ||
|
||
**Topics** | ||
+ [Managing applications in AWS Panorama](applications-manage.md) | ||
+ [Package configuration](applications-packages.md) | ||
+ [The AWS Panorama application manifest](applications-manifest.md) | ||
+ [Computer vision models](applications-models.md) | ||
+ [Calling AWS services from your application code](applications-awssdk.md) | ||
+ [Adding text and boxes to output video](applications-overlays.md) | ||
+ [The AWS Panorama Application SDK](applications-panoramasdk.md) | ||
+ [Setting up a development environment in Windows](applications-devenvwindows.md) | ||
+ [Migrate applications from preview](applications-migrate.md) | ||
+ [Application nodes](applications-nodes.md) | ||
+ [Application parameters](applications-manifest-parameters.md) | ||
+ [Deploy\-time configuration with overrides](applications-overrides.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Building AWS Panorama applications<a name="panorama-development"></a> | ||
|
||
Applications run on the AWS Panorama Appliance to perform computer vision tasks on video streams\. You can build computer vision applications by combining Python code and machine learning models, and deploy them to the AWS Panorama Appliance over the internet\. Applications can send video to a display, or use the AWS SDK to send results to AWS services\. | ||
|
||
A [model](applications-models.md) analyzes images to detect people, vehicles, and other objects\. Based on images that it has seen during training, the model tells you what it thinks something is, and how confident it is in its guess\. You can train models with your own image data or get started with a sample\. | ||
|
||
The application's [code](gettingstarted-sample.md) process still images from a camera stream, sends them to a model, and processes the result\. A model might detect multiple objects and return their shapes and location\. The code can use this information to add text or graphics to the video, or to send results to an AWS service for storage or further processing\. | ||
|
||
To get images from a stream, interact with a model, and output video, application code uses [the AWS Panorama Application SDK](applications-panoramasdk.md)\. The application SDK is a Python library that supports models generated with PyTorch, Apache MXNet, and TensorFlow\. | ||
|
||
**Topics** | ||
+ [Computer vision models](applications-models.md) | ||
+ [Calling AWS services from your application code](applications-awssdk.md) | ||
+ [The AWS Panorama Application SDK](applications-panoramasdk.md) | ||
+ [Serving inbound traffic](applications-ports.md) | ||
+ [Using the GPU](applications-gpuaccess.md) | ||
+ [Setting up a development environment in Windows](applications-devenvwindows.md) | ||
+ [Migrate applications from preview](applications-migrate.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Sample applications, scripts, and templates<a name="panorama-samples"></a> | ||
|
||
The GitHub repository for this guide provides sample applications, scripts and templates for AWS Panorama devices\. Use these samples to learn best practices and automate development workflows\. | ||
|
||
**Topics** | ||
+ [Sample applications](#samples-applications) | ||
+ [Utility scripts](#samples-scripts) | ||
+ [AWS CloudFormation templates](#samples-templates) | ||
|
||
## Sample applications<a name="samples-applications"></a> | ||
|
||
Sample applications demonstrate use of AWS Panorama features and common computer vision tasks\. These sample applications include scripts and templates that automate setup and deployment\. With minimal configuration, you can deploy and update applications from the command line\. | ||
|
||
**** | ||
+ [aws\-panorama\-sample](https://github.com/awsdocs/aws-panorama-developer-guide/blob/main/sample-apps/aws-panorama-sample) – Basic computer vision with a classification model\. Use the AWS SDK for Python \(Boto\) to upload metrics to CloudWatch, instrument preprocessing and inference methods, and configure logging\. | ||
+ [debug\-server](https://github.com/awsdocs/aws-panorama-developer-guide/blob/main/sample-apps/debug-server) – [Open inbound ports](applications-ports.md) on the device and forward traffic to an application code container\. Use multithreading to run application code, an HTTP server, and an HTTP client simultaneously\. | ||
+ [custom\-model](https://github.com/awsdocs/aws-panorama-developer-guide/blob/main/sample-apps/custom-model) – Export models from code and compile with SageMaker Neo to test compatibility with the AWS Panorama Appliance\. Build locally in a Python development, in a Docker container, or on an Amazon EC2 instance\. Export and compile all built\-in application models in Keras for a specific TensorFlow or Python version\. | ||
|
||
For more sample applications, also visit the [aws\-panorama\-samples](https://github.com/aws-samples/aws-panorama-samples) repository\. | ||
|
||
## Utility scripts<a name="samples-scripts"></a> | ||
|
||
The scripts in the `util-scripts` directory manage AWS Panorama resources or automate development workflows\. | ||
|
||
**** | ||
+ [register\-camera\.sh](https://github.com/awsdocs/aws-panorama-developer-guide/blob/main/util-scripts/register-camera.sh) – Register a camera\. | ||
+ [deregister\-camera\.sh](https://github.com/awsdocs/aws-panorama-developer-guide/blob/main/util-scripts/deregister-camera.sh) – Delete a camera node\. | ||
+ [push\.sh](https://github.com/awsdocs/aws-panorama-developer-guide/blob/main/util-scripts/push.sh) – Build, upload, and deploy and application\. | ||
+ [rename\-package\.sh](https://github.com/awsdocs/aws-panorama-developer-guide/blob/main/util-scripts/rename-package.sh) – Rename a node package\. Updates directory names, configuration files, and the application manifest\. | ||
+ [samplify\.sh](https://github.com/awsdocs/aws-panorama-developer-guide/blob/main/util-scripts/samplify.sh) – Replace your account ID with an example account ID, and restore backup configurations to remove local configuration\. | ||
+ [update\-model\-config\.sh](https://github.com/awsdocs/aws-panorama-developer-guide/blob/main/util-scripts/update-model-config.sh) – Re\-add the model to the application after updating the descriptor file\. | ||
+ [view\-logs\.sh](https://github.com/awsdocs/aws-panorama-developer-guide/blob/main/util-scripts/view-logs.sh) – View logs for an application instance\. | ||
|
||
For usage details, see [the README](https://github.com/awsdocs/aws-panorama-developer-guide/blob/main/util-scripts)\. | ||
|
||
## AWS CloudFormation templates<a name="samples-templates"></a> | ||
|
||
Use the AWS CloudFormation templates in the `cloudformation-templates` directory to create resources for AWS Panorama applications\. | ||
|
||
**** | ||
+ [application\-role\.yml](https://github.com/awsdocs/aws-panorama-developer-guide/blob/main/cloudformation-templates/application-role.yml) – Create an application role\. The role includes permission to send metrics to CloudWatch\. Add permissions to the policy statement for other API operations that your application uses\. | ||
|
||
The `create-stack.sh` script in this directory creates AWS CloudFormation stacks\. It takes a variable number of arguments\. The first argument is the name of the template, and the remaining arguments are overrides for parameters in the template\. | ||
|
||
For example, the following comand creates an application role\. | ||
|
||
``` | ||
$ ./create-stack.sh application-role | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters