Run in Google Colab
|
View source on GitHub
|
This notebook demonstrates how to perform automatic model updates without stopping your Apache Beam pipeline.
You can use side inputs to update your model in real time, even while the Apache Beam pipeline is running. The side input is passed in a ModelHandler configuration object. You can update the model either by leveraging one of Apache Beam's provided patterns, such as the WatchFilePattern, or by configuring a custom side input PCollection that defines the logic for the model update.
The pipeline in this notebook uses a RunInference PTransform with TensorFlow machine learning (ML) models to run inference on images. To update the model, it uses a side input PCollection that emits ModelMetadata.
For more information about side inputs, see the Side inputs section in the Apache Beam Programming Guide.
This example uses WatchFilePattern as a side input. WatchFilePattern is used to watch for file updates that match the file_pattern based on timestamps. It emits the latest ModelMetadata, which is used in the RunInference PTransform to automatically update the ML model without stopping the Apache Beam pipeline.
Before you begin
Install the dependencies required to run this notebook.
To use RunInference with side inputs for automatic model updates, use Apache Beam version 2.46.0 or later.
pip install apache_beam[interactive,gcp]>=2.46.0 tensorflow==2.15.0 tensorflow_hub==0.16.1 keras==2.15.0 Pillow==11.0.0 --quiet
Run in Google Colab
View source on GitHub