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
KStream<String, Object> transformedMessage = imageInputLines.mapValues(value -> { | |
System.out.println("Image path: " + value); | |
imagePath = value; | |
TensorflowObjectRecogniser recogniser = new TensorflowObjectRecogniser(server, port); | |
System.out.println("Image = " + imagePath); | |
InputStream jpegStream; | |
try { | |
jpegStream = new FileInputStream(imagePath); | |
// Prediction of the TensorFlow Image Recognition model: | |
List<Map.Entry<String, Double>> list = recogniser.recognise(jpegStream); | |
String prediction = list.toString(); | |
System.out.println("Prediction: " + prediction); | |
recogniser.close(); | |
jpegStream.close(); | |
return prediction; | |
} catch (Exception e) { | |
e.printStackTrace(); | |
return Collections.emptyList().toString(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment