Processing
AutoPadding
Bases: Processing
, ABC
Source code in V3_5/src/super_gradients/training/processing/processing.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
|
__init__(shape_multiple, pad_value)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
shape_multiple |
Tuple[int, int]
|
Tuple of (H, W) indicating the height and width multiples to which the input image dimensions will be padded. For instance, with a value of (32, 40), an input image of size (45, 67) will be padded to (64, 80). |
required |
pad_value |
int
|
Value to pad the image with. |
required |
Source code in V3_5/src/super_gradients/training/processing/processing.py
98 99 100 101 102 103 104 105 |
|
CenterCrop
Bases: ClassificationProcess
Parameters:
Name | Type | Description | Default |
---|---|---|---|
size |
int
|
Desired output size of the crop. |
224
|
Source code in V3_5/src/super_gradients/training/processing/processing.py
628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 |
|
infer_image_input_shape()
Infer the output image shape from the processing.
Returns:
Type | Description |
---|---|
Optional[Tuple[int, int]]
|
(rows, cols) Returns the last known output shape for all the processings. |
Source code in V3_5/src/super_gradients/training/processing/processing.py
658 659 660 661 662 663 664 |
|
preprocess_image(image)
Crops the given image at the center.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image |
np.ndarray
|
Image, in (H, W, C) format. |
required |
Returns:
Type | Description |
---|---|
Tuple[np.ndarray, None]
|
The center cropped image. |
Source code in V3_5/src/super_gradients/training/processing/processing.py
638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 |
|
ComposeProcessing
Bases: Processing
Compose a list of Processing objects into a single Processing object.
Source code in V3_5/src/super_gradients/training/processing/processing.py
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 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
|
__init__(processings)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
processings |
List[Processing]
|
List of Processing objects to compose. |
required |
Source code in V3_5/src/super_gradients/training/processing/processing.py
120 121 122 123 124 |
|
get_equivalent_compose_without_resizing(auto_padding)
Get a composed processing equivalent to this one, but without resizing the image.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
auto_padding |
AutoPadding
|
AutoPadding object to use for padding the image. This is required since models often expect input image to be a multiple of a specific shape (usually 32x32). This padding operation will be applied on the input image before any other processing. |
required |
Returns:
Type | Description |
---|---|
ComposeProcessing
|
A composed processing equivalent to this one, but without resizing the image. |
Source code in V3_5/src/super_gradients/training/processing/processing.py
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
|
infer_image_input_shape()
Infer the output image shape from the processing.
Returns:
Type | Description |
---|---|
Optional[Tuple[int, int]]
|
(rows, cols) Returns the last known output shape for all the processings. |
Source code in V3_5/src/super_gradients/training/processing/processing.py
150 151 152 153 154 155 156 157 158 159 160 161 162 |
|
postprocess_predictions(predictions, metadata)
Postprocess the model output predictions.
Source code in V3_5/src/super_gradients/training/processing/processing.py
134 135 136 137 138 139 |
|
preprocess_image(image)
Processing an image, before feeding it to the network.
Source code in V3_5/src/super_gradients/training/processing/processing.py
126 127 128 129 130 131 132 |
|
ImagePermute
Bases: Processing
Permute the image dimensions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
permutation |
Tuple[int, int, int]
|
Specify new order of dims. Default value (2, 0, 1) suitable for converting from HWC to CHW format. |
(2, 0, 1)
|
Source code in V3_5/src/super_gradients/training/processing/processing.py
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
|
NormalizeImage
Bases: Processing
Normalize an image based on means and standard deviation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mean |
List[float]
|
Mean values for each channel. |
required |
std |
List[float]
|
Standard deviation values for each channel. |
required |
Source code in V3_5/src/super_gradients/training/processing/processing.py
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 |
|
Processing
Bases: ABC
Interface for preprocessing and postprocessing methods that are used to prepare images for a model and process the model's output.
Subclasses should implement the preprocess_image
and postprocess_predictions
methods according to the specific requirements of the model and task.
Source code in V3_5/src/super_gradients/training/processing/processing.py
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 |
|
resizes_image: bool
abstractmethod
property
Return True if the processing resizes the image, False otherwise.
get_equivalent_photometric_module()
abstractmethod
Get the equivalent photometric preprocessing module for this processing. A photometric preprocessing apply a transformation to the image pixels, without changing the image size. This includes RGB -> BGR, standardization, normalization etc. If a Processing subclass does not have change pixel values, it should return an nn.Identity module. If a Processing subclass does not have an equivalent photometric preprocessing, it should return None.
Returns:
Type | Description |
---|---|
Optional[nn.Module]
|
Source code in V3_5/src/super_gradients/training/processing/processing.py
69 70 71 72 73 74 75 76 77 78 79 |
|
infer_image_input_shape()
Infer the shape (rows, cols) of the image after all the processing steps. This is the effective image size that is fed to model itself
Returns:
Type | Description |
---|---|
Optional[Tuple[int, int]]
|
Return the image shape (rows, cols), or None if the image shape cannot be inferred (When preprocessing contains no resize/padding operations). |
Source code in V3_5/src/super_gradients/training/processing/processing.py
81 82 83 84 85 86 87 88 |
|
postprocess_predictions(predictions, metadata)
abstractmethod
Postprocess the model output predictions.
Source code in V3_5/src/super_gradients/training/processing/processing.py
64 65 66 67 |
|
preprocess_image(image)
abstractmethod
Processing an image, before feeding it to the network. Expected to be in (H, W, C) or (H, W).
Source code in V3_5/src/super_gradients/training/processing/processing.py
59 60 61 62 |
|
ProcessingMetadata
dataclass
Bases: ABC
Metadata including information to postprocess a prediction.
Source code in V3_5/src/super_gradients/training/processing/processing.py
29 30 31 |
|
Resize
Bases: ClassificationProcess
Source code in V3_5/src/super_gradients/training/processing/processing.py
595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 |
|
preprocess_image(image)
Resize an image.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image |
np.ndarray
|
Image, in (H, W, C) format. |
required |
Returns:
Type | Description |
---|---|
Tuple[np.ndarray, None]
|
The resized image. |
Source code in V3_5/src/super_gradients/training/processing/processing.py
601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 |
|
ReverseImageChannels
Bases: Processing
Reverse the order of the image channels (RGB -> BGR or BGR -> RGB).
Source code in V3_5/src/super_gradients/training/processing/processing.py
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 |
|
preprocess_image(image)
Reverse the channel order of an image.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image |
np.ndarray
|
Image, in (H, W, C) format. |
required |
Returns:
Type | Description |
---|---|
Tuple[np.ndarray, None]
|
Image with reversed channel order. (RGB if input was BGR, BGR if input was RGB) |
Source code in V3_5/src/super_gradients/training/processing/processing.py
216 217 218 219 220 221 222 223 224 225 226 227 |
|
StandardizeImage
Bases: Processing
Standardize image pixel values with img/max_val
Parameters:
Name | Type | Description | Default |
---|---|---|---|
max_value |
float
|
Current maximum value of the image pixels. (usually 255) |
255.0
|
Source code in V3_5/src/super_gradients/training/processing/processing.py
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 |
|
preprocess_image(image)
Reverse the channel order of an image.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image |
np.ndarray
|
Image, in (H, W, C) format. |
required |
Returns:
Type | Description |
---|---|
Tuple[np.ndarray, None]
|
Image with reversed channel order. (RGB if input was BGR, BGR if input was RGB) |
Source code in V3_5/src/super_gradients/training/processing/processing.py
253 254 255 256 257 258 259 260 |
|
default_dekr_coco_processing_params()
Processing parameters commonly used for training DEKR on COCO dataset.
Source code in V3_5/src/super_gradients/training/processing/processing.py
740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 |
|
default_imagenet_processing_params()
Processing parameters commonly used for training resnet on Imagenet dataset.
Source code in V3_5/src/super_gradients/training/processing/processing.py
899 900 901 902 903 904 905 906 907 908 |
|
default_ppyoloe_coco_processing_params()
Processing parameters commonly used for training PPYoloE on COCO dataset. TODO: remove once we load it from the checkpoint
Source code in V3_5/src/super_gradients/training/processing/processing.py
694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 |
|
default_vit_imagenet_processing_params()
Processing parameters used by ViT for training resnet on Imagenet dataset.
Source code in V3_5/src/super_gradients/training/processing/processing.py
911 912 913 914 915 916 917 918 919 920 |
|
default_yolo_nas_coco_processing_params()
Processing parameters commonly used for training YoloNAS on COCO dataset. TODO: remove once we load it from the checkpoint
Source code in V3_5/src/super_gradients/training/processing/processing.py
717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 |
|
default_yolox_coco_processing_params()
Processing parameters commonly used for training YoloX on COCO dataset. TODO: remove once we load it from the checkpoint
Source code in V3_5/src/super_gradients/training/processing/processing.py
671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 |
|
get_pretrained_processing_params(model_name, pretrained_weights)
Get the processing parameters for a pretrained model. TODO: remove once we load it from the checkpoint
Source code in V3_5/src/super_gradients/training/processing/processing.py
923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 |
|