0845 643 64 63

Cognitive Services with U-SQL (Reference Guide)

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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);

 

Paul’s Frog Blog

Hi, I'm Paul Andrew and yes I know it's not the best picture! Anyway, a little bit about me; I have many years experience working with SQL Server and Microsoft technologies. I'm the newest member of the Purple Frog Systems team and fairly new to the SQL Server community. This is my blog of all things in my professional world with no specific theme or subject, but it should be pure gold. Ha! Regardless I hope to inspire and help others with my knowledge sharing as I travel through the modern data driven world.
Thanks for visiting.
@mrpaulandrew