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")
| 1106 | |
| 1107 | |
| 1108 | def _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 | |
| 1145 | def _get_fake_input_shape(parser: ConfigParser) -> tuple: |
no test coverage detected
searching dependent graphs…