models#

A model is defined by 3 core components:

  1. repository - git repository containing the model code;

  2. files - files containing model parameters or any other model configuration (e.g. number of layers);

  3. runtime - information about what Python functions to call (and how) in order to load a model and make predictions with it.

And since it is common to develop multiple models even for a single ML problem you can define multiple models per project.

We provide ways to upload both a remote code and a local code. Here is an example how to define a single model detecting bounding boxes from a remote repository:

Remote code:

models:
  - name: YOLOR-P6
    repository:
      url: https://github.com/efemarai/yolor
      branch: main
      access_token: ${GIT_KEY}  # environment variable
    files:
      - name: params
        url: results/yolor_p6.pt
        upload: True
    runtime:
      image: pytorch/pytorch:1.9.1-cuda11.1-cudnn8-runtime
      load:
        entrypoint: inference:get_model  # inference.py is in model repository
        inputs:
          - name: params_url
            value: ${model.files.params.url}
        output:
          name: model
      predict:
        entrypoint: inference:predict
        inputs:
          - name: model
            value: ${model.runtime.load.output.model}
          - name: datapoints
            value: ${datapoints}
        output:
          name: predictions
          keys:
            - boxes
            - classes
            - scores

Local code:

In order to upload a local model, simply leave the repository section empty!

models:
  - name: YOLOR-P6
    files:
      - name: params
        url: results/yolor_p6.pt
        upload: True
    runtime:
      image: pytorch/pytorch:1.9.1-cuda11.1-cudnn8-runtime
      load:
        entrypoint: inference:get_model  # inference.py is in model repository
        inputs:
          - name: params_url
            value: ${model.files.params.url}
        output:
          name: model
      predict:
        entrypoint: inference:predict
        inputs:
          - name: model
            value: ${model.runtime.load.output.model}
          - name: datapoints
            value: ${datapoints}
        output:
          name: predictions
          keys:
            - boxes
            - classes
            - scores

Properties

models contains an array where each element defines a model and has the following properties:

  • name: unique name of the model

  • description (optional): free text description of the model

  • repository: git repository containing model code

  • files: files containing model parameters and/or configurations

  • runtime: model runtime information

  • version (optional): string representing the version of the model

Universal model name#

In some instances, it is convenient to specify a global name for all models that have not been explicitly enumerated. This is common if you have a group of models that have been trained for multiple different tasks, yet have the same underlying structure (and inference needs). This can be done by having an inference runtime for a model with the name ${model.name} in the repository. The models can still be uploaded with a human understandable name (through a separate model.yaml file or the SDK), yet during inference, if a matching name is not present, the universal name is defaulted to.