Processor
Processor class
paz.abstract.processor.Processor(name=None)
Abstract class for creating a processor unit.
Arguments
- name: String indicating name of the processing unit.
Methods
call()
Example
class NormalizeImage(Processor):
def __init__(self):
super(NormalizeImage, self).__init__()
def call(self, image):
return image / 255.0
Why this name?
Originally PAZ was only meant for pre-processing pipelines that
included data-augmentation, normalization, etc. However, I found
out that we could use the same API for post-processing; therefore,
I thought at the time that Processor
would be adequate to describe
the capacity of both pre-processing and post-processing.
Names that I also thought could have worked were: Function
,
Functor
but I didn't want to use those since I thought they could
also cause confusion. Similarly, in Keras this abstraction is
interpreted as a Layer
but here I don't think that abstraction
is adequate. A layer of computation maybe? So after having this
thoughts swirling around I decided to go with Processor
and try to be explicit about my mental jugglery hoping the name
doesn't cause much mental overhead.
Processor methods
call
call(X)
Custom user's logic should be implemented here.
SequentialProcessor class
paz.abstract.processor.SequentialProcessor(processors=None, name=None)
Abstract class for creating a sequential pipeline of processors.
Arguments
- processors: List of instantiated child classes of
Processor
classes. - name: String indicating name of the processing unit.
Methods
add() remove() pop() insert() get_processor()
Example
AugmentImage = SequentialProcessor()
AugmentImage.add(pr.RandomContrast())
AugmentImage.add(pr.RandomBrightness())
augment_image = AugmentImage()
transformed_image = augment_image(image)
SequentialProcessor methods
add
add(processor)
Adds a process to the sequence of processes to be applied to input.
Arguments
- processor: An instantiated child class of
Processor
.
remove
remove(name)
Removes processor from sequence
Arguments
- name: String indicating the process name
pop
pop(index=-1)
Pops processor in given index from sequence
Arguments
- index: Int.
insert
insert(index, processor)
Inserts processor
to self.processors queue at index
Argument
- index: Int.
- processor: An instantiated child class of of
Processor
.
get_processor
get_processor(name)
Gets processor from sequencer
Arguments
- name: String indicating the process name