Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.extension
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bob
bob.extension
Merge requests
!59
Add stacked processors
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Add stacked processors
processors
into
master
Overview
0
Commits
1
Pipelines
1
Changes
6
Merged
Amir MOHAMMADI
requested to merge
processors
into
master
7 years ago
Overview
0
Commits
1
Pipelines
1
Changes
6
Expand
0
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
8fe1ee73
1 commit,
7 years ago
6 files
+
198
−
6
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
6
Search (e.g. *.vue) (Ctrl+P)
bob/extension/processors.py
0 → 100644
+
87
−
0
Options
class
SequentialProcessor
(
object
):
"""
A helper class which takes several processors and applies them one by
one on data sequentially. See :ref:`bob.extension.processors` for more
details.
Attributes
----------
processors : list
A list of processors to apply.
"""
def
__init__
(
self
,
processors
,
**
kwargs
):
"""
Initialization
Parameters
----------
processors : :py:class:`list`
A list of preprocessors to be used.
**kwargs
Any kwargs are passed to the parent class.
"""
super
(
SequentialProcessor
,
self
).
__init__
(
**
kwargs
)
self
.
processors
=
processors
def
__call__
(
self
,
data
,
**
kwargs
):
"""
Applies the processors on the data sequentially. The output of the
first one goes as input to the next one.
Parameters
----------
data : object
The data that needs to be processed.
**kwargs
Any kwargs are passed to the processors.
Returns
-------
object
The processed data.
"""
for
processor
in
self
.
processors
:
data
=
processor
(
data
,
**
kwargs
)
return
data
class
ParallelProcessor
(
object
):
"""
A helper class which takes several processors and applies data on each
processor separately and yields their outputs one by one. See
:ref:`bob.extension.processors` for more details.
Attributes
----------
processors : list
A list of processors to apply.
"""
def
__init__
(
self
,
processors
,
**
kwargs
):
"""
Initialization
Parameters
----------
processors : :py:class:`list`
A list of preprocessors to be used.
**kwargs
Any kwargs are passed to the parent class.
"""
super
(
ParallelProcessor
,
self
).
__init__
(
**
kwargs
)
self
.
processors
=
processors
def
__call__
(
self
,
data
,
**
kwargs
):
"""
Applies the processors on the data independently and outputs a
generator of their outputs.
Parameters
----------
data : object
The data that needs to be processed.
**kwargs
Any kwargs are passed to the processors.
Yields
------
object
The processed data from processors one by one.
"""
for
processor
in
self
.
processors
:
yield
processor
(
data
,
**
kwargs
)
Loading