Args: predict_net, init_net (core.Net): caffe2 nets convert_outptus (callable): a function that converts caffe2 outputs to the same format of the original pytorch model. By default, use the one defined in the caffe2 meta_arch.
(self, predict_net, init_net, *, convert_outputs=None)
| 130 | """ |
| 131 | |
| 132 | def __init__(self, predict_net, init_net, *, convert_outputs=None): |
| 133 | """ |
| 134 | Args: |
| 135 | predict_net, init_net (core.Net): caffe2 nets |
| 136 | convert_outptus (callable): a function that converts caffe2 |
| 137 | outputs to the same format of the original pytorch model. |
| 138 | By default, use the one defined in the caffe2 meta_arch. |
| 139 | """ |
| 140 | super().__init__() |
| 141 | self.protobuf_model = ProtobufModel(predict_net, init_net) |
| 142 | self.size_divisibility = get_pb_arg_vali(predict_net, "size_divisibility", 0) |
| 143 | self.device = get_pb_arg_vals(predict_net, "device", b"cpu").decode("ascii") |
| 144 | |
| 145 | if convert_outputs is None: |
| 146 | meta_arch = get_pb_arg_vals(predict_net, "meta_architecture", b"GeneralizedRCNN") |
| 147 | meta_arch = META_ARCH_CAFFE2_EXPORT_TYPE_MAP[meta_arch.decode("ascii")] |
| 148 | self._convert_outputs = meta_arch.get_outputs_converter(predict_net, init_net) |
| 149 | else: |
| 150 | self._convert_outputs = convert_outputs |
| 151 | |
| 152 | def _convert_inputs(self, batched_inputs): |
| 153 | # currently all models convert inputs in the same way |
nothing calls this directly
no test coverage detected