Search in sources :

Example 1 with IdentifyLabelsResult

use of com.amplifyframework.predictions.result.IdentifyLabelsResult in project amplify-android by aws-amplify.

the class AWSPredictionsIdentifyLabelsTest method testIdentifyLabels.

/**
 * Assert label detection works.
 * @throws Exception if prediction fails
 */
@Test
public void testIdentifyLabels() throws Exception {
    final Bitmap image = Assets.readAsBitmap("jeff_bezos.jpg");
    // Identify the labels inside given image and assert non-null result.
    IdentifyLabelsResult result = (IdentifyLabelsResult) predictions.identify(LabelType.ALL, image);
    assertNotNull(result);
    // Assert that Jeff's portrait doesn't flag moderation :)
    assertFalse(result.isUnsafeContent());
    // Assert at least one label is detected as "Person"
    assertFalse(Empty.check(result.getLabels()));
    assertTrue(Observable.fromIterable(result.getLabels()).map(Label::getName).toList().blockingGet().contains("Person"));
}
Also used : Bitmap(android.graphics.Bitmap) Label(com.amplifyframework.predictions.models.Label) IdentifyLabelsResult(com.amplifyframework.predictions.result.IdentifyLabelsResult) Test(org.junit.Test)

Aggregations

Bitmap (android.graphics.Bitmap)1 Label (com.amplifyframework.predictions.models.Label)1 IdentifyLabelsResult (com.amplifyframework.predictions.result.IdentifyLabelsResult)1 Test (org.junit.Test)1