Skip to content

Model Management ​

Use the SDK to create and manage your models on the OpenGradient Model Hub.

Managing Models ​

To add files to existing or new model repositories, you need to define its name and version. If you use a model repository name that doesn't exist, it will automatically be created. Similarly, if you upload a file to a new version, the version will automatically be added to the repository.

You can use either our Python library or CLI to upload new files.

Using the CLI ​

  1. To create a new model repository, use the following command:
bash
opengradient create-model-repo --repo "my_model" --description "my description"
  1. To add files to a model repository, you need to create a version. In the above create-model call, version 1.00 is automatically initialized for you. Versions can be used to organize different iterations of the same model. To create a new version, use:
bash
opengradient create-version --repo "my_model" --notes "major feature"
  1. To upload your ONNX model file or any associated file to a given model and version, use the following command:
bash
opengradient upload-file path/to/model.onnx --repo "my_model" --version "1.00"
  1. To list the files of a particular version of a model, run the list_files command:
bash
opengradient list-files --repo "my_model" --version "1.00"

Using the Library ​

Using the Python library for model management. To create the ModelHub instance, run the following command:

python
import opengradient as og

hub = og.ModelHub(email="<email>", password="<password>")

TIP

Refer to our Getting Started guide to obtain these credentials

Creating a Model Repo ​

To create a new model, run the following command:

python
hub.create_model(model_name="<model_name>", model_desc="<model_description>")

create_model automatically calls create_version to initialize v1.00 of your new model

Check the API Reference for more details.

Creating a new version ​

python
new_version = hub.create_version(model_name="<model_name>", notes="<notes>")

Check the API Reference for more details.

File Upload ​

To upload a file to a specific model repo and version, use the following command:

python
hub.upload(model_path="<model_path>", model_name="<model_name>", version="<version>")

Check the API Reference for more details.

List Files ​

To see what files are in a model repo and version:

python
hub.list_files(model_name="<model_name>", version="<version>")

Tutorial ​

python
import opengradient as og

# Create the ModelHub instance
hub = og.ModelHub(email="<email>", password="<password>")

model_name = "<model_name>"

# Create a Model
hub.create_model(model_name, model_desc="OpenGradient's dynamic fee model")

# Create a Version for the Model
versionString = hub.create_version(model_name, notes="<notes>")

# Uploading a model
hub.upload(model_path="local_path_to_your_model.onnx", model_name=model_name, version=versionString)

SDK API Reference ​

Please refer to our API Reference for any additional details around the SDK methods.