You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For prototyping it would be very useful to have a node that applies a user-provided mapping to the voxels of an array for a key/multiple keys (the shape of the data may not change). Is there a node with such functionality in gunpowder?
I currently have a MapNumpyArray node that does exactly that:
classMapNumpyArray(BatchFilter):
def__init__(
self,
mapping,
*keys):
super(BatchFilter, self).__init__()
self.keys=keysself.mapping=mappingdefsetup(self):
passdefprepare(self, request):
passdefprocess(self, batch, request):
forkeyinself.keys:
ifnotkeyinrequest:
logger.debug('Ignoring key %s: not in request %s', key, request)
continueassertkeyinbatch.arrays, 'Requested key %s not in batch arrays %s'% (key, batch)
array=batch.arrays[key]
logger.debug('Array data dtype for key %s before mapping: %s', key, array.data.dtype)
mapped_data=self.mapping(array.data)
assertmapped_data.shape==array.data.shape, 'Mapping must not change shape of data: Original shape is {}, mapped shape is {}'.format(array.data.shape, mapped_data.shape)
array.data=mapped_datalogger.debug('Array data dtype for key %s after mapping: %s', key, batch.arrays[key].data.dtype)
Could this be useful for the broader gunpowder community? If so, I'll file a PR.
The text was updated successfully, but these errors were encountered:
I also have a custom node that does something similar (MapLabels), but in my case found I was able to abuse ExcludeLabels to the same end with only slightly worse performance.
One consideration if you want to PR if that if you change the dtype of the data via mapping, you will need to change the spec in setup, something like (pseudo):
One consideration if you want to PR if that if you change the dtype of the data via mapping, you will need to change the spec in setup, something like (pseudo):
Interesting, that is exactly what I used the node for initially (np.require) but I never thought about changing the output dtype.
For prototyping it would be very useful to have a node that applies a user-provided mapping to the voxels of an array for a key/multiple keys (the shape of the data may not change). Is there a node with such functionality in gunpowder?
I currently have a
MapNumpyArray
node that does exactly that:Could this be useful for the broader gunpowder community? If so, I'll file a PR.
The text was updated successfully, but these errors were encountered: