MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / _get_net_io_info

Function _get_net_io_info

monai/bundle/scripts.py:1108–1142  ·  view source on GitHub ↗

Get the input and output information defined in the metadata. Args: parser: a ConfigParser of the given bundle. prefix: a prefix for the input and output ID, which will be combined as `prefix#inputs` and `prefix#outputs` to parse the input and output information

(parser: ConfigParser | None = None, prefix: str = "_meta_#network_data_format")

Source from the content-addressed store, hash-verified

1106
1107
1108def _get_net_io_info(parser: ConfigParser | None = None, prefix: str = "_meta_#network_data_format") -> tuple:
1109 """
1110 Get the input and output information defined in the metadata.
1111
1112 Args:
1113 parser: a ConfigParser of the given bundle.
1114 prefix: a prefix for the input and output ID, which will be combined as `prefix#inputs` and
1115 `prefix#outputs` to parse the input and output information in the `metadata.json` file of
1116 a bundle, default to `meta_#network_data_format`.
1117
1118 Returns:
1119 input_channels: the channel number of the `image` input.
1120 input_spatial_shape: the spatial shape of the `image` input.
1121 input_dtype: the data type of the `image` input.
1122 output_channels: the channel number of the output.
1123 output_dtype: the data type of the output.
1124 """
1125 if not isinstance(parser, ConfigParser):
1126 raise AttributeError(f"Parameter parser should be a ConfigParser, got {type(parser)}.")
1127
1128 prefix_key = f"{prefix}#inputs"
1129 key = f"{prefix_key}#image#num_channels"
1130 input_channels = parser.get(key)
1131 key = f"{prefix_key}#image#spatial_shape"
1132 input_spatial_shape = tuple(parser.get(key))
1133 key = f"{prefix_key}#image#dtype"
1134 input_dtype = get_equivalent_dtype(parser.get(key), torch.Tensor)
1135
1136 prefix_key = f"{prefix}#outputs"
1137 key = f"{prefix_key}#pred#num_channels"
1138 output_channels = parser.get(key)
1139 key = f"{prefix_key}#pred#dtype"
1140 output_dtype = get_equivalent_dtype(parser.get(key), torch.Tensor)
1141
1142 return input_channels, input_spatial_shape, input_dtype, output_channels, output_dtype
1143
1144
1145def _get_fake_input_shape(parser: ConfigParser) -> tuple:

Callers 2

_get_fake_input_shapeFunction · 0.85
verify_net_in_outFunction · 0.85

Calls 2

get_equivalent_dtypeFunction · 0.90
getMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…