Processing
CenterCrop
Bases: ClassificationProcess
Parameters:
Name | Type | Description | Default |
---|---|---|---|
size |
int
|
Desired output size of the crop. |
224
|
Source code in latest/src/super_gradients/training/processing/processing.py
455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 |
|
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 latest/src/super_gradients/training/processing/processing.py
485 486 487 488 489 490 491 |
|
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 latest/src/super_gradients/training/processing/processing.py
465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 |
|
ComposeProcessing
Bases: Processing
Compose a list of Processing objects into a single Processing object.
Source code in latest/src/super_gradients/training/processing/processing.py
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 |
|
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 latest/src/super_gradients/training/processing/processing.py
119 120 121 122 123 124 125 126 127 128 129 130 131 |
|
postprocess_predictions(predictions, metadata)
Postprocess the model output predictions.
Source code in latest/src/super_gradients/training/processing/processing.py
103 104 105 106 107 108 |
|
preprocess_image(image)
Processing an image, before feeding it to the network.
Source code in latest/src/super_gradients/training/processing/processing.py
95 96 97 98 99 100 101 |
|
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 latest/src/super_gradients/training/processing/processing.py
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
|
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 latest/src/super_gradients/training/processing/processing.py
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
|
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 latest/src/super_gradients/training/processing/processing.py
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 |
|
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 latest/src/super_gradients/training/processing/processing.py
66 67 68 69 70 71 72 73 74 75 76 |
|
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 latest/src/super_gradients/training/processing/processing.py
78 79 80 81 82 83 84 85 |
|
postprocess_predictions(predictions, metadata)
abstractmethod
Postprocess the model output predictions.
Source code in latest/src/super_gradients/training/processing/processing.py
61 62 63 64 |
|
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 latest/src/super_gradients/training/processing/processing.py
56 57 58 59 |
|
ProcessingMetadata
dataclass
Bases: ABC
Metadata including information to postprocess a prediction.
Source code in latest/src/super_gradients/training/processing/processing.py
26 27 28 |
|
Resize
Bases: ClassificationProcess
Source code in latest/src/super_gradients/training/processing/processing.py
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 |
|
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 latest/src/super_gradients/training/processing/processing.py
446 447 448 449 450 451 452 |
|
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 latest/src/super_gradients/training/processing/processing.py
431 432 433 434 435 436 437 438 439 440 441 |
|
ReverseImageChannels
Bases: Processing
Reverse the order of the image channels (RGB -> BGR or BGR -> RGB).
Source code in latest/src/super_gradients/training/processing/processing.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
|
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 latest/src/super_gradients/training/processing/processing.py
159 160 161 162 163 164 165 166 167 168 169 170 |
|
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 latest/src/super_gradients/training/processing/processing.py
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
|
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 latest/src/super_gradients/training/processing/processing.py
192 193 194 195 196 197 198 199 |
|
default_dekr_coco_processing_params()
Processing parameters commonly used for training DEKR on COCO dataset.
Source code in latest/src/super_gradients/training/processing/processing.py
563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 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 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 |
|
default_imagenet_processing_params()
Processing parameters commonly used for training resnet on Imagenet dataset.
Source code in latest/src/super_gradients/training/processing/processing.py
644 645 646 647 648 649 650 651 652 653 |
|
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 latest/src/super_gradients/training/processing/processing.py
517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 |
|
default_vit_imagenet_processing_params()
Processing parameters used by ViT for training resnet on Imagenet dataset.
Source code in latest/src/super_gradients/training/processing/processing.py
656 657 658 659 660 661 662 663 664 665 |
|
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 latest/src/super_gradients/training/processing/processing.py
540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 |
|
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 latest/src/super_gradients/training/processing/processing.py
494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 |
|
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 latest/src/super_gradients/training/processing/processing.py
668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 |
|