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"));
}
Aggregations