Skip to content

Instantly share code, notes, and snippets.

Created October 29, 2019 12:01
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
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);
return prediction;
} catch (Exception e) {
return Collections.emptyList().toString();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment