Open topic with navigation

# Add a Face to a Database (Using Separate Steps)

This section describes how to create a new (empty) face, then add training images, and then train HPE Media Server, using separate actions. You can also add metadata to the face but this is an optional step. You might want to perform training in this way if you are building a front end application that responds to user input.

Alternatively, you can train HPE Media Server to recognize a face by sending a single action. To do this, see Add a Face to a Database (Using a Single Action).

To add a face to a database (using separate steps)

1. Add a face using the `NewFace` action. Set the following parameters:

   `database` | The name of the database to add the face to. The database must already exist.
   `identifier` | (Optional) A unique identifier for the face (maximum 254 bytes). If you do not set this parameter, HPE Media Server generates an identifier automatically. You can use the person's name as the identifier, but you might have several people with the same name and all identifiers within a database must be unique. Alternatively, allow HPE Media Server to generate an identifier and add the person's name to a metadata field (see step 3, below).

   For example:

       curl http://localhost:14000 -F action=NewFace
                                   -F database=Faces

   HPE Media Server adds the face and returns the identifier.

2. Add one or more training images to the face using the `AddFaceImages` action. Set the following parameters:

   `database` | The name of the database that contains the face.
   `identifier` | The identifier for the face, returned by the `NewFace` action.
   `imagedata` | (Set this or `imagepath`, but not both). The training images to add. Files must be uploaded as multipart/form-data. For more information about sending data to HPE Media Server, see Send Data by Using a POST Method.
   `imagepath` | (Set this or `imagedata`, but not both). The paths of the training images to add. The paths must be absolute or relative to the HPE Media Server executable file.
   `imagelabels` | A comma-separated list of labels. One label is associated with each image. (maximum 254 bytes for each label). The number of labels must match the number of images. If you do not set this parameter, HPE Media Server generates labels automatically.

   For example, to add training images by supplying the image data:

       curl http://localhost:14000 -F action=AddFaceImages
                                   -F database=Faces
                                   -F identifier=6600dc0f9dd72d0cb55589e8f1d28b62
                                   -F imagedata=@face1_smile.jpg,face1_neutral.jpg
                                   -F imagelabels=image1,image2

   Alternatively, to add training images by supplying their paths:

       curl http://localhost:14000 -F action=AddFaceImages
                                   -F database=Faces
                                   -F identifier=6600dc0f9dd72d0cb55589e8f1d28b62
                                   -F imagepath=face1_smile.jpg,face1_neutral.jpg
                                   -F imagelabels=image1,image2

3. (Optional) Add metadata to the face using the `AddFaceMetadata` action. You can add any number of key-value pairs. Set the following parameters:

   `database` | The name of the database that contains the face.
   `identifier` | The identifier for the face, returned by the `NewFace` action.
   `key` | The key to add (maximum 254 bytes).
   `value` | The value to add (maximum 254 bytes).

   For example:

       curl http://localhost:14000 -F action=AddFaceMetadata
                                   -F database=Faces
                                   -F identifier=6600dc0f9dd72d0cb55589e8f1d28b62
                                   -F key=firstname
                                   -F value=John

4. Complete the training for the face using the `BuildFace` action. Set the following parameters:

   `database` | The name of the database that contains the face.
   `identifier` | The identifier for the face, returned by the `NewFace` action.

   For example:

       curl http://localhost:14000 -F action=BuildFace
                                   -F database=Faces
                                   -F identifier=6600dc0f9dd72d0cb55589e8f1d28b62

© 2017 Hewlett Packard Enterprise Development LP | Send documentation feedback to HPE Close Send documentation feedback To open the configured email client on this computer, open an email window. Otherwise, copy the information below to a web mail client, and send this email to AutonomyTPFeedback@hpe.com. We appreciate your feedback! Product: Topic Title: Help Topic: Feedback:

_HP_HTML5_bannerTitle.htm