Media Server 24.1

# Create and Train a Recognizer

To create and train an object class recognizer, follow these steps. For more information about the actions used in this section, refer to the Media Server Reference.

To create and train a recognizer

1. Start by creating a new recognizer. For example:

   `curl http://localhost:14000/action=CreateObjectClassRecognizer -F recognizer=vehicles`

2. (Optional) Choose the type of recognizer that you want to train. For example:

   `curl http://localhost:14000/action=SetObjectClassRecognizerTrainingOption -F key=recognizer_type -F value=generation2`

3. Add your chosen object classes to the recognizer.

   The following example adds a new class named "car" to the "vehicles" recognizer.

   `curl http://localhost:14000/action=CreateObjectClass -F recognizer=vehicles -F identifier=car`

4. Add images to the recognizer that contain example objects for training.

   The following example adds two images to the "vehicles" recognizer, and labels them "car42" and "bike19":

   `curl http://localhost:14000/action=AddObjectClassImages -F recognizer=vehicles -F imagedata=@car42.jpg,bike19.jpg -F imagelabels=car42,bike19`

5. Annotate each training image. An annotation identifies a region of a training image that contains an object, and the class that the object belongs to. Media Server can then use that region of the image to train the recognizer. You can add multiple annotations to the same image, if the image contains multiple objects.

   The following example adds an annotation to the image "car42", associating a region covering the center 25% of the image with the "car" object class. The region is specified by the `Boxes` parameter, which is a comma-separated list of values in the form `(left,top,width,height)`. `Left` specifies the distance from the left side of the image to the left side of the region. `Top` specifies the distance from the top of the image to the top of the region. `Width` and `Height` specify the width and height of the region. The values are in pixels, unless you set `RegionsAsPercentage=true` (in which case specify `Left` and `Width` as a percentage of the image width and `Top` and `Height` as a percentage of the image height).

   `curl http://localhost:14000/action=AddObjectClassAnnotations -F recognizer=vehicles -F imagelabel=car42 -F identifiers=car -F boxes=(25,25,50,50) -F regionsaspercentage=true`

   TIP: To obtain a list of training images that have been added to the recognizer but have not been annotated, use the action `ListUnannotatedObjectClassImages`.

6. Choose the number of training iterations to run.

   `curl http://localhost:14000/action=SetObjectClassRecognizerTrainingOption -F recognizer=vehicles -F key=iterations -F value=2000`

7. (Optional) To set aside images to evaluate the performance of the recognizer and find the optimum number of training iterations, enable snapshots by setting the `snapshot_frequency` training option. If you want to change the proportion of images that are set aside, you can set the `validation_proportion` training option.

   `curl http://localhost:14000/action=SetObjectClassRecognizerTrainingOption -F recognizer=vehicles -F key=snapshot_frequency -F value=500`

8. Train Media Server by building the recognizer. For example:

   `curl http://localhost:14000/action=BuildObjectClassRecognizer -F recognizer=vehicles`

   This action is asynchronous, so Media Server returns a token. You can use the `QueueInfo` action to check the status of the request.

   When the `BuildObjectClassRecognizer` action has finished, you can use the recognizer. If you did not enable snapshots, the training process is complete.

9. If you enabled snapshots, test the performance of the recognizer and select the snapshot to use.

   1. List the snapshots that are available.

      `curl http://localhost:14000/action=ListObjectClassRecognizers`

      The response to this action includes an index number for each snapshot.

   2. Run the action `TestObjectClassRecognizerSnapshot` for each snapshot that you want to evaluate. The action is asynchronous, so Media Server returns a token. You can use the `QueueInfo` action to check the status of your request(s).

      `curl http://localhost:14000/action=TestObjectClassRecognizerSnapshot -F recognizer=vehicles -F snapshotindex=0`

   3. Review the results with the action `GetObjectClassRecognizerSnapshotStatistics`.

      `curl http://localhost:14000/action=GetObjectClassRecognizerSnapshotStatistics -F recognizer=vehicles`

   4. If one of the snapshots provides acceptable performance, select the snapshot by running the action `SelectObjectClassRecognizerSnapshot`.

      `curl http://localhost:14000/action=SelectObjectClassRecognizerSnapshot -F recognizer=vehicles -F snapshotindex=3`

      If none of the snapshots provides acceptable performance, you might need to add additional training data or run more training iterations.

Copyright 2023 Open Text
Version 24.1 | Last updated December 2023

Send documentation feedback

Close

Send documentation feedback

To send feedback using your default email client, open an email window.

Otherwise, send your feedback and the information below to MFI-swpdl.idoldocsfeedback@opentext.com.

We appreciate your feedback!

Product: IDOL Media Server 24.1

Topic Title: Create and Train a Recognizer