Create a superset of inputs needed to run test or train batches. Args: input_shape (tuple): input batch dimensions num_items (None | List[int]): specifies the number of boxes in each batch item num_classes (int): number of different
(
input_shape=(1, 3, 300, 300),
num_items=None,
num_classes=10,
with_track=False)
| 45 | |
| 46 | |
| 47 | def _demo_mm_inputs( |
| 48 | input_shape=(1, 3, 300, 300), |
| 49 | num_items=None, |
| 50 | num_classes=10, |
| 51 | with_track=False): |
| 52 | """Create a superset of inputs needed to run test or train batches. |
| 53 | |
| 54 | Args: |
| 55 | input_shape (tuple): |
| 56 | input batch dimensions |
| 57 | |
| 58 | num_items (None | List[int]): |
| 59 | specifies the number of boxes in each batch item |
| 60 | |
| 61 | num_classes (int): |
| 62 | number of different labels a box might have |
| 63 | """ |
| 64 | from mmdet.core import BitmapMasks |
| 65 | |
| 66 | (N, C, H, W) = input_shape |
| 67 | |
| 68 | rng = np.random.RandomState(0) |
| 69 | |
| 70 | imgs = rng.rand(*input_shape) |
| 71 | |
| 72 | img_metas = [{ |
| 73 | 'img_shape': (H, W, C), |
| 74 | 'ori_shape': (H, W, C), |
| 75 | 'pad_shape': (H, W, C), |
| 76 | 'filename': '<demo>.png', |
| 77 | 'scale_factor': 1.0, |
| 78 | 'flip': False, |
| 79 | 'frame_id': 0, |
| 80 | 'img_norm_cfg': { |
| 81 | 'mean': (128.0, 128.0, 128.0), |
| 82 | 'std': (10.0, 10.0, 10.0) |
| 83 | } |
| 84 | } for i in range(N)] |
| 85 | |
| 86 | gt_bboxes = [] |
| 87 | gt_labels = [] |
| 88 | gt_masks = [] |
| 89 | gt_instance_ids = [] |
| 90 | |
| 91 | for batch_idx in range(N): |
| 92 | if num_items is None: |
| 93 | num_boxes = rng.randint(1, 10) |
| 94 | else: |
| 95 | num_boxes = num_items[batch_idx] |
| 96 | |
| 97 | cx, cy, bw, bh = rng.rand(num_boxes, 4).T |
| 98 | |
| 99 | tl_x = ((cx * W) - (W * bw / 2)).clip(0, W) |
| 100 | tl_y = ((cy * H) - (H * bh / 2)).clip(0, H) |
| 101 | br_x = ((cx * W) + (W * bw / 2)).clip(0, W) |
| 102 | br_y = ((cy * H) + (H * bh / 2)).clip(0, H) |
| 103 | |
| 104 | boxes = np.vstack([tl_x, tl_y, br_x, br_y]).T |
no outgoing calls