Args: inputs: the inputs to a model. It is a list of dicts. Each dict corresponds to an image and contains keys like "height", "width", "file_name". outputs: the outputs of a model. It is either list of semantic segmentation prediction
(self, inputs, outputs)
| 105 | self._predictions = [] |
| 106 | |
| 107 | def process(self, inputs, outputs): |
| 108 | """ |
| 109 | Args: |
| 110 | inputs: the inputs to a model. |
| 111 | It is a list of dicts. Each dict corresponds to an image and |
| 112 | contains keys like "height", "width", "file_name". |
| 113 | outputs: the outputs of a model. It is either list of semantic segmentation predictions |
| 114 | (Tensor [H, W]) or list of dicts with key "sem_seg" that contains semantic |
| 115 | segmentation prediction in the same format. |
| 116 | """ |
| 117 | # for input, output in zip(inputs, outputs): |
| 118 | input, output = inputs, outputs[0] |
| 119 | |
| 120 | output = output["sem_seg"].argmax(dim=0).to(self._cpu_device) |
| 121 | pred = np.array(output, dtype=np.int) |
| 122 | |
| 123 | gt = input["gt"] |
| 124 | gt[gt == self._ignore_label] = self._num_classes |
| 125 | |
| 126 | self._conf_matrix += np.bincount( |
| 127 | (self._num_classes + 1) * pred.reshape(-1) + gt.reshape(-1), |
| 128 | minlength=self._conf_matrix.size, |
| 129 | ).reshape(self._conf_matrix.shape) |
| 130 | |
| 131 | self._predictions.extend(self.encode_json_sem_seg(pred, input["filename"])) |
| 132 | |
| 133 | @staticmethod |
| 134 | def all_gather(data, group=None): |
nothing calls this directly
no test coverage detected