| 323 | return cur_img, targets |
| 324 | |
| 325 | def init_img(self, img): |
| 326 | ori_img = img.copy() |
| 327 | self.seq_h, self.seq_w = img.shape[:2] |
| 328 | scale = self.img_height / min(self.seq_h, self.seq_w) |
| 329 | if max(self.seq_h, self.seq_w) * scale > self.img_width: |
| 330 | scale = self.img_width / max(self.seq_h, self.seq_w) |
| 331 | target_h = int(self.seq_h * scale) |
| 332 | target_w = int(self.seq_w * scale) |
| 333 | img = cv2.resize(img, (target_w, target_h)) |
| 334 | img = F.normalize(F.to_tensor(img), self.mean, self.std) |
| 335 | img = img.unsqueeze(0) |
| 336 | return img, ori_img |
| 337 | |
| 338 | @staticmethod |
| 339 | def filter_dt_by_score(dt_instances: Instances, prob_threshold: float) -> Instances: |