Giter VIP home page Giter VIP logo

kafka-python-image-classifier's Introduction

Kafka + Python "Image Classifier"

This application demonstrates an integration between Apache Kafka, and a Python based machine-learning image classifier.

Getting Started

First install dependencies:

pip install -r requirements.txt

Configure your connection to Kafka using the client.ini file:

[default]
bootstrap.servers=<bootstrap-host>:<bootstrap-port>
security.protocol=<PLAINTEXT | SSL | SASL_PLAINTEXT | SASL_SSL | etc>
; if using SASL 
sasl.mechanisms=<PLAIN | GSSAPI | SCRAM-SHA-256>
sasl.username=<sasl username>
sasl.password=<sasl password>

[schema_registry]
url=http://<sr-host>:<sr-port>

Load your "source" topic with imagery:

python producer.py client.ini --out <topic-name> --path imagery/

The producer application will scan the directory specified as --path for JPEG files under 1MB in size. Each file will be published to the --out topic as a Kafka event with the image content as base64 encoded string.

NOTE: embedding binary data in Kafka events is only recommended for "smallish" files. Larger files should probably utilize an object store and pass URIs for retrieval by the classifier app.

Run the classifier application:

python kafka_classifier_app.py client.ini --in <source-topic> --out <destination-topic>

The classifier will pull the source event data, decode the images, send them through a machine-learning based image classification model (this demo uses the ResNet50 model embedded with TensorFlow and Keras). The model's predictions will then be added to the event message and republished to the destination Kafka topic.

Cheers! ๐Ÿป

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.