This post is a reference guide to support an event talk or webinar. The content is intended to assist the audience only. Thank you.

Abstract

Microsoft’s Cognitive Services are basically the best thing since sliced bread, especially for anybody working with data. Artificial intelligence just got packaged and made available for the masses to download. In this short talk, I’ll take you on a whirl wind tour of how to use these massively powerful libraries directly in Azure Data Lake with that offspring of T-SQL and C# … U-SQL. How do you get hold of the DLL’s and how can you wire them up for yourself?… Everything will be revealed as well as the chance to see what the machines make of the audience!

Links

Helpful Bits

Why U-SQL?

  • U for unified. Unifying T-SQL and C#.
  • U is the next letter after T. T-SQL > U-SQL.
  • U for U-Boat, because Mike Rys dives into his Data Lake with a U-Boat 🙂

Installing the U-SQL samples and extension files in your Data Lake Storage.

The executed code.

USE [CognitiveServices];

REFERENCE ASSEMBLY ImageCommon;
REFERENCE ASSEMBLY FaceSdk;
REFERENCE ASSEMBLY ImageEmotion;
REFERENCE ASSEMBLY ImageTagging;
REFERENCE ASSEMBLY ImageOcr;

--Extract the number of objects on each image and tag them 
@imgs =
    EXTRACT 
        FileName string, 
        [ImgData] byte[]
    FROM 
        @"/Images/{FileName}.jpg"
    USING 
        new Cognition.Vision.ImageExtractor();

@imgTags =
    PROCESS 
        @imgs 
    PRODUCE 
        [FileName],
        [NumObjects] int,
        [Tags] string
    READONLY 
        [FileName]
    USING 
        new Cognition.Vision.ImageTagger();

OUTPUT @imgTags
TO "/output/ImageTags.csv"
USING Outputters.Csv(quoting : true, outputHeader : true);

 

Tags: