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
- Open the project and open the
Modelspanel from the Navigation column. - Click
New Model. - Enter a name and description, and choose the scope: the unit the model takes as input.
- Choose the model settings, and create the model.
| Scope | The model receives |
|---|---|
Image | One image at a time (default) |
Series | A whole series, e.g. a CT or MR volume. Required for 3D models. |
Exam | A whole exam, with all its series |
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.
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 filesThe root folder must be named model. See Model Interface for what goes in each file. Compress the model folder as .zip or .tar.gz.
4. Build a version
On the model card, click New Model Version and follow the steps:
| Step | What to do |
|---|---|
| Upload Model | Drop in your .zip or .tar.gz. |
| Validate Model | MD.ai checks the package structure and config.yaml, and lists any errors. |
| Set Runtime Config | Choose the hardware and inputs. See below. |
| Set Model Args | Optional: add arguments, with default values, that users can change when they run the model. Your code reads them from data["args"]. |
| Build Model | Click Start Build. |
Runtime config:
| Setting | Options |
|---|---|
Runtime Hardware | CPU or GPU, as set by device_type in config.yaml |
GPU Type | The GPUs available on your deployment, such as NVIDIA T4 or L4 |
Input File Type | DICOM, or Thumbnail to receive PNG/JPEG renderings |
Input Data Source | Memory: files are passed in the request. Disk: files are written to disk and passed as paths, for large inputs. |
Batch Size | How many inputs the model receives at once, 1 to 1024. Fixed if batch_size is set in config.yaml. |
Input Annotations | Whether 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.