Samples
DepthEstimationSample
dataclass
A dataclass representing a single depth estimation sample. Contains input image and depth map.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image |
np.ndarray
|
np.ndarray, Image of [H, W, (C if colorful)] shape. |
required |
depth_map |
np.ndarray
|
Depth map of [H, W] shape. |
required |
Source code in V3_6/src/super_gradients/training/samples/depth_estimation_sample.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
|
DetectionSample
dataclass
A data class describing a single object detection sample that comes from a dataset. It contains both input image and target information to train an object detection 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 |
bboxes_xywh |
Numpy array of [N,4] shape with bounding box of each instance (XYWH) |
required | |
labels |
np.ndarray
|
Numpy array of [N] shape with class label for each instance |
required |
is_crowd |
Optional[np.ndarray]
|
(Optional) Numpy array of [N] shape with is_crowd flag for each instance |
None
|
additional_samples |
Optional[List[DetectionSample]]
|
(Optional) List of additional samples for the same image. |
None
|
Source code in V3_6/src/super_gradients/training/samples/detection_sample.py
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 |
|
filter_by_bbox_area(min_bbox_area)
Remove pose instances that has area of the corresponding bounding box less than a certain threshold. This method operates in-place and modifies the caller.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
min_bbox_area |
Union[int, float]
|
Minimal bounding box area of the pose to keep. |
required |
Returns:
Type | Description |
---|---|
DetectionSample
|
A DetectionSample after filtering (caller instance). |
Source code in V3_6/src/super_gradients/training/samples/detection_sample.py
97 98 99 100 101 102 103 104 105 106 107 108 |
|
filter_by_mask(mask)
Remove boxes & labels with respect to a given mask. This method operates in-place and modifies the caller. If you are implementing a subclass of DetectionSample and adding extra field associated with each bbox instance (Let's say you add a distance property for each bbox 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 |
---|---|
DetectionSample
|
A DetectionSample after filtering (caller instance). |
Source code in V3_6/src/super_gradients/training/samples/detection_sample.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
|
sanitize_sample()
Apply sanity checks on the detection sample, which includes clamping of bounding boxes to image boundaries. This function does not remove instances, but may make them subject for removal later on. This method operates in-place and modifies the caller.
Returns:
Type | Description |
---|---|
DetectionSample
|
A DetectionSample after filtering (caller instance). |
Source code in V3_6/src/super_gradients/training/samples/detection_sample.py
68 69 70 71 72 73 74 75 76 77 78 |
|
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_6/src/super_gradients/training/samples/pose_estimation_sample.py
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 162 |
|
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_6/src/super_gradients/training/samples/pose_estimation_sample.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
|
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_6/src/super_gradients/training/samples/pose_estimation_sample.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
|
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_6/src/super_gradients/training/samples/pose_estimation_sample.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
|
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_6/src/super_gradients/training/samples/pose_estimation_sample.py
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
|
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_6/src/super_gradients/training/samples/pose_estimation_sample.py
117 118 119 120 121 122 123 124 125 126 |
|
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_6/src/super_gradients/training/samples/pose_estimation_sample.py
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 |
|
SegmentationSample
dataclass
A data class describing a single semantic segmentation sample that comes from a dataset. It contains both input image and target segmentation mask to train an semantic segmentation model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image |
Union[np.ndarray, Image]
|
Associated image with sample, in [H,W,C] (or H,W for greyscale) format. |
required |
mask |
Union[np.ndarray, Image]
|
Associated segmentation mask with sample, in [H,W] |
required |
Source code in V3_6/src/super_gradients/training/samples/segmentation_sample.py
11 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 |
|
__init__(image, mask)
Initialize segmentation sample
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image |
Union[np.ndarray, Image]
|
Input image in [H,W,C] format. Can be numpy array or PIL image (in which case it will be converted to numpy array) |
required |
mask |
Union[np.ndarray, Image]
|
Target mask in [H,W] format. Can be numpy array or PIL image (in which case it will be converted to numpy array) |
required |
Source code in V3_6/src/super_gradients/training/samples/segmentation_sample.py
26 27 28 29 30 31 32 33 34 35 36 37 |
|