aws_ai 0.0.3

aws_ai #

Flutter package to wrap Amazon artificial intelligence (AI) services, which provide flutter community developers with the ability to add intelligence to their applications through an API call to pre-trained services rather than developing and training their own models. Amazon AI services are :

  • Amazon Rekognition : built on technology used by Amazon Prime Photos to analyze billions of images daily, is a service that makes it easy to add image analysis to your applications. With Rekognition, you can detect objects, scenes, and faces in images, as well as search and compare faces between images.
  • Amazon Translate : a neural machine translation service that delivers fast, high-quality, and affordable language translation.
  • Amazon Polly (still not implemented): a service that turns text into lifelike speech. Polly lets you create applications that speak in over two dozen languages with a wide variety of natural sounding male and female voices to enable you to build entirely new categories of speech-enabled products.
  • Amazon Lex (still not implemented) : uses the same technology as Amazon Alexa to provide advanced deep learning functionalities of automatic speech recognition (ASR) and natural language understanding (NLU) to enable you to build applications with conversational interfaces, commonly called chatbots.

Translate #

Sample Code

import 'package:aws_ai/src/TranslateHandler.dart';

TranslateHandler translate = new TranslateHandler(accessKey, secretKey, region); 
String output = await translate.translate(Languages.auto, Languages.fr, "اسمي محمد");

Output will be a String contains JSON object with below format

{
   "SourceLanguageCode": "string",
   "TargetLanguageCode": "string",
   "TranslatedText": "string"
}

"TranslatedText" will be in UTF8 format.

Rekognition #

  • Face comparison (compareFaces) #

    Sample Code
import 'package:aws_ai/src/RekognitionHandler.dart';

File sourceImagefile, targetImagefile; //load source and target images in those File objects
String accessKey, secretKey, region ; //load your aws account info in those variables

RekognitionHandler rekognition = new RekognitionHandler(accessKey, secretKey, region); 
Future<String> labelsArray = rekognition.compareFaces(sourceImagefile, targetImagefile);

Output will be a String contains JSON object with below format

{
 "FaceMatches": [
    {
       "Face": {
          "BoundingBox": {
             "Height": "number",
             "Left": "number",
             "Top": "number",
             "Width": "number"
          },
          "Confidence": "number",
          "Landmarks": [
             {
                "Type": "string",
                "X": "number",
                "Y": "number"
             }
          ],
          "Pose": {
             "Pitch": "number",
             "Roll": "number",
             "Yaw": "number"
          },
          "Quality": {
             "Brightness": "number",
             "Sharpness": "number"
          }
       },
       "Similarity": "number"
    }
 ],
 "SourceImageFace": {
    "BoundingBox": {
       "Height": "number",
       "Left": "number",
       "Top": "number",
       "Width": "number"
    },
    "Confidence": "number"
 },
 "SourceImageOrientationCorrection": "string",
 "TargetImageOrientationCorrection": "string",
 "UnmatchedFaces": [
    {
       "BoundingBox": {
          "Height": "number",
          "Left": "number",
          "Top": "number",
          "Width": "number"
       },
       "Confidence": "number",
       "Landmarks": [
          {
             "Type": "string",
             "X": "number",
             "Y": "number"
          }
       ],
       "Pose": {
          "Pitch": "number",
          "Roll": "number",
          "Yaw": "number"
       },
       "Quality": {
          "Brightness": "number",
          "Sharpness": "number"
       }
    }
 ]
}
  • Facial analysis (detectFaces) #

    Sample Code
import 'package:aws_ai/src/RekognitionHandler.dart';

File sourceImagefile; //load source image in this File object
String accessKey, secretKey, region ; //load your aws account info in those variables

RekognitionHandler rekognition = new RekognitionHandler(accessKey, secretKey, region);
Future<String> labelsArray = rekognition.detectFaces(sourceImagefile);

Output will be a String contains JSON object with below format

{
 "FaceDetails": [
    {
       "AgeRange": {
          "High": "number",
          "Low": "number"
       },
       "Beard": {
          "Confidence": "number",
          "Value": "boolean"
       },
       "BoundingBox": {
          "Height": "number",
          "Left": "number",
          "Top": "number",
          "Width": "number"
       },
       "Confidence": "number",
       "Emotions": [
          {
             "Confidence": "number",
             "Type": "string"
          }
       ],
       "Eyeglasses": {
          "Confidence": "number",
          "Value": "boolean"
       },
       "EyesOpen": {
          "Confidence": "number",
          "Value": "boolean"
       },
       "Gender": {
          "Confidence": "number",
          "Value": "string"
       },
       "Landmarks": [
          {
             "Type": "string",
             "X": "number",
             "Y": "number"
          }
       ],
       "MouthOpen": {
          "Confidence": "number",
          "Value": "boolean"
       },
       "Mustache": {
          "Confidence": "number",
          "Value": "boolean"
       },
       "Pose": {
          "Pitch": "number",
          "Roll": "number",
          "Yaw": "number"
       },
       "Quality": {
          "Brightness": "number",
          "Sharpness": "number"
       },
       "Smile": {
          "Confidence": "number",
          "Value": "boolean"
       },
       "Sunglasses": {
          "Confidence": "number",
          "Value": "boolean"
       }
    }
 ],
 "OrientationCorrection": "string"
}
  • Unsafe image detection (detectModerationLabels) #

    Sample Code
import 'package:aws_ai/src/RekognitionHandler.dart';

File sourceImagefile; //load source image in this File object
String accessKey, secretKey, region ; //load your aws account info in those variables

RekognitionHandler rekognition = new RekognitionHandler(accessKey, secretKey, region);
Future<String> labelsArray = rekognition.detectModerationLabels(sourceImagefile);

Output will be a String contains JSON object with below format

{
 "ModerationLabels": [
    {
       "Confidence": "number",
       "Name": "string",
       "ParentName": "string"
    }
 ]
}
  • Celebrity recognition (recognizeCelebrities) #

    Sample Code
import 'package:aws_ai/src/RekognitionHandler.dart';

File sourceImagefile; //load source image in this File object
String accessKey, secretKey, region ; //load your aws account info in those variables

RekognitionHandler rekognition = new RekognitionHandler(accessKey, secretKey, region);
Future<String> labelsArray = rekognition.recognizeCelebrities(sourceImagefile);

Output will be a String contains JSON object with below format

{
    "CelebrityFaces": [
      {
         "Face": {
            "BoundingBox": {
               "Height": "number",
               "Left": "number",
               "Top": "number",
               "Width": "number"
            },
            "Confidence": "number",
            "Landmarks": [
               {
                  "Type": "string",
                  "X": "number",
                  "Y": "number"
               }
            ],
            "Pose": {
               "Pitch": "number",
               "Roll": "number",
               "Yaw": "number"
            },
            "Quality": {
               "Brightness": "number",
               "Sharpness": "number"
            }
         },
         "Id": "string",
         "MatchConfidence": "number",
         "Name": "string",
         "Urls": [ "string" ]
      }
    ],
    "OrientationCorrection": "string",
    "UnrecognizedFaces": [
      {
         "BoundingBox": {
            "Height": "number",
            "Left": "number",
            "Top": "number",
            "Width": "number"
         },
         "Confidence": "number",
         "Landmarks": [
            {
               "Type": "string",
               "X": "number",
               "Y": "number"
            }
         ],
         "Pose": {
            "Pitch": "number",
            "Roll": "number",
            "Yaw": "number"
         },
         "Quality": {
            "Brightness": "number",
            "Sharpness": "number"
         }
      }
    ]
    }
  • Text in image (detectText) #

    Sample Code
import 'package:aws_ai/src/RekognitionHandler.dart';

File sourceImagefile; //load source image in this File object
String accessKey, secretKey, region ; //load your aws account info in those variables

RekognitionHandler rekognition = new RekognitionHandler(accessKey, secretKey, region);
Future<String> labelsArray = rekognition.detectText(sourceImagefile);

Output will be a String contains JSON object with below format

{
 "TextDetections": [
    {
       "Confidence": "number",
       "DetectedText": "string",
       "Geometry": {
          "BoundingBox": {
             "Height": "number",
             "Left": "number",
             "Top": "number",
             "Width": "number"
          },
          "Polygon": [
             {
                "X": "number",
                "Y": "number"
             }
          ]
       },
       "Id": "number",
       "ParentId": "number",
       "Type": "string"
    }
 ]
}
  • Object and scene detection (detectLabels) #

    Sample Code
import 'package:aws_ai/src/RekognitionHandler.dart';

File sourceImagefile; //load source image in this File object
String accessKey, secretKey, region ; //load your aws account info in those variables

RekognitionHandler rekognition = new RekognitionHandler(accessKey, secretKey, region);
Future<String> labelsArray = rekognition.detectLabels(sourceImagefile);

Output will be a String contains JSON object with below format

{
 "Labels": [
    {
       "Confidence": "number",
       "Name": "string"
    }
 ],
 "OrientationCorrection": "string"
}

[0.0.1] - 16 OCT 2018.

  • Initial Open Source release.
  • Support many AWS Rekognition APIs :
  • compareFaces
  • detectFaces
  • detectModerationLabels
  • recognizeCelebrities
  • detectText
  • detectLabels

[0.0.3] - 18 OCT 2018.

  • Support AWS Translate API

example/example.dart

import 'package:aws_ai/src/RekognitionHandler.dart';
import 'package:aws_ai/src/TranslateHandler.dart';
import 'dart:async';
import 'dart:io';

main() async {

  File sourceImagefile; //load source image in this File object
  String  accessKey = "",
          secretKey = "",
          region    = "" ;

  RekognitionHandler rekognition = new RekognitionHandler(accessKey, secretKey, region);
  String labelsArray = await rekognition.detectLabels(sourceImagefile);
  print(labelsArray);



  TranslateHandler translate = new TranslateHandler(accessKey, secretKey, region);
  String output = await translate.translate(Languages.ar, Languages.en, "اسمي محمد");
  print(output);
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  aws_ai: ^0.0.3

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:aws_ai/aws_ai.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
62
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
77
Learn more about scoring.

We analyzed this package on Aug 19, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19
  • Flutter: 1.7.8+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health issues and suggestions

Document public APIs. (-1 points)

28 out of 28 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Fix lib/src/Signature.dart. (-0.50 points)

Analysis of lib/src/Signature.dart reported 1 hint:

line 4 col 8: Don't import implementation files from another package.

Format lib/aws_ai.dart.

Run flutter format to format lib/aws_ai.dart.

Format lib/src/TranslateHandler.dart.

Run flutter format to format lib/src/TranslateHandler.dart.

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (http).

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
async ^2.0.8 2.3.0
crypto ^2.0.6 2.1.1+1
flutter 0.0.0
http ^0.11.3+17 0.11.3+17 0.12.0+2
intl ^0.15.7 0.15.8
path ^1.6.2 1.6.4
Transitive dependencies
charcode 1.1.2
collection 1.14.11 1.14.12
convert 2.1.1
http_parser 3.1.3
meta 1.1.6 1.1.7
sky_engine 0.0.99
source_span 1.5.5
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test