Skip to content
Snippets Groups Projects

Refactoring of arbiter to add flexibility and to allow reuse kernels

Merged Egor Sobolev requested to merge feat/multi-kernels-in-arbiter into master
Files
10
@@ -12,7 +12,7 @@ class BooleanCombination(BaseArbiterKernel):
(
OVERWRITE_ELEMENT(schema)
.key(prefix)
.description(
.setNewDescription(
"This kernel allows combining individual masks from many sources. It "
"is intended for cases where, for example, each correction device via "
"some addon provides its own frame mask. This arbiter kernel would "
@@ -39,16 +39,17 @@ class BooleanCombination(BaseArbiterKernel):
def consider(self, train_id, sources, num_frames, mask, out_hash):
# pretty sure this is special case of reduce and threshold in some algebra
# TODO: use mask
res = np.zeros(num_frames, dtype=bool)
mask = mask.astype(bool, copy=False)
sources_with_key = [
data[self._key] for (data, _) in sources.values() if data.has(self._key)
data[self._key][mask]
for (data, _) in sources.values()
if data.has(self._key)
]
if not sources_with_key:
raise KeyError(f"No sources had '{self._key}'")
return self._operator(
sources_with_key,
axis=0,
).astype(np.uint8, copy=False)
res[mask] = self._operator(sources_with_key, axis=0)
return res
def reconfigure(self, config):
if config.has("key"):
Loading