Connect with us

Amazon

Enable scalable, highly accurate, and cost-effective video analytics with Axis Communications and Amazon Rekognition

With the number of cameras and sensors deployed growing exponentially, companies across industries are consuming more video than ever before. Additionally, advancements in analytics have expanded potential use cases, and these devices are now used to improve business operations and intelligence. In turn, the ability to effectively process video at these rapidly expanding volumes is…

Published

on

With the number of cameras and sensors deployed growing exponentially, companies across industries are consuming more video than ever before. Additionally, advancements in analytics have expanded potential use cases, and these devices are now used to improve business operations and intelligence. In turn, the ability to effectively process video at these rapidly expanding volumes is now critical—but too often, it still falls to manual review. This is unreliable, poorly scalable, and costly, and underscores the need for automation to process video accurately, at scale.

In this post, we show you how to enable your Axis Communications cameras with Amazon Rekognition. Combining Axis edge technology with Amazon Rekognition provides an efficient and scalable solution capable of delivering the high-quality video analysis needed to generate actionable business and security insights.

Proactively analyzing video helps drive business outcomes

Video surveillance has typically been utilized in a reactive way, with security personnel monitoring banks of wall monitors for anything amiss or reviewing footage after the fact for evidence. Advances in edge capabilities and artificial intelligence (AI) and machine learning (ML) in the cloud have enabled today’s cameras to respond to incidents in real time.

High-quality cameras can now capture more accurate and detailed images for analysis in the cloud, which has made analytics more accessible. Edge processing can also make this analysis more feasible, reducing bandwidth by lowering the amount of data that must be transmitted for effective analysis. This combination of improved processing, image quality, and AI and ML capabilities has made serious breakthroughs possible. These advances, including object detection and tracking and pan/tilt/zoom cameras, have improved the quality of images for processing and analysis. Reviewing these images is also easier than ever, with searchable image and video libraries tagged with relevant markers.

The opportunity to apply advanced analytics has therefore never been greater. Companies across industries, including enterprise security, retail, manufacturing, hospitality, travel, and more, are using a hybrid edge plus cloud approach to scale use cases like person of interest detection, automated access management, people and vehicle counting, heat mapping, PPE compliance analysis, sentiment analysis, and product defect and anomaly detection. With these advanced analytics, companies can improve their business KPIs, whether it be improving customer safety, making customer experiences more seamless, or diminishing product defects.

Enhance video analysis with Axis Communications and Amazon Rekognition

Axis Communications is the industry leader in IP cameras and network solutions that provide insights for improving security and new ways of doing business. As the industry leader, Axis offers network products and services for intelligent video surveillance, access control, intercom, and audio.

Amazon Rekognition is an AI service that uses deep learning technology to allow you to extract meaningful metadata from images and videos – including identifying objects, people, text, scenes, and activities, and potentially inappropriate content – with no ML expertise required. Amazon Rekognition also provides highly accurate facial analysis and facial search capabilities that you can use to detect, analyze, and compare faces for a wide variety of user verification, people counting, and safety use cases. Lastly, with Amazon Rekognition Custom Labels, you can use your own data to build your own object detection and image classification models.

The combination of Axis technology for video ingestion and edge preprocessing with Amazon Rekognition for computer vision provides a highly scalable workflow for video analytics. Ease of use is a significant positive factor here because adding Amazon Rekognition to existing systems isn’t difficult – it’s as simple as integrating an API into a workflow. No need to be an ML scientist; simply send captured frames to AWS and receive a result that can be entered into a database.

Serverless computing, through AWS Lambda, also makes life easier for both customers and integrators. It means less hardware needs to be deployed, which also reduces the cost of deployment. And because Axis cameras are processing video at the network edge, you can set intelligent rules to determine when these devices should send captured images to Amazon Rekognition for further analysis – saving considerable bandwidth. With just a few lines of code, you can create the glue that attaches received images to Amazon Rekognition.

This further underscores the dramatic improvement over manual review. Better results can be achieved faster and with greater accuracy – without the need for costly, unnecessary manhours. With so many potential use cases, the combination of Axis devices and Amazon Rekognition has the potential to provide today’s businesses with significant and immediate ROI.

Solution overview

First, preprocessing is performed at the edge using an Axis camera. You can use a variety of different events to trigger when to capture an image and sent it to AWS for further image analysis:

  • Axis native camera event triggers – These include the following:
    • Digital I/O input
    • Scheduled event
    • Virtual input (input from other sensors to trigger the image upload)
    • Tampering
    • Shock detection
    • Audio detection
  • Axis analytic event triggers – The following is a list of Axis analytical camera applications that you can use to trigger an image capture. You can also develop your own apps to run on the camera to generate an event. For more information, see AXIS Camera Application Platform.
    • Motion detection, which is installed on all cameras by default
    • Axis Object Analytics captures a person or vehicle in a scene
    • Axis Face Detector captures faces found in a scene
    • Axis License Plate Verifier reads license plates
    • Axis Live Privacy Shield masks people for privacy
    • Axis Fence Guard allows you to set up virtual fences in a camera’s field of view
    • Axis Loitering Guard captures a person or vehicle in a scene loitering

Second, combining Amazon API Gateway, Lambda, and Amazon Simple Storage Service (Amazon S3) with an Axis network camera and its event system allows you to securely upload images to the AWS Cloud.

Third, you can send those images to Amazon Rekognition for analysis of what’s in the frames (such as people, faces, and vehicles).

The following diagram illustrates this architecture.

Now let’s dive into how to set up the cloud services needed and configure the event system in the Axis network camera to upload the images.

The solution setup is divided in two sections: one for the AWS setup and one for the Axis camera setup.

The AWS services and camera configurations needed in order to send an image to Amazon S3 are managed via an example application that can be downloaded from an Axis Communications GitHub repository. The application consists of the following AWS resources:

Because the camera can’t sign requests using AWS Signature Version 4, we need to include a Lambda function to handle this step. Rather than sending images directly from the Axis camera to Amazon S3, we instead send them to an API Gateway. The API Gateway delegates authorization to a Lambda authorizer that compares the provided access token to an access token stored in Secrets Manager. If the provided access token is deemed valid, the API Gateway forwards the request to a Lambda function that uploads the provided image to an S3 bucket.

Prerequisites

Before you get started, make sure you have the following prerequisites:

AWS setup

For your AWS-side configuration, complete the following steps:

  1. Clone the GitHub repo.
  2. In your AWS CLI terminal, start by authenticating access to AWS. Depending on your organization’s setup, several authentication options may be valid. For this post, we use multi-factor authentication (MFA) to authenticate access to AWS. Modify and run the following command:

$ aws sts get-session-token –serial-number arn-of-the-mfa-device –token-code code-from-token

When you’re authenticated against AWS, you can start building and deploying the AWS services receiving the snapshots sent from a network camera. The service resources are described in template.yaml using the AWS Sam.

  1. Run the following command:

sam build sam deploy –guided

The first command builds the source of your application. The second command packages and deploys your application to AWS, with a series of prompts:

  • Stack Name – The name of the stack to deploy to AWS CloudFormation. This should be unique to your account and Region; a good starting point would be images-to-aws-s3 or something similar.
  • AWS Region – The Region you want to deploy your app to.
  • Confirm changes before deploy – If set to yes, any change sets are shown to you before running manual review. If set to no, the AWS SAM CLI automatically deploys application changes.
  • Allow SAM CLI IAM role creation – This AWS SAM template creates AWS Identity and Access Management (IAM) roles required for the Lambda function to access AWS services. By default, these are scoped down to minimum required permissions. Choose Y to have the AWS SAM automatically create the roles.
  • Save arguments to samconfig.toml – If set to Y, your choices are saved to a configuration file inside the project, so that in the future you can just rerun sam deploy without parameters to deploy changes to your application.
  1. After a successful deployment, navigate to your newly created CloudFormation stack on the AWS CloudFormation console.

You’ll find the API Gateway forwarding requests to Lambda, and the Lambda function saves the image snapshots to an S3 bucket.

The deployed CloudFormation stack created two output parameters that we use when configuring our Axis camera:

  • Recipient – Defines the URL of the API Gateway where cameras should send their snapshots.
  • AccessToken – Contains the URL to the secret API access token found in Secret Manager. This API access token authorizes the camera and allows it to send snapshots.
  1. Enter the link to the AccessToken in your browser to go directly to where you can find the secret.

You use the secret in your API Gateway to authenticate the image upload.

Requests to the API Gateway without this access token are denied access.

Axis camera setup

In the camera, you need to set up an HTTPS recipient to the API Gateway and an event in the camera that’s used as a trigger when an image should be uploaded.

  1. Log in to the camera.
  2. On the System tab, choose Events.
  3. On the Recipients tab, choose the plus sign to add the API Gateway recipient URL.

No username and password are needed here; the authentication is handled via the access token (AccessToken) that you enter as a custom CGI parameter in a later step.

  1. On the Rules tab, choose the plus sign to add a condition for when to send an image to Amazon S3.
  2. Choose Manual trigger to manually trigger an upload of a limited number of images to Amazon S3.
  3. For Postbuffer, enter 00:01.
  4. For Maximum images, enter 1.

If you need to take images and upload them to Amazon S3 automatically, at a given period of time, you can use a the pulse type condition. In this case, you can specify a pulse interval like every minute or every second. For more information about how to capture an image snapshot, see AXIS OS Portal User manual.

  1. For Custom CGI parameters, enter the AccessToken value.
  2. Choose Save.

Test the setup

After you send some images (manually or automatically) from the camera, you can open the Amazon S3 console to verify that the images are uploaded correctly.

Analyse frames with Amazon Rekognition

You can now call Amazon Rekognition APIs to analyse the frame you stored on S3, by triggering an AWS Lambda function invoking the Amazon Rekongition API that you need. The following instructions show how to create a Lambda function in Python that calls Amazon Rekognition DetectLabels.

Step 1: Create an AWS Lambda function (console)

  1. Sign in to the AWS Management Console and open the AWS Lambda console at https://console.aws.amazon.com/lambda/.
  2. Choose Create function. For more information, see Create a Lambda Function with the Console.
  3. Choose the following options.
    • Choose Author from scratch.
    • Enter a value for Function name.
    • For Runtimechoose Python (from7 to  3.9 version).
    • For Choose or create an execution role, choose Create a new role with basic Lambda permissions.
  4. Choose Create functionto create the AWS Lambda function.

Step 2: Attach Amazon Rekognition and Amazon S3 permissions to AWS Lambda created role

  1. Open the IAM console at https://console.aws.amazon.com/iam/.
  2. From the navigation pane, choose Roles.
  3. From the resources list, choose the IAM role that AWS Lambda created for you. The role name is prepended with the name of your Lambda function.
  4. In the Permissionstab, choose Attach policies.
  5. Add the AmazonRekognitionFullAccessand AmazonS3ReadOnlyAccess.
  6. Choose Attach Policy.

Step 3: Add Python code in AWS Lambda console

  1. In AWS Lambda, choose your function name.
  2. In Function Overview panel choose +Add trigger.
  3. Select S3 trigger, then select the bucket where the Axis camera is storing the camera frames (in our example images-to-aws-s3-bucket-1o45tt35jsonk).
  4. In event type choose PUT.
  5. Flag the Recursive invocation acknowledgment and then click on Add.

Step 4: Add Python code in AWS Lambda console

  1. In AWS Lambda function page select the code tab.
  2. In the function code editor, add the following to the file py. This function will process each frame just after the upload from the Axis Camera, because of the trigger on the PUT event we configured at step 3. import json import boto3 def lambda_handler(event, context): # Get the object from the S3 event bucket = event[‘Records’][0][‘s3’][‘bucket’][‘name’] key = urllib.parse.unquote_plus( event[‘Records’][0][‘s3’][‘object’][‘key’], encoding=’utf-8′) client=boto3.client(‘rekognition’) response = client.detect _labels( Image={‘S3Object’: {‘Bucket’: bucket, ‘Name’: frame}}, MaxLabels=10) #Get the labels labels=response[‘Labels’] #Add your custom code here for storing Rekognition results return { ‘statusCode’: 200, ‘body’: json.dumps(labels) }
  3. Choose Save to save your Lambda function.

Step 5: Test your AWS Lambda function (console)

  1. Choose Test.
  2. Choose s3-put as Event template.
  3. Enter a value for Event name.
  4. Change bucket name and objet key in the test json request byt providing the bucket name and one frame name you already have on Amazon S3.
  5. Choose Create.
  6. Choose Test. The Lambda function is invoked. The output is displayed in the Execution results pane of the code editor. The output is a list of labels found by Amazon Rekognition on the given frame.

Conclusion

Getting started with Axis Communications and Amazon Rekognition is easy. Integrators are a critical delivery mechanism for this technology, and its countless integrations provide opportunities to offer expanding services to new and existing customers. The application has been released to the public via GitHub for integrators to review. You can find a code sample on how to send images to S3 below, or click on this GitHub link to get started now.

Please go to this link to find out more information on how to get started with Amazon Rekognition. Additionally, details on Amazon Rekognition pricing can be found here. Amazon Rekognition image APIs come with a free tier that lasts 12 months and allows you to analyze 5,000 images per month and store 1,000 pieces of face metadata per month.

If you are interested in becoming a partner, please visit the channel network at Axis Communications and the partner network at AWS.

About the Author

Oliver Myers is the Principal WW Business Development Manager for Amazon Rekognition (an AI service that allows customers to extract visual metadata from images and videos) at AWS. In this role he focuses on helping customers implement computer vision into their business workflows across industries.

 

 

Woody Borraccino is a Senior AI Solutions Architect at AWS.



Source

Continue Reading
Click to comment

Leave a Reply

Your email address will not be published.

Amazon

Customize pronunciation using lexicons in Amazon Polly

Amazon Polly is a text-to-speech service that uses advanced deep learning technologies to synthesize natural-sounding human speech. It is used in a variety of use cases, such as contact center systems, delivering conversational user experiences with human-like voices for automated real-time status check, automated account and billing inquiries, and by news agencies like The Washington…

Published

on

By

Amazon Polly is a text-to-speech service that uses advanced deep learning technologies to synthesize natural-sounding human speech. It is used in a variety of use cases, such as contact center systems, delivering conversational user experiences with human-like voices for automated real-time status check, automated account and billing inquiries, and by news agencies like The Washington Post to allow readers to listen to news articles.

As of today, Amazon Polly provides over 60 voices in 30+ language variants. Amazon Polly also uses context to pronounce certain words differently based upon the verb tense and other contextual information. For example, “read” in “I read a book” (present tense) and “I will read a book” (future tense) is pronounced differently.

However, in some situations you may want to customize the way Amazon Polly pronounces a word. For example, you may need to match the pronunciation with local dialect or vernacular. Names of things (e.g., Tomato can be pronounced as tom-ah-to or tom-ay-to), people, streets, or places are often pronounced in many different ways.

In this post, we demonstrate how you can leverage lexicons for creating custom pronunciations. You can apply lexicons for use cases such as publishing, education, or call centers.

Customize pronunciation using SSML tag

Let’s say you stream a popular podcast from Australia and you use the Amazon Polly Australian English (Olivia) voice to convert your script into human-like speech. In one of your scripts, you want to use words that are unknown to Amazon Polly voice. For example, you want to send Mātariki (Māori New Year) greetings to your New Zealand listeners. For such scenarios, Amazon Polly supports phonetic pronunciation, which you can use to achieve a pronunciation that is close to the correct pronunciation in the foreign language.

You can use the Speech Synthesis Markup Language (SSML) tag to suggest a phonetic pronunciation in the ph attribute. Let me show you how you can use SSML tag.

First, login into your AWS console and search for Amazon Polly in the search bar at the top. Select Amazon Polly and then choose Try Polly button.

In the Amazon Polly console, select Australian English from the language dropdown and enter following text in the Input text box and then click on Listen to test the pronunciation.

I’m wishing you all a very Happy Mātariki.

Sample speech without applying phonetic pronunciation:

If you hear the sample speech above, you can notice that the pronunciation of Mātariki – a word which is not part of Australian English – isn’t quite spot-on. Now, let’s look at how in such scenarios we can use phonetic pronunciation using SSML tag to customize the speech produced by Amazon Polly.

To use SSML tags, turn ON the SSML option in Amazon Polly console. Then copy and paste following SSML script containing phonetic pronunciation for Mātariki specified inside the ph attribute of the tag.

I’m wishing you all a very Happy Mātariki.

With the tag, Amazon Polly uses the pronunciation specified by the ph attribute instead of the standard pronunciation associated by default with the language used by the selected voice.

Sample speech after applying phonetic pronunciation:

If you hear the sample sound, you’ll notice that we opted for a different pronunciation for some of vowels (e.g., ā) to make Amazon Polly synthesize the sounds that are closer to the correct pronunciation. Now you might have a question, how do I generate the phonetic transcription “mA:.tA:.ri.ki” for the word Mātariki?

You can create phonetic transcriptions by referring to the Phoneme and Viseme tables for the supported languages. In the example above we have used the phonemes for Australian English.

Amazon Polly offers support in two phonetic alphabets: IPA and X-Sampa. Benefit of X-Sampa is that they are standard ASCII characters, so it is easier to type the phonetic transcription with a normal keyboard. You can use either of IPA or X-Sampa to generate your transcriptions, but make sure to stay consistent with your choice, especially when you use a lexicon file which we’ll cover in the next section.

Each phoneme in the phoneme table represents a speech sound. The bolded letters in the “Example” column of the Phoneme/Viseme table in the Australian English page linked above represent the part of the word the “Phoneme” corresponds to. For example, the phoneme /j/ represents the sound that an Australian English speaker makes when pronouncing the letter “y” in “yes.”

Customize pronunciation using lexicons

Phoneme tags are suitable for one-off situations to customize isolated cases, but these are not scalable. If you process huge volume of text, managed by different editors and reviewers, we recommend using lexicons. Using lexicons, you can achieve consistency in adding custom pronunciations and simultaneously reduce manual effort of inserting phoneme tags into the script.

A good practice is that after you test the custom pronunciation on the Amazon Polly console using the tag, you create a library of customized pronunciations using lexicons. Once lexicons file is uploaded, Amazon Polly will automatically apply phonetic pronunciations specified in the lexicons file and eliminate the need to manually provide a tag.

Create a lexicon file

A lexicon file contains the mapping between words and their phonetic pronunciations. Pronunciation Lexicon Specification (PLS) is a W3C recommendation for specifying interoperable pronunciation information. The following is an example PLS document:

Matariki Mātariki mA:.tA:.ri.ki NZ New Zealand

Make sure that you use correct value for the xml:lang field. Use en-AU if you’re uploading the lexicon file to use with the Amazon Polly Australian English voice. For a complete list of supported languages, refer to Languages Supported by Amazon Polly.

To specify a custom pronunciation, you need to add a element which is a container for a lexical entry with one or more element and one or more pronunciation information provided inside element.

The element contains the text describing the orthography of the element. You can use a element to specify the word whose pronunciation you want to customize. You can add multiple elements to specify all word variations, for example with or without macrons. The element is case-sensitive, and during speech synthesis Amazon Polly string matches the words inside your script that you’re converting to speech. If a match is found, it uses the element, which describes how the is pronounced to generate phonetic transcription.

You can also use for commonly used abbreviations. In the preceding example of a lexicon file, NZ is used as an alias for New Zealand. This means that whenever Amazon Polly comes across “NZ” (with matching case) in the body of the text, it’ll read those two letters as “New Zealand”.

For more information on lexicon file format, see Pronunciation Lexicon Specification (PLS) Version 1.0 on the W3C website.

You can save a lexicon file with as a .pls or .xml file before uploading it to Amazon Polly.

Upload and apply the lexicon file

Upload your lexicon file to Amazon Polly using the following instructions:

  1. On the Amazon Polly console, choose Lexicons in the navigation pane.
  2. Choose Upload lexicon.
  3. Enter a name for the lexicon and then choose a lexicon file.
  4. Choose the file to upload.
  5. Choose Upload lexicon.

If a lexicon by the same name (whether a .pls or .xml file) already exists, uploading the lexicon overwrites the existing lexicon.

Now you can apply the lexicon to customize pronunciation.

  1. Choose Text-to-Speech in the navigation pane.
  2. Expand Additional settings.
  3. Turn on Customize pronunciation.
  4. Choose the lexicon on the drop-down menu.

You can also choose Upload lexicon to upload a new lexicon file (or a new version).

It’s a good practice to version control the lexicon file in a source code repository. Keeping the custom pronunciations in a lexicon file ensures that you can consistently refer to phonetic pronunciations for certain words across the organization. Also, keep in mind the pronunciation lexicon limits mentioned on Quotas in Amazon Polly page.

Test the pronunciation after applying the lexicon

Let’s perform quick test using “Wishing all my listeners in NZ, a very Happy Mātariki” as the input text.

We can compare the audio files before and after applying the lexicon.

Before applying the lexicon:

After applying the lexicon:

Conclusion

In this post, we discussed how you can customize pronunciations of commonly used acronyms or words not found in the selected language in Amazon Polly. You can use SSML tag which is great for inserting one-off customizations or testing purposes. We recommend using Lexicon to create a consistent set of pronunciations for frequently used words across your organization. This enables your content writers to spend time on writing instead of the tedious task of adding phonetic pronunciations in the script repetitively. You can try this in your AWS account on the Amazon Polly console.

Summary of resources

About the Authors

Ratan Kumar is a Solutions Architect based out of Auckland, New Zealand. He works with large enterprise customers helping them design and build secure, cost-effective, and reliable internet scale applications using the AWS cloud. He is passionate about technology and likes sharing knowledge through blog posts and twitch sessions.

Maciek Tegi is a Principal Audio Designer and a Product Manager for Polly Brand Voices. He has worked in professional capacity in the tech industry, movies, commercials and game localization. In 2013, he was the first audio engineer hired to the Alexa Text-To- Speech team. Maciek was involved in releasing 12 Alexa TTS voices across different countries, over 20 Polly voices, and 4 Alexa celebrity voices. Maciek is a triathlete, and an avid acoustic guitar player.



Source

Continue Reading

Amazon

AWS Week in Review – May 16, 2022

This post is part of our Week in Review series. Check back each week for a quick roundup of interesting news and announcements from AWS! I had been on the road for the last five weeks and attended many of the AWS Summits in Europe. It was great to talk to so many of you…

Published

on

By

This post is part of our Week in Review series. Check back each week for a quick roundup of interesting news and announcements from AWS!

I had been on the road for the last five weeks and attended many of the AWS Summits in Europe. It was great to talk to so many of you in person. The Serverless Developer Advocates are going around many of the AWS Summits with the Serverlesspresso booth. If you attend an event that has the booth, say “Hi ” to my colleagues, and have a coffee while asking all your serverless questions. You can find all the upcoming AWS Summits in the events section at the end of this post.

Last week’s launches
Here are some launches that got my attention during the previous week.

AWS Step Functions announced a new console experience to debug your state machine executions – Now you can opt-in to the new console experience of Step Functions, which makes it easier to analyze, debug, and optimize Standard Workflows. The new page allows you to inspect executions using three different views: graph, table, and event view, and add many new features to enhance the navigation and analysis of the executions. To learn about all the features and how to use them, read Ben’s blog post.

Example on how the Graph View looks

Example on how the Graph View looks

AWS Lambda now supports Node.js 16.x runtime – Now you can start using the Node.js 16 runtime when you create a new function or update your existing functions to use it. You can also use the new container image base that supports this runtime. To learn more about this launch, check Dan’s blog post.

AWS Amplify announces its Android library designed for Kotlin – The Amplify Android library has been rewritten for Kotlin, and now it is available in preview. This new library provides better debugging capacities and visibility into underlying state management. And it is also using the new AWS SDK for Kotlin that was released last year in preview. Read the What’s New post for more information.

Three new APIs for batch data retrieval in AWS IoT SiteWise – With this new launch AWS IoT SiteWise now supports batch data retrieval from multiple asset properties. The new APIs allow you to retrieve current values, historical values, and aggregated values. Read the What’s New post to learn how you can start using the new APIs.

AWS Secrets Manager now publishes secret usage metrics to Amazon CloudWatch – This launch is very useful to see the number of secrets in your account and set alarms for any unexpected increase or decrease in the number of secrets. Read the documentation on Monitoring Secrets Manager with Amazon CloudWatch for more information.

For a full list of AWS announcements, be sure to keep an eye on the What’s New at AWS page.

Other AWS News
Some other launches and news that you may have missed:

IBM signed a deal with AWS to offer its software portfolio as a service on AWS. This allows customers using AWS to access IBM software for automation, data and artificial intelligence, and security that is built on Red Hat OpenShift Service on AWS.

Podcast Charlas Técnicas de AWS – If you understand Spanish, this podcast is for you. Podcast Charlas Técnicas is one of the official AWS podcasts in Spanish. This week’s episode introduces you to Amazon DynamoDB and shares stories on how different customers use this database service. You can listen to all the episodes directly from your favorite podcast app or the podcast web page.

AWS Open Source News and Updates – Ricardo Sueiras, my colleague from the AWS Developer Relation team, runs this newsletter. It brings you all the latest open-source projects, posts, and more. Read edition #112 here.

Upcoming AWS Events
It’s AWS Summits season and here are some virtual and in-person events that might be close to you:

You can register for re:MARS to get fresh ideas on topics such as machine learning, automation, robotics, and space. The conference will be in person in Las Vegas, June 21–24.

That’s all for this week. Check back next Monday for another Week in Review!

— Marcia



Source

Continue Reading

Amazon

Personalize your machine translation results by using fuzzy matching with Amazon Translate

A person’s vernacular is part of the characteristics that make them unique. There are often countless different ways to express one specific idea. When a firm communicates with their customers, it’s critical that the message is delivered in a way that best represents the information they’re trying to convey. This becomes even more important when…

Published

on

By

A person’s vernacular is part of the characteristics that make them unique. There are often countless different ways to express one specific idea. When a firm communicates with their customers, it’s critical that the message is delivered in a way that best represents the information they’re trying to convey. This becomes even more important when it comes to professional language translation. Customers of translation systems and services expect accurate and highly customized outputs. To achieve this, they often reuse previous translation outputs—called translation memory (TM)—and compare them to new input text. In computer-assisted translation, this technique is known as fuzzy matching. The primary function of fuzzy matching is to assist the translator by speeding up the translation process. When an exact match can’t be found in the TM database for the text being translated, translation management systems (TMSs) often have the option to search for a match that is less than exact. Potential matches are provided to the translator as additional input for final translation. Translators who enhance their workflow with machine translation capabilities such as Amazon Translate often expect fuzzy matching data to be used as part of the automated translation solution.

In this post, you learn how to customize output from Amazon Translate according to translation memory fuzzy match quality scores.

Translation Quality Match

The XML Localization Interchange File Format (XLIFF) standard is often used as a data exchange format between TMSs and Amazon Translate. XLIFF files produced by TMSs include source and target text data along with match quality scores based on the available TM. These scores—usually expressed as a percentage—indicate how close the translation memory is to the text being translated.

Some customers with very strict requirements only want machine translation to be used when match quality scores are below a certain threshold. Beyond this threshold, they expect their own translation memory to take precedence. Translators often need to apply these preferences manually either within their TMS or by altering the text data. This flow is illustrated in the following diagram. The machine translation system processes the translation data—text and fuzzy match scores— which is then reviewed and manually edited by translators, based on their desired quality thresholds. Applying thresholds as part of the machine translation step allows you to remove these manual steps, which improves efficiency and optimizes cost.

Machine Translation Review Flow

Figure 1: Machine Translation Review Flow

The solution presented in this post allows you to enforce rules based on match quality score thresholds to drive whether a given input text should be machine translated by Amazon Translate or not. When not machine translated, the resulting text is left to the discretion of the translators reviewing the final output.

Solution Architecture

The solution architecture illustrated in Figure 2 leverages the following services:

  • Amazon Simple Storage Service – Amazon S3 buckets contain the following content:
    • Fuzzy match threshold configuration files
    • Source text to be translated
    • Amazon Translate input and output data locations
  • AWS Systems Manager – We use Parameter Store parameters to store match quality threshold configuration values
  • AWS Lambda – We use two Lambda functions:
    • One function preprocesses the quality match threshold configuration files and persists the data into Parameter Store
    • One function automatically creates the asynchronous translation jobs
  • Amazon Simple Queue Service – An Amazon SQS queue triggers the translation flow as a result of new files coming into the source bucket

Solution Architecture Diagram

Figure 2: Solution Architecture

You first set up quality thresholds for your translation jobs by editing a configuration file and uploading it into the fuzzy match threshold configuration S3 bucket. The following is a sample configuration in CSV format. We chose CSV for simplicity, although you can use any format. Each line represents a threshold to be applied to either a specific translation job or as a default value to any job.

default, 75 SourceMT-Test, 80

The specifications of the configuration file are as follows:

  • Column 1 should be populated with the name of the XLIFF file—without extension—provided to the Amazon Translate job as input data.
  • Column 2 should be populated with the quality match percentage threshold. For any score below this value, machine translation is used.
  • For all XLIFF files whose name doesn’t match any name listed in the configuration file, the default threshold is used—the line with the keyword default set in Column 1.

Auto-generated parameter in Systems Manager Parameter Store

Figure 3: Auto-generated parameter in Systems Manager Parameter Store

When a new file is uploaded, Amazon S3 triggers the Lambda function in charge of processing the parameters. This function reads and stores the threshold parameters into Parameter Store for future usage. Using Parameter Store avoids performing redundant Amazon S3 GET requests each time a new translation job is initiated. The sample configuration file produces the parameter tags shown in the following screenshot.

The job initialization Lambda function uses these parameters to preprocess the data prior to invoking Amazon Translate. We use an English-to-Spanish translation XLIFF input file, as shown in the following code. It contains the initial text to be translated, broken down into what is referred to as segments, represented in the source tags.

Consent Form CONSENT FORM FORMULARIO DE CONSENTIMIENTO Screening Visit: Screening Visit Selección

The source text has been pre-matched with the translation memory beforehand. The data contains potential translation alternatives—represented as tags—alongside a match quality attribute, expressed as a percentage. The business rule is as follows:

  • Segments received with alternative translations and a match quality below the threshold are untouched or empty. This signals to Amazon Translate that they must be translated.
  • Segments received with alternative translations with a match quality above the threshold are pre-populated with the suggested target text. Amazon Translate skips those segments.

Let’s assume the quality match threshold configured for this job is 80%. The first segment with 99% match quality isn’t machine translated, whereas the second segment is, because its match quality is below the defined threshold. In this configuration, Amazon Translate produces the following output:

Consent Form FORMULARIO DE CONSENTIMIENTO CONSENT FORM FORMULARIO DE CONSENTIMIENTO Screening Visit: Visita de selección Screening Visit Selección

In the second segment, Amazon Translate overwrites the target text initially suggested (Selección) with a higher quality translation: Visita de selección.

One possible extension to this use case could be to reuse the translated output and create our own translation memory. Amazon Translate supports customization of machine translation using translation memory thanks to the parallel data feature. Text segments previously machine translated due to their initial low-quality score could then be reused in new translation projects.

In the following sections, we walk you through the process of deploying and testing this solution. You use AWS CloudFormation scripts and data samples to launch an asynchronous translation job personalized with a configurable quality match threshold.

Prerequisites

For this walkthrough, you must have an AWS account. If you don’t have an account yet, you can create and activate one.

Launch AWS CloudFormation stack

  1. Choose Launch Stack:
  2. For Stack name, enter a name.
  3. For ConfigBucketName, enter the S3 bucket containing the threshold configuration files.
  4. For ParameterStoreRoot, enter the root path of the parameters created by the parameters processing Lambda function.
  5. For QueueName, enter the SQS queue that you create to post new file notifications from the source bucket to the job initialization Lambda function. This is the function that reads the configuration file.
  6. For SourceBucketName, enter the S3 bucket containing the XLIFF files to be translated. If you prefer to use a preexisting bucket, you need to change the value of the CreateSourceBucket parameter to No.
  7. For WorkingBucketName, enter the S3 bucket Amazon Translate uses for input and output data.
  8. Choose Next.

    Figure 4: CloudFormation stack details

  9. Optionally on the Stack Options page, add key names and values for the tags you may want to assign to the resources about to be created.
  10. Choose Next.
  11. On the Review page, select I acknowledge that this template might cause AWS CloudFormation to create IAM resources.
  12. Review the other settings, then choose Create stack.

AWS CloudFormation takes several minutes to create the resources on your behalf. You can watch the progress on the Events tab on the AWS CloudFormation console. When the stack has been created, you can see a CREATE_COMPLETE message in the Status column on the Overview tab.

Test the solution

Let’s go through a simple example.

  1. Download the following sample data.
  2. Unzip the content.

There should be two files: an .xlf file in XLIFF format, and a threshold configuration file with .cfg as the extension. The following is an excerpt of the XLIFF file.

English to French sample file extract

Figure 5: English to French sample file extract

  1. On the Amazon S3 console, upload the quality threshold configuration file into the configuration bucket you specified earlier.

The value set for test_En_to_Fr is 75%. You should be able to see the parameters on the Systems Manager console in the Parameter Store section.

  1. Still on the Amazon S3 console, upload the .xlf file into the S3 bucket you configured as source. Make sure the file is under a folder named translate (for example, /translate/test_En_to_Fr.xlf).

This starts the translation flow.

  1. Open the Amazon Translate console.

A new job should appear with a status of In Progress.

Auto-generated parameter in Systems Manager Parameter Store

Figure 6: In progress translation jobs on Amazon Translate console

  1. Once the job is complete, click into the job’s link and consult the output. All segments should have been translated.

All segments should have been translated. In the translated XLIFF file, look for segments with additional attributes named lscustom:match-quality, as shown in the following screenshot. These custom attributes identify segments where suggested translation was retained based on score.

Custom attributes identifying segments where suggested translation was retained based on score

Figure 7: Custom attributes identifying segments where suggested translation was retained based on score

These were derived from the translation memory according to the quality threshold. All other segments were machine translated.

You have now deployed and tested an automated asynchronous translation job assistant that enforces configurable translation memory match quality thresholds. Great job!

Cleanup

If you deployed the solution into your account, don’t forget to delete the CloudFormation stack to avoid any unexpected cost. You need to empty the S3 buckets manually beforehand.

Conclusion

In this post, you learned how to customize your Amazon Translate translation jobs based on standard XLIFF fuzzy matching quality metrics. With this solution, you can greatly reduce the manual labor involved in reviewing machine translated text while also optimizing your usage of Amazon Translate. You can also extend the solution with data ingestion automation and workflow orchestration capabilities, as described in Speed Up Translation Jobs with a Fully Automated Translation System Assistant.

About the Authors

Narcisse Zekpa is a Solutions Architect based in Boston. He helps customers in the Northeast U.S. accelerate their adoption of the AWS Cloud, by providing architectural guidelines, design innovative, and scalable solutions. When Narcisse is not building, he enjoys spending time with his family, traveling, cooking, and playing basketball.

Dimitri Restaino is a Solutions Architect at AWS, based out of Brooklyn, New York. He works primarily with Healthcare and Financial Services companies in the North East, helping to design innovative and creative solutions to best serve their customers. Coming from a software development background, he is excited by the new possibilities that serverless technology can bring to the world. Outside of work, he loves to hike and explore the NYC food scene.



Source

Continue Reading

Trending

Copyright © 2021 Today's Digital.