Created
January 11, 2020 16:30
-
-
Save nkalra0123/2d8a7f6874eaff66a469df4c3b20ca6f to your computer and use it in GitHub Desktop.
Collect the relevant label information in a map
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// After written to GCS, analyze the image. | |
AnnotateImageResponse response = analyzeImage(bucket + "/" + filename); | |
Map<String, Float> imageLabels = | |
response.getLabelAnnotationsList() | |
.stream() | |
.collect( | |
Collectors.toMap( | |
EntityAnnotation::getDescription, | |
EntityAnnotation::getScore, | |
(u, v) -> { | |
throw new IllegalStateException(String.format("Duplicate key %s", u)); | |
}, | |
LinkedHashMap::new)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment