Samples
PoseEstimationSample
dataclass
A data class describing a single pose estimation sample that comes from a dataset. It contains both input image and target information to train a pose estimation model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image |
Union[np.ndarray, torch.Tensor]
|
Associated image with a sample. Can be in [H,W,C] or [C,H,W] format |
required |
image_layout |
Layout of the image (HWC or CHW) |
required | |
mask |
Union[np.ndarray, torch.Tensor]
|
Target mask in [H,W] format |
required |
joints |
np.ndarray
|
Target joints in [NumInstances, NumJoints, 3] format. Last dimension contains (x,y,visibility) for each joint. |
required |
areas |
Optional[np.ndarray]
|
(Optional) Numpy array of [N] shape with area of each instance. Note this is not a bbox area, but area of the object itself. One may use a heuristic |
required |
bboxes_xywh |
Optional[np.ndarray]
|
(Optional) Numpy array of [N,4] shape with bounding box of each instance (XYWH) |
required |
additional_samples |
Optional[List[PoseEstimationSample]]
|
(Optional) List of additional samples for the same image. |
required |
is_crowd |
Optional[np.ndarray]
|
(Optional) Numpy array of [N] shape with is_crowd flag for each instance |
required |
Source code in V3_5/src/super_gradients/training/samples/pose_estimation_sample.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
|
compute_area_of_joints_bounding_box(joints)
classmethod
Compute area of a bounding box enclosing visible joints for each pose instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
joints |
np.ndarray of [Num Instances, Num Joints, 3] shape (x,y,visibility) |
required |
Returns:
Type | Description |
---|---|
np.ndarray
|
np.ndarray of [Num Instances] shape with box area of the visible joints (zero if all joints are not visible or only one joint is visible) |
Source code in V3_5/src/super_gradients/training/samples/pose_estimation_sample.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
|
filter_by_bbox_area(min_bbox_area)
Remove pose instances that has area of the corresponding bounding box less than a certain threshold.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sample |
Instance of PoseEstimationSample to modify. Modification done in-place. |
required | |
min_bbox_area |
Union[int, float]
|
Minimal bounding box area of the pose to keep. |
required |
Returns:
Type | Description |
---|---|
PoseEstimationSample
|
A pose sample after filtering. |
Source code in V3_5/src/super_gradients/training/samples/pose_estimation_sample.py
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
|
filter_by_mask(mask)
Remove pose instances with respect to given mask.
:remark: This is main method to modify instances of the sample. If you are implementing a subclass of PoseEstimationSample and adding extra field associated with each pose instance (Let's say you add a distance property for each pose from the camera), then you should override this method to do filtering on extra attribute as well.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mask |
np.ndarray
|
A boolean or integer mask of samples to keep for given sample. |
required |
Returns:
Type | Description |
---|---|
PoseEstimationSample
|
A pose sample after filtering. |
Source code in V3_5/src/super_gradients/training/samples/pose_estimation_sample.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
|
filter_by_pose_area(min_instance_area)
Remove pose instances which area is less than a certain threshold.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sample |
Instance of PoseEstimationSample to modify. Modification done in-place. |
required | |
min_instance_area |
Union[int, float]
|
Minimal area of the pose to keep. |
required |
Returns:
Type | Description |
---|---|
PoseEstimationSample
|
A pose sample after filtering. |
Source code in V3_5/src/super_gradients/training/samples/pose_estimation_sample.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
|
filter_by_visible_joints(min_visible_joints)
Remove instances from the sample which has less than N visible joints.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
min_visible_joints |
int
|
A minimal number of visible joints a pose has to have in order to be kept. |
required |
Returns:
Type | Description |
---|---|
PoseEstimationSample
|
A pose sample after filtering. |
Source code in V3_5/src/super_gradients/training/samples/pose_estimation_sample.py
116 117 118 119 120 121 122 123 124 125 |
|
sanitize_sample()
Apply sanity checks on the pose sample, which includes: - Clamp bbox coordinates to ensure they are within image boundaries - Update visibility status of keypoints if they are outside of image boundaries - Update area if bbox clipping occurs This function does not remove instances, but may make them subject for removal instead.
Returns:
Type | Description |
---|---|
PoseEstimationSample
|
self |
Source code in V3_5/src/super_gradients/training/samples/pose_estimation_sample.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
|