Description of image

How to Use the Gradient Model Repository to Manage Models Beta

Workflows automate machine learning tasks, combining GPU instances with an expressive syntax to generate production-ready machine learning pipelines with a few lines of code.


The Gradient Model repository is a hub for importing, managing, and deploying ML models.

You can create Gradient Models in two ways:

  • Generating models from your workloads such as Workflows or Notebooks
  • Importing into Gradient by uploading them directly from the Paperspace UI or CLI

Paperspace supports creating the following model formats:

  • TensorFlow
  • ONNX (Open Neural Network Exchange)
  • Custom

Gradient has a repository of models per project. The model repository holds reference to the model artifacts (files generated during training) as well as optional summary metrics associated with the model’s performance such as accuracy and loss.

Models are available within projects

If you are creating a Notebook for the first time, the Models section asks you to either UPLOAD MODEL or view our documentation.

No models are created yet within projects

Create a Model

You can use the Paperspace UI or CLI to create a model in Gradient either by running a workload that generates a model or by uploading a model.

Run a Workload to Generate a Model

You can do this using a Gradient Action or the SDK. This places your model in your Project’s model repository. For more information, see the Model CLI/SDK docs.

Upload a Model

You can upload models in the model repository via the Paperspace UI or CLI.

To upload a Model via the Paperspace UI, first navigate to the Models page.

From there, click Upload a Model +.

Upload

This opens up a window to Upload a Model, where you can select a model file or directory from your local machine. You also choose the model Type, and provide a Name, custom Summary, and any Additional Notes as metadata.

Upload model

Then click Upload Model. This uploads and registers the model in Gradient.

You can upload a model via the CLI with the gradient models upload subcommand:

gradient models upload downloads/squeezenet1.1.onnx --name squeezenet --modelType ONNX

Now that you have a model, read on to learn how you can use it to create a Deployment.

View Models

You can view your team’s models in the model repository via the Paperspace UI or CLI.

In the Paperspace UI, click the Models tab to see your list of trained models:

Models are available within projects Single model card in your models list

The Paperspace UI view shows your model ID, when the model was created, the S3 bucket location of your model, your metrics summary data, the model type, and whether it is currently deployed on Paperspace.

You can click Deploy Model to create a deployment with your model. You can also click Open Detail to view or download the model’s performance metrics, a list of all of the checkpoint files (artifacts) generated by the final model.

Expanded Model Details showing model and checkpoint files

Alternately, you can view your models via the CLI by running gradient models list. Currently, the CLI only let’s you view each model in the project space’s ID and name when this is called.

You can view your models via the CLI by running gradient models list.

$ gradient models list

+------+-----------------+------------+------------+
| Name | ID              | Model Type | Project ID |
+------+-----------------+------------+------------+
| None | moilact08jpaok  | Tensorflow | prcl68pnk  |
| None | mos2uhkg4yvga0p | Tensorflow | prcl68pnk  |
| None | moc7i8v6bsrhzk  | Custom     | prddziv0z  |

You can use the --projectId flag to filter the list by Project ID.

Modifying Your Model

If you want to rename your model, click your model’s name and type your new model name. If you want to delete the model, it depends on whether your interface is a Paperspace UI or CLI.

Paperspace Interface

Click the Models tab to view your list of trained models. From here, you can delete models by clicking the Delete button.

Paperspace CLI

You can delete a model using the CLI with the following command:

gradient models delete --id <your-model-id>

A model is successfully deleted if it no output is generated after running the command.

Add Metadata to Models

Model Type Values Description
"Tensorflow" TensorFlow compatible model outputs
"ONNX" ONNX model outputs
"Custom" Custom model type (for example, a Flask server)

If you do not specify modelType, you can associate custom model metadata with the model by creating a gradient-model-metadata.json file in the modelPath directory. You can store any valid JSON data in this file.