Sf base
Subfunction_Base
¤
Bases: ABC
An abstract base class for a Subfunction class.
A child of this ABC can be used as a Subfunction and be passed to a DataGenerator.
This class provides functionality for running the transform function, which preprocesses an image during the processing (batch preparation) of the DataGenerator.
Create a custom Subfunction
from aucmedi.data_processing.subfunctions.sf_base import Subfunction_Base
class My_custom_Subfunction(Subfunction_Base):
def __init__(self): # you can pass here class variables
pass
def transform(self, image):
new_image = image + 1.0 # do some operation
return new_image # return modified image
Required Functions
Function | Description |
---|---|
__init__() |
Object creation function. |
transform() |
Transform the image. |
Source code in aucmedi/data_processing/subfunctions/sf_base.py
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 |
|
__init__()
abstractmethod
¤
Functions which will be called during the Subfunction object creation.
This function can be used to pass variables and options in the Subfunction instance. The are no mandatory required parameters for the initialization.
Source code in aucmedi/data_processing/subfunctions/sf_base.py
60 61 62 63 64 65 66 67 |
|
transform(image)
abstractmethod
¤
Transform the image according to the subfunction during preprocessing (training + prediction).
It is required to return the transformed image object (as NumPy array).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image |
numpy.ndarray
|
Image encoded as NumPy matrix with 1 or 3 channels. (e.g. 224x224x3) |
required |
Returns:
Name | Type | Description |
---|---|---|
image |
numpy.ndarray
|
Transformed image encoded as NumPy matrix with 1 or 3 channels. (e.g. 224x224x3) |
Source code in aucmedi/data_processing/subfunctions/sf_base.py
71 72 73 74 75 76 77 78 79 80 81 82 83 |
|