ADRs/0012 - OmniHub-Zoo Download Implementations.md
Discussion
Proposed by: Adam Gibson (1st Jan 2022)
Following on from work in downloading models We need to be able to interop in different ecosystems. This ADR will address the specs for implementing interop with the following ecosystems:
This proposal will be broken up in to separate sections detailing the work and implementation needed to implement the loading of models from each of these ecosystems.
Each section will cover how to implement the download and loading of model download workflow described in downloading models
We will also cover how we will handle staging of models for each framework.
Onnx is pretty straightforward as a github repo download. These models do not have any special structure beyond the zip file. Our downloader will focus on the already uncompressed models for ease of simplicity.
Tensorflow will use the tf hub web service. Our access will be focused on using the uncompressed pb models + handling other conversion code for freezing models to be reused.
For our purposes a staged model will be a frozen model that can be directly imported.
Pytorch will need to be converted to onnx. Pytorch serving uses the model archive tool for handling model storage.
Unfortunately, this requires a bit of to integrate with. Pytorch serve archives can vary in format. We will typically want to extract the model from it to manipulate it.
Separately, pytorch has various model zoos both official and community provided:
At the end, we will want to convert the model to onnx. This will be considered a staged model that is consumable by the framework.
Huggingface spaces uses git repositories to store models. URLs are accessible using the huggingface hub SDK
Huggingface hub supports 3 frameworks: pytorch, tensorflow, JAX
Our initial support will only focus on pytorch and tensorflow. JAX will come at a later date when we have implemented JAX for the model import framework.
When loading a model, we will need to know which model type we are running so we can convert it to onnx. We will know this by letting a user specify the model type when they go to download it.
For each of tensorflow and pytorch we will be storing models under their respective frameworks reusing the staging techniques from the tensorflow and onnx frameworks.
Huggingface paths should be repositories + the framework_name specifier. We use AutoModel(pytorch) and AutoTFModel(tensorflow) for converting models to onnx and saved_model -> pb respectively.
Keras applications are simple archives that contain .h5 files. We will use the keras applications library to download and cache the models.