:meth: read the object from a dict
(self, record, body_key, head_key, class_names, gtflag)
| 208 | self._dtNum = None |
| 209 | |
| 210 | def load(self, record, body_key, head_key, class_names, gtflag): |
| 211 | """ |
| 212 | :meth: read the object from a dict |
| 213 | """ |
| 214 | if "ID" in record and self.ID is None: |
| 215 | self.ID = record['ID'] |
| 216 | if "width" in record and self._width is None: |
| 217 | self._width = record["width"] |
| 218 | if "height" in record and self._height is None: |
| 219 | self._height = record["height"] |
| 220 | if gtflag: |
| 221 | self._gtNum = len(record["gtboxes"]) |
| 222 | body_bbox, head_bbox = self.load_gt_boxes(record, 'gtboxes', class_names) |
| 223 | if self.eval_mode == 0: |
| 224 | self.gtboxes = body_bbox |
| 225 | self._ignNum = (body_bbox[:, -1] == -1).sum() |
| 226 | elif self.eval_mode == 1: |
| 227 | self.gtboxes = head_bbox |
| 228 | self._ignNum = (head_bbox[:, -1] == -1).sum() |
| 229 | elif self.eval_mode == 2: |
| 230 | gt_tag = np.array( |
| 231 | [body_bbox[i, -1] != -1 and head_bbox[i, -1] != -1 |
| 232 | for i in range(len(body_bbox))] |
| 233 | ) |
| 234 | self._ignNum = (gt_tag == 0).sum() |
| 235 | self.gtboxes = np.hstack( |
| 236 | (body_bbox[:, :-1], head_bbox[:, :-1], gt_tag.reshape(-1, 1)) |
| 237 | ) |
| 238 | else: |
| 239 | raise Exception('Unknown evaluation mode!') |
| 240 | if not gtflag: |
| 241 | self._dtNum = len(record["dtboxes"]) |
| 242 | if self.eval_mode == 0: |
| 243 | self.dtboxes = self.load_det_boxes(record, 'dtboxes', body_key, 'score') |
| 244 | elif self.eval_mode == 1: |
| 245 | self.dtboxes = self.load_det_boxes(record, 'dtboxes', head_key, 'score') |
| 246 | elif self.eval_mode == 2: |
| 247 | body_dtboxes = self.load_det_boxes(record, 'dtboxes', body_key) |
| 248 | head_dtboxes = self.load_det_boxes(record, 'dtboxes', head_key, 'score') |
| 249 | self.dtboxes = np.hstack((body_dtboxes, head_dtboxes)) |
| 250 | else: |
| 251 | raise Exception('Unknown evaluation mode!') |
| 252 | |
| 253 | def compare_caltech(self, thres): |
| 254 | """ |
no test coverage detected