MD.ai

Deploy a Model

Package your model, upload it, and build it to run on MD.ai

Deploying your own model takes four steps: create the model, map its outputs to labels, package the code, and build a version. After that, anyone in the project can run it.

Only project admins can create models, from the Models panel in the annotator. The panel isn't available in Crowdsourcing projects, or on deployments without models.

As an example, this page uses the Hello World X-ray classifier, which classifies X-rays as chest or abdomen.

1. Create the model

  1. Open the project and open the Models panel from the Navigation column.
  2. Click New Model.
  3. Enter a name and description, and choose the scope: the unit the model takes as input.
  4. Choose the model settings, and create the model.
ScopeThe model receives
ImageOne image at a time (default)
SeriesA whole series, e.g. a CT or MR volume. Required for 3D models.
ExamA whole exam, with all its series
Create a model

2. Map the model's classes to labels

Your model outputs class indices. Tell MD.ai which label each index means: on the model card, click New Label Class, select the label, and enter its Class Index. Repeat for every class.

In the example, Abdomen is class 0 and Chest is class 1, matching how the model was trained.

Map label classes

Label classes can only be added or removed before the model's first version. Create the labels and map every class first.

3. Package the model

Create a folder named model with your model files and an .mdai folder containing the MD.ai interface files:

model/
├── .mdai/
│   ├── config.yaml       # build settings
│   ├── mdai_deploy.py    # loads the model and runs predictions
│   └── requirements.txt  # Python dependencies
└── model_file.pth        # your weights, and any other files

The root folder must be named model. See Model Interface for what goes in each file. Compress the model folder as .zip or .tar.gz.

Create the zip file

4. Build a version

On the model card, click New Model Version and follow the steps:

StepWhat to do
Upload ModelDrop in your .zip or .tar.gz.
Validate ModelMD.ai checks the package structure and config.yaml, and lists any errors.
Set Runtime ConfigChoose the hardware and inputs. See below.
Set Model ArgsOptional: add arguments, with default values, that users can change when they run the model. Your code reads them from data["args"].
Build ModelClick Start Build.
Create a model version

Runtime config:

SettingOptions
Runtime HardwareCPU or GPU, as set by device_type in config.yaml
GPU TypeThe GPUs available on your deployment, such as NVIDIA T4 or L4
Input File TypeDICOM, or Thumbnail to receive PNG/JPEG renderings
Input Data SourceMemory: files are passed in the request. Disk: files are written to disk and passed as paths, for large inputs.
Batch SizeHow many inputs the model receives at once, 1 to 1024. Fixed if batch_size is set in config.yaml.
Input AnnotationsWhether the model receives existing annotations of its labels. On by default.

CPU and memory are set by MD.ai and shown for reference.

Build status

The build goes from Queued to Working to Success. Large models can take a while in Working. You get an email and an in-app notification when the build finishes, whether it succeeds or fails.

If the build fails, click the version's Details button and View Build Logs to see why.

Manage versions

Each new version becomes the model's default version: the one used by auto-run and upload and run. Click a version in the versions table to make it the active version for running from the card.

Per version:

  • Details: build status, Docker image, build logs, runtime settings, and how many tasks and outputs it has produced.
  • Add Filter: show only this version's outputs.
  • Delete: deletes the version and its outputs. If it was the default, the newest remaining version becomes the default.

To delete a whole model, with its versions, tasks and outputs, click Delete Model on the card.

The model's owner manages its label classes, versions and settings. In a cloned project, models can only be added or updated if the original project allows it.

Security

Model containers run in an isolated network. During inference, a model you upload can only receive requests from MD.ai, and can't connect out to the internet or other services, so it can't send your data elsewhere. See Model Security.

On this page