Facebook
From Botched Human, 5 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 244
  1. REFERENCE ASSEMBLY ImageCommon;
  2. REFERENCE ASSEMBLY FaceSdk;
  3. REFERENCE ASSEMBLY ImageEmotion;
  4. REFERENCE ASSEMBLY ImageTagging;
  5. REFERENCE ASSEMBLY ImageOcr;
  6.  
  7. // Get the image data
  8. @imgs =
  9.     EXTRACT
  10.         FileName string,
  11.         ImgData byte[]
  12.     FROM @"/images/{FileName}.jpg"
  13.     USING new Cognition.Vision.ImageExtractor();
  14.  
  15. //  Extract the number of objects on each image and tag them
  16.  
  17. @tags =
  18.     PROCESS @imgs
  19.     PRODUCE FileName,
  20.             NumObjects int,
  21.             Tags SQL.MAP<string, float?>
  22.     READONLY FileName
  23.     USING new Cognition.Vision.ImageTagger();
  24.  
  25. @tags_serialized =
  26.     SELECT FileName,
  27.            NumObjects,
  28.            String.Join(";", Tags.Select(x => String.Format("{0}:{1}", x.Key, x.Value))) AS TagsString
  29.     FROM @tags;
  30.  
  31. OUTPUT @tags_serialized
  32.     TO "/tags.csv"
  33.     USING Outputters.Csv();
  34.