Skip to content

Instantly share code, notes, and snippets.

@marvinhoxha
Created September 8, 2022 13:05
Show Gist options
  • Save marvinhoxha/d7f50d7f4350b5a13c0bc70d961d70e4 to your computer and use it in GitHub Desktop.
Save marvinhoxha/d7f50d7f4350b5a13c0bc70d961d70e4 to your computer and use it in GitHub Desktop.
def consumer():
consumer = KafkaConsumer('dogtopic')
for message in consumer:
with open("foo.png","wb") as f:
f.write(decodebytes(message.value))
img = tf.keras.utils.load_img(
"foo.png",
target_size=(224,224)
)
input_arr = tf.keras.utils.img_to_array(img)
image = input_arr[None, ...]
if config=="TENSORFLOW":
print("Tensorflow")
result = predict_tfserve(image)
elif config=="SELDON":
print("SELDON")
result = predict_seldon(image)
send_photo_to_slack(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment