简体   繁体   中英

Trouble accessing AWS Rekognition facial analysis using ``paws`` package

This is not a data analysis issue, so I don't have a data to reproduce.

I installed the paws package from this Github page to extract facial features (ie, smile) via Amazon Rekognition. I am doing it as a part of a study to test performance across Microsoft Azure and Face++. By the way, I replaced "AccessKeyHere" and "SecretKeyHere" with appropriate security IDs.

library(paws)

Sys.setenv(
  AWS_ACCESS_KEY_ID = "AccessKeyHere",
  AWS_SECRET_ACCESS_KEY = "SecretKeyHere",
  AWS_REGION = "us-east-1"
)

ec2 <- paws::ec2()

resp <- ec2$run_instances(
  ImageId = "ami-f973ab84",
  InstanceType = "t2.micro",
  KeyName = "default",
  MinCount = 1,
  MaxCount = 1,
  TagSpecifications = list(
    list(
      ResourceType = "instance",
      Tags = list(
        list(Key = "webserver", Value = "production")
      )
    )
  )
)

Unfortunately, I get this error:

Error: InvalidKeyPair.NotFound: The key pair 'default' does not exist

I tried following through the Setting Up Credentials document in the Github page without success.

The results I want would look something along the lines of this (taken directly from Amazon demo):

{
    "FaceDetails": [
        {
            "BoundingBox": {
                "Width": 0.20394515991210938,
                "Height": 0.4204871356487274,
                "Left": 0.1556132435798645,
                "Top": 0.11629478633403778
            },
            "AgeRange": {
                "Low": 20,
                "High": 38
            },
            "Smile": {
                "Value": true,
                "Confidence": 98.88771057128906
            },
            "Eyeglasses": {
                "Value": true,
                "Confidence": 99.87944030761719
            },
            "Sunglasses": {
                "Value": true,
                "Confidence": 99.51188659667969
            },
            "Gender": {
                "Value": "Female",
                "Confidence": 99.98441314697266
            },
            "Beard": {
                "Value": false,
                "Confidence": 99.99455261230469
            },
            "Mustache": {
                "Value": false,
                "Confidence": 99.99205017089844
            },
            "EyesOpen": {
                "Value": true,
                "Confidence": 100
            },
            "MouthOpen": {
                "Value": true,
                "Confidence": 99.64435577392578
            },
            "Emotions": [
                {
                    "Type": "ANGRY",
                    "Confidence": 0.5140029191970825
                },
                {
                    "Type": "DISGUSTED",
                    "Confidence": 0.36493897438049316
                },
                {
                    "Type": "SURPRISED",
                    "Confidence": 1.5832388401031494
                },
                {
                    "Type": "CALM",
                    "Confidence": 7.553433418273926
                },
                {
                    "Type": "CONFUSED",
                    "Confidence": 2.7683539390563965
                },
                {
                    "Type": "SAD",
                    "Confidence": 0.1280381977558136
                },
                {
                    "Type": "HAPPY",
                    "Confidence": 87.08799743652344
                }
            ],
            "Landmarks": [
                {
                    "Type": "eyeLeft",
                    "X": 0.23317773640155792,
                    "Y": 0.2868470251560211
                },
                {
                    "Type": "eyeRight",
                    "X": 0.3252476453781128,
                    "Y": 0.27732565999031067
                },
                {
                    "Type": "mouthLeft",
                    "X": 0.2494768351316452,
                    "Y": 0.4339924454689026
                },
                {
                    "Type": "mouthRight",
                    "X": 0.32560691237449646,
                    "Y": 0.42571622133255005
                },
                {
                    "Type": "nose",
                    "X": 0.29963040351867676,
                    "Y": 0.3560841381549835
                },
                {
                    "Type": "leftEyeBrowLeft",
                    "X": 0.18990693986415863,
                    "Y": 0.25858017802238464
                },
                {
                    "Type": "leftEyeBrowRight",
                    "X": 0.2559714913368225,
                    "Y": 0.23907452821731567
                },
                {
                    "Type": "leftEyeBrowUp",
                    "X": 0.22477854788303375,
                    "Y": 0.23571543395519257
                },
                {
                    "Type": "rightEyeBrowLeft",
                    "X": 0.3101874887943268,
                    "Y": 0.23408983647823334
                },
                {
                    "Type": "rightEyeBrowRight",
                    "X": 0.3540191650390625,
                    "Y": 0.24142536520957947
                },
                {
                    "Type": "rightEyeBrowUp",
                    "X": 0.3341374397277832,
                    "Y": 0.2246120721101761
                },
                {
                    "Type": "leftEyeLeft",
                    "X": 0.21425437927246094,
                    "Y": 0.28872400522232056
                },
                {
                    "Type": "leftEyeRight",
                    "X": 0.2506107687950134,
                    "Y": 0.28627288341522217
                },
                {
                    "Type": "leftEyeUp",
                    "X": 0.23298975825309753,
                    "Y": 0.2797400951385498
                },
                {
                    "Type": "leftEyeDown",
                    "X": 0.2338254302740097,
                    "Y": 0.29329705238342285
                },
                {
                    "Type": "rightEyeLeft",
                    "X": 0.3053741455078125,
                    "Y": 0.2805119752883911
                },
                {
                    "Type": "rightEyeRight",
                    "X": 0.33686137199401855,
                    "Y": 0.2753002941608429
                },
                {
                    "Type": "rightEyeUp",
                    "X": 0.3239244222640991,
                    "Y": 0.2698554992675781
                },
                {
                    "Type": "rightEyeDown",
                    "X": 0.32346177101135254,
                    "Y": 0.28338298201560974
                },
                {
                    "Type": "noseLeft",
                    "X": 0.27390313148498535,
                    "Y": 0.37751662731170654
                },
                {
                    "Type": "noseRight",
                    "X": 0.3062724471092224,
                    "Y": 0.373584508895874
                },
                {
                    "Type": "mouthUp",
                    "X": 0.29330143332481384,
                    "Y": 0.4100639820098877
                },
                {
                    "Type": "mouthDown",
                    "X": 0.2929871082305908,
                    "Y": 0.4546505808830261
                },
                {
                    "Type": "leftPupil",
                    "X": 0.23317773640155792,
                    "Y": 0.2868470251560211
                },
                {
                    "Type": "rightPupil",
                    "X": 0.3252476453781128,
                    "Y": 0.27732565999031067
                },
                {
                    "Type": "upperJawlineLeft",
                    "X": 0.14384371042251587,
                    "Y": 0.3039131164550781
                },
                {
                    "Type": "midJawlineLeft",
                    "X": 0.1776188313961029,
                    "Y": 0.4594067335128784
                },
                {
                    "Type": "chinBottom",
                    "X": 0.2889330983161926,
                    "Y": 0.5328735709190369
                },
                {
                    "Type": "midJawlineRight",
                    "X": 0.3430669903755188,
                    "Y": 0.441012978553772
                },
                {
                    "Type": "upperJawlineRight",
                    "X": 0.3498701751232147,
                    "Y": 0.28120794892311096
                }
            ],
            "Pose": {
                "Roll": -4.4155192375183105,
                "Yaw": 10.105213165283203,
                "Pitch": 0.32932278513908386
            },
            "Quality": {
                "Brightness": 60.6755256652832,
                "Sharpness": 94.08262634277344
            },
            "Confidence": 99.99998474121094
        }
    ]
}

If I could advance to this stage, it would be fantanstic. But it would be even nicer if the extracted data could look consistent with my Microsoft Azure results:

          anger contempt disgust  fear happiness neutral sadness surprise
emotion       0        0       0     0         0       1       0        0
emotion1      0        0       0     0         0   0.997   0.002        0
emotion2      0    0.001       0     0         0   0.994   0.004    0.001
emotion3      0        0       0     0         0   0.965   0.035        0

The error is with this line:

KeyName = "default",

It is referring to an Amazon EC2 Key Pair that should be attached to the Amazon EC2 instance. However, there is no keypair named default . Therefore, it fails.

To fix it, instead of default you should use the name of a Keypair that has been created. You can see a list of keypairs in the EC2 management console. You could also remove this line (without specifying a KeyName ), but then you would not be able to login to the instance.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM