Yesterday we introduced you to U-SQL Advanced Analytics and showed how Python can be used with U-SQL. Today, we’ll show U-SQL’s built-in support for Cognitive scenarios for images and text.
Currently U-SQL Supports these cognitive scenarios:
- Detecting Objects in Images (Tagging)
- Detecting Emotion in Faces in Images
- Detecting Text in Images (OCR)
- Text Key Phrase Extraction
- Text Sentiment Analysis
Over time, we’ll add more support and enhance the integration in many ways.
Here’s an example of how U-SQL can be used to detect objects in images:
REFERENCE ASSEMBLY ImageCommon; REFERENCE ASSEMBLY FaceSdk; REFERENCE ASSEMBLY ImageEmotion; REFERENCE ASSEMBLY ImageTagging; REFERENCE ASSEMBLY ImageOcr; @imgs = EXTRACT FileName string, ImgData byte[] FROM @"/images/{FileName:*}.jpg" USING new Cognition.Vision.ImageExtractor(); // Extract the number of objects on each image and tag them @objects = PROCESS @imgs PRODUCE FileName, NumObjects int, Tags string READONLY FileName USING new Cognition.Vision.ImageTagger();
In this sample the Cognition.Vision.ImageTagger() processor is used to detect objects and place a text description of them in the Tags column.
Here’s an example of how U-SQL can be used to detect objects in images:
REFERENCE ASSEMBLY [TextCommon]; REFERENCE ASSEMBLY [TextSentiment]; REFERENCE ASSEMBLY [TextKeyPhrase]; @WarAndPeace = EXTRACT No int, Year string, Book string, Chapter string, Text string FROM @"/usqlext/samples/cognition/war_and_peace.csv" USING Extractors.Csv(); @sentiment = PROCESS @WarAndPeace PRODUCE No, Year, Book, Chapter, Text, Sentiment string, Conf double READONLY No, Year, Book, Chapter, Text USING new Cognition.Text.SentimentAnalyzer(true);
In this sample the Cognition.Text.SentimentAnalyzer() processor is used to detect objects and place a text description of them in the Sentiment column.
To learn more about our support for U-SQL Advanced Analytics and how to enable it in your Data Lake Analytics Accounts, see our Getting Started guide.