/mlops-hf-tf-vision-models

MLOps for Vision Models (TensorFlow) from 🤗 Transformers with TensorFlow Extended (TFX)

Primary LanguageJupyter NotebookApache License 2.0Apache-2.0

Python TFX

MLOps for Vision Models (TensorFlow) from 🤗 Transformers with TensorFlow Extended (TFX)

This repository shows how to build Machine Learning pipeline for a vision model (TensorFlow) from 🤗 Transformers using the TensorFlow Ecosystem. In particular, we use TensorFlow Extended(TFX), and there are TensorFlow Data Validation(TFDV), Transform(TFT), Model Analysis(TFMA), and Serving(TF Serving) besides TensorFlow itself internally involved.

NOTE: This is a follow-up projects of "Deploying Vision Models (TensorFlow) from 🤗 Transformers" which shows how to deploy ViT model locally, on kubernetes, and on a fully managed service Vertex AI.

We will show how to build ML pipeline with TFX in a step-by-step manner:

  • Basic ( CI / Basic CD / Basic )

    • as the first step, we show how to build ML pipeline with the most basic components, which are ExampleGen, Trainer, and Pusher. These components are responsible for injecting raw dataset into the ML pipeline, training a TensorFlow model, and deploying a trained model.

  • Intermediate ( CI / Intermediate CD / Intermediate )

    • as the second step, we show how to extend the ML pipeline from the first step by adding more components, which are SchemaGen, StatisticsGen, and Transform. These components are responsible for analyzing the structures of the dataset, analyzing the statistical traits of the features in the dataset, and data pre-processing.

  • Advanced Part 1 ( CI / Advanced Part1 CD / Advanced Part1 )

    • as the third step, we show how to extend the ML pipeline from the second step by adding more components, which are Resolver and Evaluator. These components are responsible for importing existing Artifacts (such as previously trained model) and comparing the performance between two models (one from the Resolver and one from the current pipeline run).

  • Advanced Part 2 ( CI / Advanced Part2 CD / Advanced Part2 )

    • as the fourth step, we show how to extend the ML pipeline from the third step by adding one more additional component, Tuner. This component is responsible for running a set of experiments with different sets of hyperparameters with fewer epochs, and the found best hyperparameter combination will be passed to the Trainer, and Trainer will train the model longer time with that hyperparameter combinations as the starting point.

  • 🤗 Hub Integration

    • in this optional step, we show how to use custom TFX components for 🤗 Hub. In particular, we use HFModelPusher to push currently trained model to 🤗 Model Hub and HFSpacePusher to automatically deploy Gradio application to 🤗 Space Hub.

Acknowledgements

We are thankful to the ML Developer Programs team at Google that provided GCP support.