From 1e132212b89efd18926cae0fa3b5b98b6f99a03a Mon Sep 17 00:00:00 2001 From: Eric Kerfoot Date: Mon, 22 Jan 2024 13:07:19 +0000 Subject: [PATCH 01/15] Adding metadata schema to the code base itself Signed-off-by: Eric Kerfoot --- monai/bundle/meta_schema.json | 181 ++++++++++++++++++++++++++++++++++ 1 file changed, 181 insertions(+) create mode 100644 monai/bundle/meta_schema.json diff --git a/monai/bundle/meta_schema.json b/monai/bundle/meta_schema.json new file mode 100644 index 0000000000..620c77e581 --- /dev/null +++ b/monai/bundle/meta_schema.json @@ -0,0 +1,181 @@ +{ + "$schema": "https://json-schema.org/draft/2019-09/schema", + "$defs": { + "tensor": { + "$comment": "Represents a tensor object argument/return value, can be MetaTensor.", + "type": "object", + "properties": { + "type": { "type": "string" }, + "format": { "type": "string" }, + "num_channels": { "type": "integer" }, + "spatial_shape": { + "type": "array", + "items": { + "type": ["string", "integer"] + } + }, + "dtype": { "type": "string" }, + "value_range": { + "type": "array", + "items": { "type": "number" } + }, + "is_patch_data": { "type": "boolean" }, + "channel_def": { "type": "object" } + }, + "required": [ + "type", + "format", + "num_channels", + "spatial_shape", + "dtype", + "value_range" + ] + }, + "argument": { + "$comment": "Acceptable input types for model forward pass, arbitrary Python objects not covered.", + "anyOf": [ + { "type": "number" }, + { "type": "integer" }, + { "type": "string" }, + { "type": "boolean" }, + { "$ref": "#/$defs/tensor" } + ] + }, + "result": { + "$comment": "Return value from a model's forward pass, same as an argument for now.", + "$ref": "#/$defs/argument" + }, + "network_io": { + "description": "Defines the format, shape, and meaning of inputs and outputs to the model.", + "type": "object", + "$comment": "Arguments/return values described by pattern property, order considered significant.", + "properties": { + "inputs": { + "type": "object", + "patternProperties": { + "^.+$": { "$ref": "#/$defs/argument" } + } + }, + "outputs": { + "type": "object", + "patternProperties": { + "^.+$": { "$ref": "#/$defs/result" } + } + }, + "post_processed_outputs": { + "$comment": "Return value format after post-processing, not needed if not changed.", + "type": "object", + "patternProperties": { + "^.+$": { "$ref": "#/$defs/result" } + } + } + }, + "required": [ + "inputs", + "outputs" + ] + } + }, + "type": "object", + "properties": { + "schema": { + "description": "URL of the schema file.", + "type": "string" + }, + "version": { + "description": "Version number of the bundle.", + "type": "string" + }, + "changelog": { + "description": "Dictionary relating previous version names to strings describing the version.", + "type": "object" + }, + "monai_version": { + "description": "Version of MONAI the bundle was generated with.", + "type": "string" + }, + "pytorch_version": { + "description": "Version of PyTorch the bundle was generated with.", + "type": "string" + }, + "numpy_version": { + "description": "Version of NumPy the bundlewas generated with.", + "type": "string" + }, + "required_packages_version": { + "description": "Dictionary relating required additional package names to their versions.", + "type": "object" + }, + "optional_packages_version": { + "description": "Dictionary relating optional additional package names to their versions.", + "type": "object" + }, + "task": { + "description": "Plain-language description of what the bundle is meant to do.", + "type": "string" + }, + "description": { + "description": "Longer form description of what the bundle is, what it does, etc.", + "type": "string" + }, + "authors": { + "description": "State author(s) of the bundle.", + "type": "string" + }, + "copyright": { + "description": "State copyright of the bundle.", + "type": "string" + }, + "data_source": { + "description": "Where to download or prepare the data used in this bundle.", + "type": "string" + }, + "data_type": { + "description": "Type of the data, like: `dicom`, `nibabel`, etc.", + "type": "string" + }, + "image_classes": { + "description": "Description for every class of the input tensors.", + "type": "string" + }, + "label_classes": { + "description": "Description for every class of the input tensors if present.", + "type": "string" + }, + "pred_classes": { + "description": "Description for every class of the output prediction(s).", + "type": "string" + }, + "eval_metrics": { + "description": "Dictionary relating evaluation metrics to the achieved scores.", + "type": "object" + }, + "intended_use": { + "description": "What the bundle is to be used for, ie. what task it accomplishes.", + "type": "string" + }, + "references": { + "description": "List of published referenced relating to the bundle.", + "type": "array" + }, + "network_data_format": { "$ref": "#/$defs/network_io" } + }, + "$comment": "This permits definitions for multiple networks with format _data_format", + "patternProperties": { + "^[_a-zA-Z0-9]+_data_format$": { "$ref": "#/$defs/network_io" } + }, + "required": [ + "schema", + "version", + "monai_version", + "pytorch_version", + "numpy_version", + "required_packages_version", + "optional_packages_version", + "task", + "description", + "authors", + "copyright", + "network_data_format" + ] +} From 5fe35243e7990f75eeec5c2be8a4779fc7ea08a7 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 22 Jan 2024 13:16:51 +0000 Subject: [PATCH 02/15] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- monai/bundle/meta_schema.json | 387 +++++++++++++++++++--------------- 1 file changed, 212 insertions(+), 175 deletions(-) diff --git a/monai/bundle/meta_schema.json b/monai/bundle/meta_schema.json index 620c77e581..9847f05077 100644 --- a/monai/bundle/meta_schema.json +++ b/monai/bundle/meta_schema.json @@ -1,181 +1,218 @@ { - "$schema": "https://json-schema.org/draft/2019-09/schema", - "$defs": { - "tensor": { - "$comment": "Represents a tensor object argument/return value, can be MetaTensor.", - "type": "object", - "properties": { - "type": { "type": "string" }, - "format": { "type": "string" }, - "num_channels": { "type": "integer" }, - "spatial_shape": { - "type": "array", - "items": { - "type": ["string", "integer"] - } - }, - "dtype": { "type": "string" }, - "value_range": { - "type": "array", - "items": { "type": "number" } - }, - "is_patch_data": { "type": "boolean" }, - "channel_def": { "type": "object" } - }, - "required": [ - "type", - "format", - "num_channels", - "spatial_shape", - "dtype", - "value_range" - ] - }, - "argument": { - "$comment": "Acceptable input types for model forward pass, arbitrary Python objects not covered.", - "anyOf": [ - { "type": "number" }, - { "type": "integer" }, - { "type": "string" }, - { "type": "boolean" }, - { "$ref": "#/$defs/tensor" } - ] - }, - "result": { - "$comment": "Return value from a model's forward pass, same as an argument for now.", - "$ref": "#/$defs/argument" - }, - "network_io": { - "description": "Defines the format, shape, and meaning of inputs and outputs to the model.", - "type": "object", - "$comment": "Arguments/return values described by pattern property, order considered significant.", - "properties": { - "inputs": { - "type": "object", - "patternProperties": { - "^.+$": { "$ref": "#/$defs/argument" } - } - }, - "outputs": { - "type": "object", - "patternProperties": { - "^.+$": { "$ref": "#/$defs/result" } - } - }, - "post_processed_outputs": { - "$comment": "Return value format after post-processing, not needed if not changed.", - "type": "object", - "patternProperties": { - "^.+$": { "$ref": "#/$defs/result" } - } + "$schema": "https://json-schema.org/draft/2019-09/schema", + "$defs": { + "tensor": { + "$comment": "Represents a tensor object argument/return value, can be MetaTensor.", + "type": "object", + "properties": { + "type": { + "type": "string" + }, + "format": { + "type": "string" + }, + "num_channels": { + "type": "integer" + }, + "spatial_shape": { + "type": "array", + "items": { + "type": [ + "string", + "integer" + ] + } + }, + "dtype": { + "type": "string" + }, + "value_range": { + "type": "array", + "items": { + "type": "number" + } + }, + "is_patch_data": { + "type": "boolean" + }, + "channel_def": { + "type": "object" + } + }, + "required": [ + "type", + "format", + "num_channels", + "spatial_shape", + "dtype", + "value_range" + ] + }, + "argument": { + "$comment": "Acceptable input types for model forward pass, arbitrary Python objects not covered.", + "anyOf": [ + { + "type": "number" + }, + { + "type": "integer" + }, + { + "type": "string" + }, + { + "type": "boolean" + }, + { + "$ref": "#/$defs/tensor" + } + ] + }, + "result": { + "$comment": "Return value from a model's forward pass, same as an argument for now.", + "$ref": "#/$defs/argument" + }, + "network_io": { + "description": "Defines the format, shape, and meaning of inputs and outputs to the model.", + "type": "object", + "$comment": "Arguments/return values described by pattern property, order considered significant.", + "properties": { + "inputs": { + "type": "object", + "patternProperties": { + "^.+$": { + "$ref": "#/$defs/argument" + } + } + }, + "outputs": { + "type": "object", + "patternProperties": { + "^.+$": { + "$ref": "#/$defs/result" + } + } + }, + "post_processed_outputs": { + "$comment": "Return value format after post-processing, not needed if not changed.", + "type": "object", + "patternProperties": { + "^.+$": { + "$ref": "#/$defs/result" + } + } + } + }, + "required": [ + "inputs", + "outputs" + ] } - }, - "required": [ - "inputs", - "outputs" - ] - } - }, - "type": "object", - "properties": { - "schema": { - "description": "URL of the schema file.", - "type": "string" - }, - "version": { - "description": "Version number of the bundle.", - "type": "string" - }, - "changelog": { - "description": "Dictionary relating previous version names to strings describing the version.", - "type": "object" - }, - "monai_version": { - "description": "Version of MONAI the bundle was generated with.", - "type": "string" - }, - "pytorch_version": { - "description": "Version of PyTorch the bundle was generated with.", - "type": "string" - }, - "numpy_version": { - "description": "Version of NumPy the bundlewas generated with.", - "type": "string" - }, - "required_packages_version": { - "description": "Dictionary relating required additional package names to their versions.", - "type": "object" - }, - "optional_packages_version": { - "description": "Dictionary relating optional additional package names to their versions.", - "type": "object" - }, - "task": { - "description": "Plain-language description of what the bundle is meant to do.", - "type": "string" - }, - "description": { - "description": "Longer form description of what the bundle is, what it does, etc.", - "type": "string" - }, - "authors": { - "description": "State author(s) of the bundle.", - "type": "string" - }, - "copyright": { - "description": "State copyright of the bundle.", - "type": "string" - }, - "data_source": { - "description": "Where to download or prepare the data used in this bundle.", - "type": "string" - }, - "data_type": { - "description": "Type of the data, like: `dicom`, `nibabel`, etc.", - "type": "string" - }, - "image_classes": { - "description": "Description for every class of the input tensors.", - "type": "string" - }, - "label_classes": { - "description": "Description for every class of the input tensors if present.", - "type": "string" - }, - "pred_classes": { - "description": "Description for every class of the output prediction(s).", - "type": "string" - }, - "eval_metrics": { - "description": "Dictionary relating evaluation metrics to the achieved scores.", - "type": "object" }, - "intended_use": { - "description": "What the bundle is to be used for, ie. what task it accomplishes.", - "type": "string" + "type": "object", + "properties": { + "schema": { + "description": "URL of the schema file.", + "type": "string" + }, + "version": { + "description": "Version number of the bundle.", + "type": "string" + }, + "changelog": { + "description": "Dictionary relating previous version names to strings describing the version.", + "type": "object" + }, + "monai_version": { + "description": "Version of MONAI the bundle was generated with.", + "type": "string" + }, + "pytorch_version": { + "description": "Version of PyTorch the bundle was generated with.", + "type": "string" + }, + "numpy_version": { + "description": "Version of NumPy the bundlewas generated with.", + "type": "string" + }, + "required_packages_version": { + "description": "Dictionary relating required additional package names to their versions.", + "type": "object" + }, + "optional_packages_version": { + "description": "Dictionary relating optional additional package names to their versions.", + "type": "object" + }, + "task": { + "description": "Plain-language description of what the bundle is meant to do.", + "type": "string" + }, + "description": { + "description": "Longer form description of what the bundle is, what it does, etc.", + "type": "string" + }, + "authors": { + "description": "State author(s) of the bundle.", + "type": "string" + }, + "copyright": { + "description": "State copyright of the bundle.", + "type": "string" + }, + "data_source": { + "description": "Where to download or prepare the data used in this bundle.", + "type": "string" + }, + "data_type": { + "description": "Type of the data, like: `dicom`, `nibabel`, etc.", + "type": "string" + }, + "image_classes": { + "description": "Description for every class of the input tensors.", + "type": "string" + }, + "label_classes": { + "description": "Description for every class of the input tensors if present.", + "type": "string" + }, + "pred_classes": { + "description": "Description for every class of the output prediction(s).", + "type": "string" + }, + "eval_metrics": { + "description": "Dictionary relating evaluation metrics to the achieved scores.", + "type": "object" + }, + "intended_use": { + "description": "What the bundle is to be used for, ie. what task it accomplishes.", + "type": "string" + }, + "references": { + "description": "List of published referenced relating to the bundle.", + "type": "array" + }, + "network_data_format": { + "$ref": "#/$defs/network_io" + } }, - "references": { - "description": "List of published referenced relating to the bundle.", - "type": "array" + "$comment": "This permits definitions for multiple networks with format _data_format", + "patternProperties": { + "^[_a-zA-Z0-9]+_data_format$": { + "$ref": "#/$defs/network_io" + } }, - "network_data_format": { "$ref": "#/$defs/network_io" } - }, - "$comment": "This permits definitions for multiple networks with format _data_format", - "patternProperties": { - "^[_a-zA-Z0-9]+_data_format$": { "$ref": "#/$defs/network_io" } - }, - "required": [ - "schema", - "version", - "monai_version", - "pytorch_version", - "numpy_version", - "required_packages_version", - "optional_packages_version", - "task", - "description", - "authors", - "copyright", - "network_data_format" - ] + "required": [ + "schema", + "version", + "monai_version", + "pytorch_version", + "numpy_version", + "required_packages_version", + "optional_packages_version", + "task", + "description", + "authors", + "copyright", + "network_data_format" + ] } From 85c0d88119717c45d9a4801ae88efea05c026918 Mon Sep 17 00:00:00 2001 From: Eric Kerfoot Date: Sat, 3 Feb 2024 00:35:50 +0000 Subject: [PATCH 03/15] Adding notebook testing validation Signed-off-by: Eric Kerfoot --- monai/bundle/schema_validation.ipynb | 150 +++++++++++++++++++++++++++ 1 file changed, 150 insertions(+) create mode 100644 monai/bundle/schema_validation.ipynb diff --git a/monai/bundle/schema_validation.ipynb b/monai/bundle/schema_validation.ipynb new file mode 100644 index 0000000000..eb85bab717 --- /dev/null +++ b/monai/bundle/schema_validation.ipynb @@ -0,0 +1,150 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "99837a51-832c-4289-9c3c-ad88326d01cb", + "metadata": {}, + "source": [ + "# Verify Test\n", + "\n", + "This generates a schema based off the one from the segmentation template in the model zoo. It uses the URL for the schema in this PR, adds `required_packages_version`, and makes `optional_packages_version` empty." + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "b7842f14-a0ac-44a0-a889-66d12808365f", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Writing test_metadata.json\n" + ] + } + ], + "source": [ + "%%writefile test_metadata.json\n", + "\n", + "{\n", + " \"schema\": \"https://raw.githubusercontent.com/Project-MONAI/MONAI/0c9bf116a0c21c3ac36f8c9c3415e3f7cadaf5ef/monai/bundle/meta_schema.json\",\n", + " \"version\": \"0.0.2\",\n", + " \"changelog\": {\n", + " \"0.0.2\": \"Minor train.yaml clarifications\",\n", + " \"0.0.1\": \"Initial version\"\n", + " },\n", + " \"monai_version\": \"1.2.0\",\n", + " \"pytorch_version\": \"2.0.1\",\n", + " \"numpy_version\": \"1.24.4\",\n", + " \"required_packages_version\": {\n", + " \"nibabel\": \"5.1.0\",\n", + " \"pytorch-ignite\": \"0.4.12\"\n", + " },\n", + " \"optional_packages_version\": {},\n", + " \"name\": \"Segmentation Template\",\n", + " \"task\": \"Segmentation of randomly generated spheres in 3D images\",\n", + " \"description\": \"This is a template bundle for segmenting in 3D, take this as a basis for your own bundles.\",\n", + " \"authors\": \"Eric Kerfoot\",\n", + " \"copyright\": \"Copyright (c) 2023 MONAI Consortium\",\n", + " \"network_data_format\": {\n", + " \"inputs\": {\n", + " \"image\": {\n", + " \"type\": \"image\",\n", + " \"format\": \"magnitude\",\n", + " \"modality\": \"none\",\n", + " \"num_channels\": 1,\n", + " \"spatial_shape\": [\n", + " 128,\n", + " 128,\n", + " 128\n", + " ],\n", + " \"dtype\": \"float32\",\n", + " \"value_range\": [],\n", + " \"is_patch_data\": false,\n", + " \"channel_def\": {\n", + " \"0\": \"image\"\n", + " }\n", + " }\n", + " },\n", + " \"outputs\": {\n", + " \"pred\": {\n", + " \"type\": \"image\",\n", + " \"format\": \"segmentation\",\n", + " \"num_channels\": 4,\n", + " \"spatial_shape\": [\n", + " 128,\n", + " 128,\n", + " 128\n", + " ],\n", + " \"dtype\": \"float32\",\n", + " \"value_range\": [\n", + " 0,\n", + " 3\n", + " ],\n", + " \"is_patch_data\": false,\n", + " \"channel_def\": {\n", + " \"0\": \"background\",\n", + " \"1\": \"category 1\",\n", + " \"2\": \"category 2\",\n", + " \"3\": \"category 3\"\n", + " }\n", + " }\n", + " }\n", + " }\n", + "}" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "fc99da20-8df0-4e46-81c4-f2fe8900e72f", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "2024-02-03 00:33:35,098 - INFO - --- input summary of monai.bundle.scripts.verify_metadata ---\n", + "2024-02-03 00:33:35,099 - INFO - > meta_file: 'test_metadata.json'\n", + "2024-02-03 00:33:35,099 - INFO - > filepath: 'test.json'\n", + "2024-02-03 00:33:35,099 - INFO - ---\n", + "\n", + "\n", + "2024-02-03 00:33:35,099 - INFO - Expected md5 is None, skip md5 check for file test.json.\n", + "2024-02-03 00:33:35,099 - INFO - File exists: test.json, skipped downloading.\n", + "2024-02-03 00:33:35,118 - INFO - metadata is verified with no error.\n" + ] + } + ], + "source": [ + "!python -m monai.bundle verify_metadata --meta_file test_metadata.json --filepath test.json" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python [conda env:monai]", + "language": "python", + "name": "conda-env-monai-py" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.13" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} From f8f5d7ab06f947f3e300dee3aadc5c812f4e7a50 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 3 Feb 2024 00:36:22 +0000 Subject: [PATCH 04/15] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- monai/bundle/schema_validation.ipynb | 296 +++++++++++++-------------- 1 file changed, 148 insertions(+), 148 deletions(-) diff --git a/monai/bundle/schema_validation.ipynb b/monai/bundle/schema_validation.ipynb index eb85bab717..58c97cc191 100644 --- a/monai/bundle/schema_validation.ipynb +++ b/monai/bundle/schema_validation.ipynb @@ -1,150 +1,150 @@ { - "cells": [ - { - "cell_type": "markdown", - "id": "99837a51-832c-4289-9c3c-ad88326d01cb", - "metadata": {}, - "source": [ - "# Verify Test\n", - "\n", - "This generates a schema based off the one from the segmentation template in the model zoo. It uses the URL for the schema in this PR, adds `required_packages_version`, and makes `optional_packages_version` empty." - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "id": "b7842f14-a0ac-44a0-a889-66d12808365f", - "metadata": { - "tags": [] - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Writing test_metadata.json\n" - ] - } - ], - "source": [ - "%%writefile test_metadata.json\n", - "\n", - "{\n", - " \"schema\": \"https://raw.githubusercontent.com/Project-MONAI/MONAI/0c9bf116a0c21c3ac36f8c9c3415e3f7cadaf5ef/monai/bundle/meta_schema.json\",\n", - " \"version\": \"0.0.2\",\n", - " \"changelog\": {\n", - " \"0.0.2\": \"Minor train.yaml clarifications\",\n", - " \"0.0.1\": \"Initial version\"\n", - " },\n", - " \"monai_version\": \"1.2.0\",\n", - " \"pytorch_version\": \"2.0.1\",\n", - " \"numpy_version\": \"1.24.4\",\n", - " \"required_packages_version\": {\n", - " \"nibabel\": \"5.1.0\",\n", - " \"pytorch-ignite\": \"0.4.12\"\n", - " },\n", - " \"optional_packages_version\": {},\n", - " \"name\": \"Segmentation Template\",\n", - " \"task\": \"Segmentation of randomly generated spheres in 3D images\",\n", - " \"description\": \"This is a template bundle for segmenting in 3D, take this as a basis for your own bundles.\",\n", - " \"authors\": \"Eric Kerfoot\",\n", - " \"copyright\": \"Copyright (c) 2023 MONAI Consortium\",\n", - " \"network_data_format\": {\n", - " \"inputs\": {\n", - " \"image\": {\n", - " \"type\": \"image\",\n", - " \"format\": \"magnitude\",\n", - " \"modality\": \"none\",\n", - " \"num_channels\": 1,\n", - " \"spatial_shape\": [\n", - " 128,\n", - " 128,\n", - " 128\n", - " ],\n", - " \"dtype\": \"float32\",\n", - " \"value_range\": [],\n", - " \"is_patch_data\": false,\n", - " \"channel_def\": {\n", - " \"0\": \"image\"\n", - " }\n", - " }\n", - " },\n", - " \"outputs\": {\n", - " \"pred\": {\n", - " \"type\": \"image\",\n", - " \"format\": \"segmentation\",\n", - " \"num_channels\": 4,\n", - " \"spatial_shape\": [\n", - " 128,\n", - " 128,\n", - " 128\n", - " ],\n", - " \"dtype\": \"float32\",\n", - " \"value_range\": [\n", - " 0,\n", - " 3\n", - " ],\n", - " \"is_patch_data\": false,\n", - " \"channel_def\": {\n", - " \"0\": \"background\",\n", - " \"1\": \"category 1\",\n", - " \"2\": \"category 2\",\n", - " \"3\": \"category 3\"\n", - " }\n", - " }\n", - " }\n", - " }\n", - "}" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "id": "fc99da20-8df0-4e46-81c4-f2fe8900e72f", - "metadata": { - "tags": [] - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "2024-02-03 00:33:35,098 - INFO - --- input summary of monai.bundle.scripts.verify_metadata ---\n", - "2024-02-03 00:33:35,099 - INFO - > meta_file: 'test_metadata.json'\n", - "2024-02-03 00:33:35,099 - INFO - > filepath: 'test.json'\n", - "2024-02-03 00:33:35,099 - INFO - ---\n", - "\n", - "\n", - "2024-02-03 00:33:35,099 - INFO - Expected md5 is None, skip md5 check for file test.json.\n", - "2024-02-03 00:33:35,099 - INFO - File exists: test.json, skipped downloading.\n", - "2024-02-03 00:33:35,118 - INFO - metadata is verified with no error.\n" - ] - } - ], - "source": [ - "!python -m monai.bundle verify_metadata --meta_file test_metadata.json --filepath test.json" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python [conda env:monai]", - "language": "python", - "name": "conda-env-monai-py" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.13" - } - }, - "nbformat": 4, - "nbformat_minor": 5 + "cells": [ + { + "cell_type": "markdown", + "id": "99837a51-832c-4289-9c3c-ad88326d01cb", + "metadata": {}, + "source": [ + "# Verify Test\n", + "\n", + "This generates a schema based off the one from the segmentation template in the model zoo. It uses the URL for the schema in this PR, adds `required_packages_version`, and makes `optional_packages_version` empty." + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "b7842f14-a0ac-44a0-a889-66d12808365f", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Writing test_metadata.json\n" + ] + } + ], + "source": [ + "%%writefile test_metadata.json\n", + "\n", + "{\n", + " \"schema\": \"https://raw.githubusercontent.com/Project-MONAI/MONAI/0c9bf116a0c21c3ac36f8c9c3415e3f7cadaf5ef/monai/bundle/meta_schema.json\",\n", + " \"version\": \"0.0.2\",\n", + " \"changelog\": {\n", + " \"0.0.2\": \"Minor train.yaml clarifications\",\n", + " \"0.0.1\": \"Initial version\"\n", + " },\n", + " \"monai_version\": \"1.2.0\",\n", + " \"pytorch_version\": \"2.0.1\",\n", + " \"numpy_version\": \"1.24.4\",\n", + " \"required_packages_version\": {\n", + " \"nibabel\": \"5.1.0\",\n", + " \"pytorch-ignite\": \"0.4.12\"\n", + " },\n", + " \"optional_packages_version\": {},\n", + " \"name\": \"Segmentation Template\",\n", + " \"task\": \"Segmentation of randomly generated spheres in 3D images\",\n", + " \"description\": \"This is a template bundle for segmenting in 3D, take this as a basis for your own bundles.\",\n", + " \"authors\": \"Eric Kerfoot\",\n", + " \"copyright\": \"Copyright (c) 2023 MONAI Consortium\",\n", + " \"network_data_format\": {\n", + " \"inputs\": {\n", + " \"image\": {\n", + " \"type\": \"image\",\n", + " \"format\": \"magnitude\",\n", + " \"modality\": \"none\",\n", + " \"num_channels\": 1,\n", + " \"spatial_shape\": [\n", + " 128,\n", + " 128,\n", + " 128\n", + " ],\n", + " \"dtype\": \"float32\",\n", + " \"value_range\": [],\n", + " \"is_patch_data\": false,\n", + " \"channel_def\": {\n", + " \"0\": \"image\"\n", + " }\n", + " }\n", + " },\n", + " \"outputs\": {\n", + " \"pred\": {\n", + " \"type\": \"image\",\n", + " \"format\": \"segmentation\",\n", + " \"num_channels\": 4,\n", + " \"spatial_shape\": [\n", + " 128,\n", + " 128,\n", + " 128\n", + " ],\n", + " \"dtype\": \"float32\",\n", + " \"value_range\": [\n", + " 0,\n", + " 3\n", + " ],\n", + " \"is_patch_data\": false,\n", + " \"channel_def\": {\n", + " \"0\": \"background\",\n", + " \"1\": \"category 1\",\n", + " \"2\": \"category 2\",\n", + " \"3\": \"category 3\"\n", + " }\n", + " }\n", + " }\n", + " }\n", + "}" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "fc99da20-8df0-4e46-81c4-f2fe8900e72f", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "2024-02-03 00:33:35,098 - INFO - --- input summary of monai.bundle.scripts.verify_metadata ---\n", + "2024-02-03 00:33:35,099 - INFO - > meta_file: 'test_metadata.json'\n", + "2024-02-03 00:33:35,099 - INFO - > filepath: 'test.json'\n", + "2024-02-03 00:33:35,099 - INFO - ---\n", + "\n", + "\n", + "2024-02-03 00:33:35,099 - INFO - Expected md5 is None, skip md5 check for file test.json.\n", + "2024-02-03 00:33:35,099 - INFO - File exists: test.json, skipped downloading.\n", + "2024-02-03 00:33:35,118 - INFO - metadata is verified with no error.\n" + ] + } + ], + "source": [ + "!python -m monai.bundle verify_metadata --meta_file test_metadata.json --filepath test.json" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python [conda env:monai]", + "language": "python", + "name": "conda-env-monai-py" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.13" + } + }, + "nbformat": 4, + "nbformat_minor": 5 } From b46bb5bae19d3d4e30741abed4dd2540088905c1 Mon Sep 17 00:00:00 2001 From: Eric Kerfoot Date: Sat, 24 Feb 2024 20:57:01 +0000 Subject: [PATCH 05/15] Update schema description Signed-off-by: Eric Kerfoot --- monai/bundle/meta_schema.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/monai/bundle/meta_schema.json b/monai/bundle/meta_schema.json index 9847f05077..1775fa686d 100644 --- a/monai/bundle/meta_schema.json +++ b/monai/bundle/meta_schema.json @@ -136,11 +136,11 @@ "type": "string" }, "required_packages_version": { - "description": "Dictionary relating required additional package names to their versions.", + "description": "Dictionary relating required package names to their versions. The bundle requires these packages to operate.", "type": "object" }, "optional_packages_version": { - "description": "Dictionary relating optional additional package names to their versions.", + "description": "Dictionary relating optional additional package names to their versions. The bundle can operate without these packages but if present they enable specific functionality or features.", "type": "object" }, "task": { From aee04f62ed970b20c08dd5d317165a06bdd71c23 Mon Sep 17 00:00:00 2001 From: Eric Kerfoot Date: Mon, 25 Mar 2024 20:49:00 +0000 Subject: [PATCH 06/15] Update docs and schema based on conversation Signed-off-by: Eric Kerfoot --- docs/source/mb_specification.rst | 8 +++++--- monai/bundle/meta_schema.json | 3 +-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/source/mb_specification.rst b/docs/source/mb_specification.rst index cedafa0d23..65c5944c3e 100644 --- a/docs/source/mb_specification.rst +++ b/docs/source/mb_specification.rst @@ -63,12 +63,13 @@ This file contains the metadata information relating to the model, including wha * **monai_version**: version of MONAI the bundle was generated on, later versions expected to work. * **pytorch_version**: version of Pytorch the bundle was generated on, later versions expected to work. * **numpy_version**: version of Numpy the bundle was generated on, later versions expected to work. -* **optional_packages_version**: dictionary relating optional package names to their versions, these packages are not needed but are recommended to be installed with this stated minimum version. +* **required_packages_version**: dictionary relating required package names to their versions. These are packages in addition to the base requirements of MONAI which this bundle absolutely needs. For example, if the bundle must load Nifti files the Nibabel package will be required. * **task**: plain-language description of what the model is meant to do. * **description**: longer form plain-language description of what the model is, what it does, etc. * **authors**: state author(s) of the model. * **copyright**: state model copyright. -* **network_data_format**: defines the format, shape, and meaning of inputs and outputs to the model, contains keys "inputs" and "outputs" relating named inputs/outputs to their format specifiers (defined below). +* **network_data_format**: defines the format, shape, and meaning of inputs and outputs to the (primary) model, contains keys "inputs" and "outputs" relating named inputs/outputs to their format specifiers (defined below). There is also an optional "post_processed_outputs" key stating the format of "outputs" after postprocessing transforms are applied, this is used to describe the final output from the bundle if it varies from the raw network output. These keys can also relate to primitive values (number, string, boolean), instead of the tensor format specified below. +* **\*_data_format**: defines the format, shape, and meaning of inputs and outputs to additional models which are secondary to the main model. This contains the same sort of information as **network_data_format** which describes networks providing secondary functionality, eg. a localisation network used to identify ROI in an image for cropping before data is sent to the primary network of this bundle. Tensor format specifiers are used to define input and output tensors and their meanings, and must be a dictionary containing at least these keys: @@ -89,6 +90,7 @@ Optional keys: * **data_source**: description of where training/validation can be sourced. * **data_type**: type of source data used for training/validation. * **references**: list of published referenced relating to the model. +* **optional_packages_version**: dictionary relating optional package names to their versions. These packages are not needed but are recommended to be installed with this stated minimum version. If they are installed then specific features or optimisations may be enabled, so the README.md file for the bundle should be consulted to understand what these are for. The format for tensors used as inputs and outputs can be used to specify semantic meaning of these values, and later is used by software handling bundles to determine how to process and interpret this data. There are various types of image data that MONAI is uses, and other data types such as point clouds, dictionary sequences, time signals, and others. The following list is provided as a set of supported definitions of what a tensor "format" is but is not exhaustive and users can provide their own which would be left up to the model users to interpret: @@ -124,7 +126,7 @@ An example JSON metadata file: "monai_version": "0.9.0", "pytorch_version": "1.10.0", "numpy_version": "1.21.2", - "optional_packages_version": {"nibabel": "3.2.1"}, + "required_packages_version": {"nibabel": "3.2.1"}, "task": "Decathlon spleen segmentation", "description": "A pre-trained model for volumetric (3D) segmentation of the spleen from CT image", "authors": "MONAI team", diff --git a/monai/bundle/meta_schema.json b/monai/bundle/meta_schema.json index 1775fa686d..3fa94e8ce1 100644 --- a/monai/bundle/meta_schema.json +++ b/monai/bundle/meta_schema.json @@ -136,7 +136,7 @@ "type": "string" }, "required_packages_version": { - "description": "Dictionary relating required package names to their versions. The bundle requires these packages to operate.", + "description": "Dictionary relating required package names to their versions. The bundle requires these packages to operate which are additional to the base requirements for MONAI.", "type": "object" }, "optional_packages_version": { @@ -208,7 +208,6 @@ "pytorch_version", "numpy_version", "required_packages_version", - "optional_packages_version", "task", "description", "authors", From 1174ea01e988aafec258e6c0983b9611b80bbe24 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 25 Mar 2024 20:49:25 +0000 Subject: [PATCH 07/15] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- docs/source/mb_specification.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/mb_specification.rst b/docs/source/mb_specification.rst index 65c5944c3e..bbb0677869 100644 --- a/docs/source/mb_specification.rst +++ b/docs/source/mb_specification.rst @@ -63,7 +63,7 @@ This file contains the metadata information relating to the model, including wha * **monai_version**: version of MONAI the bundle was generated on, later versions expected to work. * **pytorch_version**: version of Pytorch the bundle was generated on, later versions expected to work. * **numpy_version**: version of Numpy the bundle was generated on, later versions expected to work. -* **required_packages_version**: dictionary relating required package names to their versions. These are packages in addition to the base requirements of MONAI which this bundle absolutely needs. For example, if the bundle must load Nifti files the Nibabel package will be required. +* **required_packages_version**: dictionary relating required package names to their versions. These are packages in addition to the base requirements of MONAI which this bundle absolutely needs. For example, if the bundle must load Nifti files the Nibabel package will be required. * **task**: plain-language description of what the model is meant to do. * **description**: longer form plain-language description of what the model is, what it does, etc. * **authors**: state author(s) of the model. From 4bd9afcc605f5d2c07368d98c190d897ef4440ef Mon Sep 17 00:00:00 2001 From: Eric Kerfoot Date: Wed, 24 Jul 2024 15:35:30 +0100 Subject: [PATCH 08/15] Update to include supported_apps Signed-off-by: Eric Kerfoot --- docs/source/mb_specification.rst | 1 + monai/bundle/meta_schema.json | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/source/mb_specification.rst b/docs/source/mb_specification.rst index bbb0677869..d3dfacd59b 100644 --- a/docs/source/mb_specification.rst +++ b/docs/source/mb_specification.rst @@ -90,6 +90,7 @@ Optional keys: * **data_source**: description of where training/validation can be sourced. * **data_type**: type of source data used for training/validation. * **references**: list of published referenced relating to the model. +* **supported_apps**: list of supported applications which use bundles, eg. 'monai-label' would be present if the bundle is compatible with MONAI Label applications. * **optional_packages_version**: dictionary relating optional package names to their versions. These packages are not needed but are recommended to be installed with this stated minimum version. If they are installed then specific features or optimisations may be enabled, so the README.md file for the bundle should be consulted to understand what these are for. The format for tensors used as inputs and outputs can be used to specify semantic meaning of these values, and later is used by software handling bundles to determine how to process and interpret this data. There are various types of image data that MONAI is uses, and other data types such as point clouds, dictionary sequences, time signals, and others. The following list is provided as a set of supported definitions of what a tensor "format" is but is not exhaustive and users can provide their own which would be left up to the model users to interpret: diff --git a/monai/bundle/meta_schema.json b/monai/bundle/meta_schema.json index 3fa94e8ce1..a51869ba26 100644 --- a/monai/bundle/meta_schema.json +++ b/monai/bundle/meta_schema.json @@ -189,7 +189,17 @@ }, "references": { "description": "List of published referenced relating to the bundle.", - "type": "array" + "type": "array", + "items": { + "type": "string" + } + }, + "supported_apps": { + "description": "List of supported applications, eg. 'monai-label'", + "type": "array", + "items": { + "type": "string" + } }, "network_data_format": { "$ref": "#/$defs/network_io" From c048763e3598fc49e505007b382d18a356188708 Mon Sep 17 00:00:00 2001 From: Eric Kerfoot Date: Wed, 24 Jul 2024 17:32:18 +0100 Subject: [PATCH 09/15] Remove optional packages Signed-off-by: Eric Kerfoot --- monai/bundle/meta_schema.json | 4 ---- 1 file changed, 4 deletions(-) diff --git a/monai/bundle/meta_schema.json b/monai/bundle/meta_schema.json index a51869ba26..17727efba0 100644 --- a/monai/bundle/meta_schema.json +++ b/monai/bundle/meta_schema.json @@ -139,10 +139,6 @@ "description": "Dictionary relating required package names to their versions. The bundle requires these packages to operate which are additional to the base requirements for MONAI.", "type": "object" }, - "optional_packages_version": { - "description": "Dictionary relating optional additional package names to their versions. The bundle can operate without these packages but if present they enable specific functionality or features.", - "type": "object" - }, "task": { "description": "Plain-language description of what the bundle is meant to do.", "type": "string" From 9b071ae98e1f741790fecfccc6668c14ec3f07db Mon Sep 17 00:00:00 2001 From: Eric Kerfoot Date: Wed, 24 Jul 2024 17:33:52 +0100 Subject: [PATCH 10/15] Remove optional packages Signed-off-by: Eric Kerfoot --- docs/source/mb_specification.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/mb_specification.rst b/docs/source/mb_specification.rst index d3dfacd59b..056ef50074 100644 --- a/docs/source/mb_specification.rst +++ b/docs/source/mb_specification.rst @@ -91,7 +91,7 @@ Optional keys: * **data_type**: type of source data used for training/validation. * **references**: list of published referenced relating to the model. * **supported_apps**: list of supported applications which use bundles, eg. 'monai-label' would be present if the bundle is compatible with MONAI Label applications. -* **optional_packages_version**: dictionary relating optional package names to their versions. These packages are not needed but are recommended to be installed with this stated minimum version. If they are installed then specific features or optimisations may be enabled, so the README.md file for the bundle should be consulted to understand what these are for. +* **required_packages_version**: dictionary relating required package names to their versions. These packages are needed to be installed with this stated version. The format for tensors used as inputs and outputs can be used to specify semantic meaning of these values, and later is used by software handling bundles to determine how to process and interpret this data. There are various types of image data that MONAI is uses, and other data types such as point clouds, dictionary sequences, time signals, and others. The following list is provided as a set of supported definitions of what a tensor "format" is but is not exhaustive and users can provide their own which would be left up to the model users to interpret: From f9f2aebbe6ffbed4d321db580fb40520fbba2f96 Mon Sep 17 00:00:00 2001 From: Eric Kerfoot Date: Thu, 25 Jul 2024 12:20:05 +0100 Subject: [PATCH 11/15] Adjust supported_apps Signed-off-by: Eric Kerfoot --- monai/bundle/meta_schema.json | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/monai/bundle/meta_schema.json b/monai/bundle/meta_schema.json index 17727efba0..7b587e1a9c 100644 --- a/monai/bundle/meta_schema.json +++ b/monai/bundle/meta_schema.json @@ -192,10 +192,7 @@ }, "supported_apps": { "description": "List of supported applications, eg. 'monai-label'", - "type": "array", - "items": { - "type": "string" - } + "type": "object", }, "network_data_format": { "$ref": "#/$defs/network_io" From 55e5500df7ef4289f08fa13ab26a8f8e0ee4f954 Mon Sep 17 00:00:00 2001 From: Eric Kerfoot Date: Thu, 25 Jul 2024 12:38:34 +0100 Subject: [PATCH 12/15] Removing notebook Signed-off-by: Eric Kerfoot --- monai/bundle/schema_validation.ipynb | 150 --------------------------- 1 file changed, 150 deletions(-) delete mode 100644 monai/bundle/schema_validation.ipynb diff --git a/monai/bundle/schema_validation.ipynb b/monai/bundle/schema_validation.ipynb deleted file mode 100644 index 58c97cc191..0000000000 --- a/monai/bundle/schema_validation.ipynb +++ /dev/null @@ -1,150 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "id": "99837a51-832c-4289-9c3c-ad88326d01cb", - "metadata": {}, - "source": [ - "# Verify Test\n", - "\n", - "This generates a schema based off the one from the segmentation template in the model zoo. It uses the URL for the schema in this PR, adds `required_packages_version`, and makes `optional_packages_version` empty." - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "id": "b7842f14-a0ac-44a0-a889-66d12808365f", - "metadata": { - "tags": [] - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Writing test_metadata.json\n" - ] - } - ], - "source": [ - "%%writefile test_metadata.json\n", - "\n", - "{\n", - " \"schema\": \"https://raw.githubusercontent.com/Project-MONAI/MONAI/0c9bf116a0c21c3ac36f8c9c3415e3f7cadaf5ef/monai/bundle/meta_schema.json\",\n", - " \"version\": \"0.0.2\",\n", - " \"changelog\": {\n", - " \"0.0.2\": \"Minor train.yaml clarifications\",\n", - " \"0.0.1\": \"Initial version\"\n", - " },\n", - " \"monai_version\": \"1.2.0\",\n", - " \"pytorch_version\": \"2.0.1\",\n", - " \"numpy_version\": \"1.24.4\",\n", - " \"required_packages_version\": {\n", - " \"nibabel\": \"5.1.0\",\n", - " \"pytorch-ignite\": \"0.4.12\"\n", - " },\n", - " \"optional_packages_version\": {},\n", - " \"name\": \"Segmentation Template\",\n", - " \"task\": \"Segmentation of randomly generated spheres in 3D images\",\n", - " \"description\": \"This is a template bundle for segmenting in 3D, take this as a basis for your own bundles.\",\n", - " \"authors\": \"Eric Kerfoot\",\n", - " \"copyright\": \"Copyright (c) 2023 MONAI Consortium\",\n", - " \"network_data_format\": {\n", - " \"inputs\": {\n", - " \"image\": {\n", - " \"type\": \"image\",\n", - " \"format\": \"magnitude\",\n", - " \"modality\": \"none\",\n", - " \"num_channels\": 1,\n", - " \"spatial_shape\": [\n", - " 128,\n", - " 128,\n", - " 128\n", - " ],\n", - " \"dtype\": \"float32\",\n", - " \"value_range\": [],\n", - " \"is_patch_data\": false,\n", - " \"channel_def\": {\n", - " \"0\": \"image\"\n", - " }\n", - " }\n", - " },\n", - " \"outputs\": {\n", - " \"pred\": {\n", - " \"type\": \"image\",\n", - " \"format\": \"segmentation\",\n", - " \"num_channels\": 4,\n", - " \"spatial_shape\": [\n", - " 128,\n", - " 128,\n", - " 128\n", - " ],\n", - " \"dtype\": \"float32\",\n", - " \"value_range\": [\n", - " 0,\n", - " 3\n", - " ],\n", - " \"is_patch_data\": false,\n", - " \"channel_def\": {\n", - " \"0\": \"background\",\n", - " \"1\": \"category 1\",\n", - " \"2\": \"category 2\",\n", - " \"3\": \"category 3\"\n", - " }\n", - " }\n", - " }\n", - " }\n", - "}" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "id": "fc99da20-8df0-4e46-81c4-f2fe8900e72f", - "metadata": { - "tags": [] - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "2024-02-03 00:33:35,098 - INFO - --- input summary of monai.bundle.scripts.verify_metadata ---\n", - "2024-02-03 00:33:35,099 - INFO - > meta_file: 'test_metadata.json'\n", - "2024-02-03 00:33:35,099 - INFO - > filepath: 'test.json'\n", - "2024-02-03 00:33:35,099 - INFO - ---\n", - "\n", - "\n", - "2024-02-03 00:33:35,099 - INFO - Expected md5 is None, skip md5 check for file test.json.\n", - "2024-02-03 00:33:35,099 - INFO - File exists: test.json, skipped downloading.\n", - "2024-02-03 00:33:35,118 - INFO - metadata is verified with no error.\n" - ] - } - ], - "source": [ - "!python -m monai.bundle verify_metadata --meta_file test_metadata.json --filepath test.json" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python [conda env:monai]", - "language": "python", - "name": "conda-env-monai-py" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.13" - } - }, - "nbformat": 4, - "nbformat_minor": 5 -} From d78fa37d0b3a0a98783dcb05b5870892f44cfc1f Mon Sep 17 00:00:00 2001 From: Eric Kerfoot Date: Thu, 25 Jul 2024 13:14:25 +0100 Subject: [PATCH 13/15] Adjust supported_apps Signed-off-by: Eric Kerfoot --- monai/bundle/meta_schema.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monai/bundle/meta_schema.json b/monai/bundle/meta_schema.json index 7b587e1a9c..35cf49358b 100644 --- a/monai/bundle/meta_schema.json +++ b/monai/bundle/meta_schema.json @@ -192,7 +192,7 @@ }, "supported_apps": { "description": "List of supported applications, eg. 'monai-label'", - "type": "object", + "type": "object" }, "network_data_format": { "$ref": "#/$defs/network_io" From 45c7983910874f1f2b8a637defe84af83eace648 Mon Sep 17 00:00:00 2001 From: Eric Kerfoot Date: Thu, 25 Jul 2024 17:07:04 +0100 Subject: [PATCH 14/15] Updates Signed-off-by: Eric Kerfoot --- docs/source/mb_specification.rst | 3 +-- monai/bundle/meta_schema.json | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/source/mb_specification.rst b/docs/source/mb_specification.rst index 056ef50074..56d660e35c 100644 --- a/docs/source/mb_specification.rst +++ b/docs/source/mb_specification.rst @@ -69,7 +69,6 @@ This file contains the metadata information relating to the model, including wha * **authors**: state author(s) of the model. * **copyright**: state model copyright. * **network_data_format**: defines the format, shape, and meaning of inputs and outputs to the (primary) model, contains keys "inputs" and "outputs" relating named inputs/outputs to their format specifiers (defined below). There is also an optional "post_processed_outputs" key stating the format of "outputs" after postprocessing transforms are applied, this is used to describe the final output from the bundle if it varies from the raw network output. These keys can also relate to primitive values (number, string, boolean), instead of the tensor format specified below. -* **\*_data_format**: defines the format, shape, and meaning of inputs and outputs to additional models which are secondary to the main model. This contains the same sort of information as **network_data_format** which describes networks providing secondary functionality, eg. a localisation network used to identify ROI in an image for cropping before data is sent to the primary network of this bundle. Tensor format specifiers are used to define input and output tensors and their meanings, and must be a dictionary containing at least these keys: @@ -91,7 +90,7 @@ Optional keys: * **data_type**: type of source data used for training/validation. * **references**: list of published referenced relating to the model. * **supported_apps**: list of supported applications which use bundles, eg. 'monai-label' would be present if the bundle is compatible with MONAI Label applications. -* **required_packages_version**: dictionary relating required package names to their versions. These packages are needed to be installed with this stated version. +* **\*_data_format**: defines the format, shape, and meaning of inputs and outputs to additional models which are secondary to the main model. This contains the same sort of information as **network_data_format** which describes networks providing secondary functionality, eg. a localisation network used to identify ROI in an image for cropping before data is sent to the primary network of this bundle. The format for tensors used as inputs and outputs can be used to specify semantic meaning of these values, and later is used by software handling bundles to determine how to process and interpret this data. There are various types of image data that MONAI is uses, and other data types such as point clouds, dictionary sequences, time signals, and others. The following list is provided as a set of supported definitions of what a tensor "format" is but is not exhaustive and users can provide their own which would be left up to the model users to interpret: diff --git a/monai/bundle/meta_schema.json b/monai/bundle/meta_schema.json index 35cf49358b..ae2775d63a 100644 --- a/monai/bundle/meta_schema.json +++ b/monai/bundle/meta_schema.json @@ -73,7 +73,7 @@ "$ref": "#/$defs/argument" }, "network_io": { - "description": "Defines the format, shape, and meaning of inputs and outputs to the model.", + "description": "Defines the format, shape, and meaning of inputs, outputs (and optionally post-processed outputs) to the model.", "type": "object", "$comment": "Arguments/return values described by pattern property, order considered significant.", "properties": { From 7f0e05ffc8824edc64b080ee215f06f30ff9abdd Mon Sep 17 00:00:00 2001 From: Eric Kerfoot Date: Thu, 25 Jul 2024 17:08:34 +0100 Subject: [PATCH 15/15] Removing schema file Signed-off-by: Eric Kerfoot --- monai/bundle/meta_schema.json | 220 ---------------------------------- 1 file changed, 220 deletions(-) delete mode 100644 monai/bundle/meta_schema.json diff --git a/monai/bundle/meta_schema.json b/monai/bundle/meta_schema.json deleted file mode 100644 index ae2775d63a..0000000000 --- a/monai/bundle/meta_schema.json +++ /dev/null @@ -1,220 +0,0 @@ -{ - "$schema": "https://json-schema.org/draft/2019-09/schema", - "$defs": { - "tensor": { - "$comment": "Represents a tensor object argument/return value, can be MetaTensor.", - "type": "object", - "properties": { - "type": { - "type": "string" - }, - "format": { - "type": "string" - }, - "num_channels": { - "type": "integer" - }, - "spatial_shape": { - "type": "array", - "items": { - "type": [ - "string", - "integer" - ] - } - }, - "dtype": { - "type": "string" - }, - "value_range": { - "type": "array", - "items": { - "type": "number" - } - }, - "is_patch_data": { - "type": "boolean" - }, - "channel_def": { - "type": "object" - } - }, - "required": [ - "type", - "format", - "num_channels", - "spatial_shape", - "dtype", - "value_range" - ] - }, - "argument": { - "$comment": "Acceptable input types for model forward pass, arbitrary Python objects not covered.", - "anyOf": [ - { - "type": "number" - }, - { - "type": "integer" - }, - { - "type": "string" - }, - { - "type": "boolean" - }, - { - "$ref": "#/$defs/tensor" - } - ] - }, - "result": { - "$comment": "Return value from a model's forward pass, same as an argument for now.", - "$ref": "#/$defs/argument" - }, - "network_io": { - "description": "Defines the format, shape, and meaning of inputs, outputs (and optionally post-processed outputs) to the model.", - "type": "object", - "$comment": "Arguments/return values described by pattern property, order considered significant.", - "properties": { - "inputs": { - "type": "object", - "patternProperties": { - "^.+$": { - "$ref": "#/$defs/argument" - } - } - }, - "outputs": { - "type": "object", - "patternProperties": { - "^.+$": { - "$ref": "#/$defs/result" - } - } - }, - "post_processed_outputs": { - "$comment": "Return value format after post-processing, not needed if not changed.", - "type": "object", - "patternProperties": { - "^.+$": { - "$ref": "#/$defs/result" - } - } - } - }, - "required": [ - "inputs", - "outputs" - ] - } - }, - "type": "object", - "properties": { - "schema": { - "description": "URL of the schema file.", - "type": "string" - }, - "version": { - "description": "Version number of the bundle.", - "type": "string" - }, - "changelog": { - "description": "Dictionary relating previous version names to strings describing the version.", - "type": "object" - }, - "monai_version": { - "description": "Version of MONAI the bundle was generated with.", - "type": "string" - }, - "pytorch_version": { - "description": "Version of PyTorch the bundle was generated with.", - "type": "string" - }, - "numpy_version": { - "description": "Version of NumPy the bundlewas generated with.", - "type": "string" - }, - "required_packages_version": { - "description": "Dictionary relating required package names to their versions. The bundle requires these packages to operate which are additional to the base requirements for MONAI.", - "type": "object" - }, - "task": { - "description": "Plain-language description of what the bundle is meant to do.", - "type": "string" - }, - "description": { - "description": "Longer form description of what the bundle is, what it does, etc.", - "type": "string" - }, - "authors": { - "description": "State author(s) of the bundle.", - "type": "string" - }, - "copyright": { - "description": "State copyright of the bundle.", - "type": "string" - }, - "data_source": { - "description": "Where to download or prepare the data used in this bundle.", - "type": "string" - }, - "data_type": { - "description": "Type of the data, like: `dicom`, `nibabel`, etc.", - "type": "string" - }, - "image_classes": { - "description": "Description for every class of the input tensors.", - "type": "string" - }, - "label_classes": { - "description": "Description for every class of the input tensors if present.", - "type": "string" - }, - "pred_classes": { - "description": "Description for every class of the output prediction(s).", - "type": "string" - }, - "eval_metrics": { - "description": "Dictionary relating evaluation metrics to the achieved scores.", - "type": "object" - }, - "intended_use": { - "description": "What the bundle is to be used for, ie. what task it accomplishes.", - "type": "string" - }, - "references": { - "description": "List of published referenced relating to the bundle.", - "type": "array", - "items": { - "type": "string" - } - }, - "supported_apps": { - "description": "List of supported applications, eg. 'monai-label'", - "type": "object" - }, - "network_data_format": { - "$ref": "#/$defs/network_io" - } - }, - "$comment": "This permits definitions for multiple networks with format _data_format", - "patternProperties": { - "^[_a-zA-Z0-9]+_data_format$": { - "$ref": "#/$defs/network_io" - } - }, - "required": [ - "schema", - "version", - "monai_version", - "pytorch_version", - "numpy_version", - "required_packages_version", - "task", - "description", - "authors", - "copyright", - "network_data_format" - ] -}