Skip to content

MONAI Archive Specification

Eric Kerfoot edited this page Feb 18, 2022 · 6 revisions

Overview

This is the specification for the MONAI Archive (MAR) format of portable described deep learning models. The objective of a MAR is to define a packaged network or model which includes the critical information necessary to allow users and other programs to understand how the model is used and for what purpose. A MAR includes the stored weights of a model as a state dictionary and/or a Torchscript object. Additional JSON files are included to store metadata about the model, information for constructing training, inference, and post-processing transform sequences, plain-text description, legal information, and other data the model creator wishes to include.

This specification defines the directory structure a MAR must have and the necessary files it must contain. Additional files may be included and the directory packaged into a zip file or included as extra files directly in a Torchscript file.

Directory Structure

A MAR package is defined primarily as a directory with a set of specifically named subdirectories containing the model and metadata files. The root directory should be named for the model, given as "ModelName", and should contain the following structure:

ModelName
┣━ configs
┃  ┗━ metadata.json
┣━ models
┃  ┣━ model.pt
┃  ┗━ model.ts
┗━ docs
   ┣━ README.md
   ┗━ license.txt

These files mostly are required to be present with the given names for the directory to define a valid MAR:

  • metadata.json: netadata information in JSON format relating to the type of model, definition of input and output tensors, versions of the model and used software, and other information described below.
  • model.pt: the state dictionary of a saved model, the information to instantiate the model must be found in the metadata file.
  • model.ts: the Torchscript saved model if the model is compatible with being saved correctly in this format.
  • README.md: plain-language information on the model, how to use it, author information, etc. in Markdown format.
  • license.txt: software license attached to the model, can be left blank if no license needed.
Clone this wiki locally