Serving TensorFlow models with Kubernetes

1 article/video left!

log in or sign up to unlock 3 more articles/videos this month and explore our expert resources.

Automatic Summary

Utilizing TensorFlow Models for Image Anonymization: A Workflow Overview

Hello everybody, and welcome to an engaging discussion on serving TensorFlow models, particularly in the case of image anonymization. I am Sarit Pinhas, a senior software engineer at an Israeli start-up, Duda, and global ambassador for Women in Tech, and I will be your guide today as we delve into this exciting topic.

The Problem We aim to Solve

The primary use case we will be exploring today involves the anonymization of images, specifically, protecting the identity of drivers in an input stream of images that are captured from thousands of dashcams per second. The main objective? To blur faces and license plates within these images. To achieve this, we need to identify or detect the faces and license plates within the images - a process that involves classifying the object within an image and determining its position.

After considering a few different technologies, we decided to utilize machine learning, specifically TensorFlow, to carry out these detections.

What is TensorFlow?

TensorFlow is an open-source library that is extensively used for the development and training of machine learning models. It was created by Google in 2015 to facilitate machine learning and offers several advantages some of which include:

  • Ease of building models: Models can be effortlessly built using the APIs the library provides, such as convolution.
  • Deployment flexibility: TensorFlow models can be deployed across a range of platforms - on-premises, in the cloud, in the browser, or even on-device for mobile applications.
  • Wide community support: TensorFlow boasts an extensive community of developers who can assist you in troubleshooting any issues.
  • Scalability: TensorFlow is designed to scale computations across multiple machines, increasing computational speed and efficiency.
  • Debugging: TensorFlow models are relatively easy to debug, which is not the case with some other alternatives.

Using TensorFlow for Image Anonymization

We optimize TensorFlow's functionality for the process of image anonymization using a two-phase approach: The first phase involves building the graph, also known as the training phase. Here, the machine learning model is ‘trained’ to identify license plates and faces in images through continuous computation iterations until the loss - the difference between model's answer and actual input answer - reaches a minimal level.

The second phase, known as the inference phase, involves running computations on the graph, where the trained and saved model is served, and image detections commence.

The Architecture of Serving Saved TensorFlow Models

The architecture of serving the saved TensorFlow models involves a series of steps. Incoming images from dashcams are first processed by an image processor component, which not only augments the data with additional information but also communicates with the TensorFlow processor components via a REST API. The TensorFlow processor gets the request and converts it into a request that the TensorFlow serving component can process.

The trained TensorFlow models, which have been saved to AWS S3, are retrieved by the TensorFlow serving component, allowing it to serve the detection. For fast response times, the model is only retrieved during the initiation phase of the component rather than with each request.

Our machine learning component comprises two containers: the TensorFlow processor and TensorFlow serving. The latter uses TensorFlow APIs to serve the saved model and return its prediction, which the TensorFlow processor then converts to an easily interpretable result, returning it via the REST API response to the image processor.

For performance monitoring, we calculate the full response time of each request, index the information to InfluxDB, and view it using a Grafana dashboard. Alerts are also set up to notify us when performance deteriorates.

Foreseeing Results and Improvements

Due to this innovative technology, all faces and license plates are competently blurred. What's more, the architecture enhances collaboration between the engineering team and the research team. When a new version of the model is created, either team can easily replace the old model since the bucket in which the model is saved on S3 is accessible to both.

Utilizing TensorFlow for image anonymization makes impressive results easily attainable, as evidenced by the final blurred images from our dashcams. If you are interested in delving deeper into TensorFlow or machine learning as a whole, I recommend checking out [TensorFlow's website](https://www.tensorflow.org/), its [GitHub repository](https://github.com/tensorflow/tensorflow), and a [Google IO 2019 talk](https://www.youtube.com/watch?v=JYhYZzQIQ3E) on machine learning basics.

It's been a pleasure to share this information with you all. Feel free to reach out to me on LinkedIn if you have any questions or simply want to continue the conversation. Thank you.


Video Transcription

Read More