# How to Use the Gradient Model Repository to Manage Models (private) 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](#how-to-create-a-model) 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. ![List of uploaded TensorFlow models with their names, creation times, visibility status, and options to upload new models.](https://docs.digitalocean.com/screenshots/paperspace/models-in-console.6f25246cc29eb88406ba83b60e5b81bf72f0c44f95cc13ca3bb671c3a1e2846f.png) If you are creating a Notebook for the first time, the **Models** section asks you to either **UPLOAD MODEL** or view our documentation. ## 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](https://docs.digitalocean.com/products/paperspace/workflows/reference/gradient-actions/index.html.md) or the [SDK](https://docs.digitalocean.com/reference/paperspace/gradient/index.html.md). This places your model in your Project’s model repository. For more information, see the [Model CLI/SDK docs](https://paperspace.github.io/gradient-cli/gradient.cli.html#gradient-models). ### Upload a Model You can upload models in the model repository via the Paperspace UI or CLI. ## Paperspace UI To upload a Model via the Paperspace UI, first navigate to the **Models** page, and then click **Upload a Model**. 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. Then click **Upload Model**. This uploads and registers the model in Gradient. ## CLI 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. ## Paperspace UI In the Paperspace UI, click the **Models** tab to see your list of trained models. ![List of uploaded TensorFlow models with their names, creation times, visibility status, and options to upload new models.](https://docs.digitalocean.com/screenshots/paperspace/models-in-console.6f25246cc29eb88406ba83b60e5b81bf72f0c44f95cc13ca3bb671c3a1e2846f.png) 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. 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. ## CLI You can view your models via the CLI by running `gradient models list`. ```text $ 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: ```bash gradient models delete --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.