Skip to content

Deploying models

Before following the steps for deploying your own model it is required that you already have an existing project that you want to run your experiments or create a new project following the steps mentioned in the Create project section.

For this tutorial we will go through a simple classification task titled Medical Image Classification: Hello World Deep Learning Tutorial which classifies Xrays as either chest or abdomen. This project is hosted on our platform.

Creating a new model instance

Open the MD.ai tool and select your project by going to the "My Projects" section and clicking on the "Launch" button.

select-model.gif

Once inside, click on the "Models" button and select "New Model". Enter a name for your model and add a description if you want. You can also choose the scope for your model (study, series, or instance) depending how your model processes inputs.

create-model-instance.gif

Creating a model assets zip file

Creating a model instance isn't enough, you need to further create a model version in order to run your models. In order to do that you will first need to create a zip file containing the saved model and the required MD.ai interface code. The following file structure needs to be strictly followed -

model/
  |__ .mdai/
      |__ config.yml            # Contains configuration parameters to be used during bulid
      |__ mdai_deploy.py        # Framework which communicates between the server and model
      |__ requirements.txt      # Lists the libraries needed to run the model
  |__ model_file.pth            # Pretrained model checkpoint file

Create a root folder named model. Inside this folder, store your pretrained model file. Along with this, create a sub folder named .mdai and all the MD.ai interface related build files need to be placed inside this folder. Zip the root folder and your model is then ready to be deployed.

create-zip-file.gif

Creating a model version

Now that your model assets are wrapped in a zip file, you are ready to deploy your model. Go back to your project and under your previously created model instance, click on the "NEW LABEL CLASS" button. This will map the label indices produced by your model to the corresponding labels you have created on our platform. Do this for all target labels that you might have. For eg. in this case we will map the class "Abdomen" to 0 and "Chest" to 1.

create-label-class.gif

Click on the "NEW MODEL VERSION" button and perform the following steps -

  • Upload Model - Upload the model zip file that you created before.
  • Set Model Args - Enter the values of any arguments that your model might take.
  • Set Runtime Config - Select the runtine configuration for your model such as whether you want the model to run on a CPU or a GPU (and which type of GPU)
  • Build Model - Press on "START BUILD" and you model will be prepared for deployment.

create-model-version.gif

The "Build status" will go from initally "Queued" to "Working" to finally "Succeeded", when the model has been succesfully deployed on the cloud.

Build status stuck in Working

It might take a while for the model to build depending on the size of your model file, so it's completely normal if the "Build Status" stays in the mode "Working" for some time.