How to use the dataset.action function in dataset

To help you get started, we’ve selected a few dataset examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github analysiscenter / batchflow / examples / simple_but_ugly / batch_complex.py View on Github external
    @action
    @inbatch_parallel('indices')
    def other(self, ix):
        item = self[ix]
        print()
        print("item", ix)
        print("    ", type(item))
        print("image")
        print("     len: ", len(item.images)) #, item.image_no)
github analysiscenter / batchflow / examples / simple_but_ugly / merge.py View on Github external
    @action
    @inbatch_parallel('indices', target='for')
    def other(self, ix):
        item = self[ix]
        pos = self.get_pos(None, 'images', ix)
        print("other:", ix, pos, type(item), item.images.ndim)
github analysiscenter / batchflow / examples / simple_but_ugly / comp_simple.py View on Github external
    @action
    def print2(self, txt=None):
        if txt is not None:
            print(txt)
        print(len(self))
        for i in self:
            print(i)
        print("--------------------")
        return self
github analysiscenter / batchflow / examples / simple_but_ugly / pipeline_operations.py View on Github external
    @action
    def action2(self):
        """ action2 """
        print("  action 2", self.indices)
        return self
github analysiscenter / batchflow / examples / utils / noisedbatch.py View on Github external
    @action
    def normalize_images(self):
        """Normalize pixel values to (0, 1)."""
        self.images = self.images / 255.
        return self
github analysiscenter / batchflow / examples / simple_but_ugly / batch_complex.py View on Github external
    @action
    @inbatch_parallel('items', target='for')
    def some(self, item):
        print("some:", type(item), "len:", len(item.images)) #, item.corners, item.shapes)
github analysiscenter / batchflow / examples / simple_but_ugly / batch_complex.py View on Github external
    @action
    @inbatch_parallel('indices')
    def sto(self, ix):
        pos = self.get_pos(None, 'image_no', ix)
        self.images[self.image_no[pos]] = np.diag(np.diag(self.images[self.image_no[pos]]))
github analysiscenter / batchflow / examples / utils / noisedbatch.py View on Github external
    @action
    @inbatch_parallel(init='indices', post='_assemble')
    def add_noise(self, ind):
        """Add noise at MNIST image."""
        if self.images.shape[-1] == 1:
            return np.expand_dims(np.max([self.get(ind, 'images'), self.get(ind, 'noise')], axis=0), axis=-1)
        else:
            return (np.max([self.get(ind, 'images'), self.get(ind, 'noise')], axis=0),)
github analysiscenter / batchflow / examples / simple_but_ugly / image.py View on Github external
    @action
    def print(self):
        print("data len", len(self.data))
        print("images", not self.images is None)
        print("masks", not self.masks is None)
        print("shape:", "No" if self.images is None else self.images.shape)
        #print(np.all(self.images[0] == self[self.indices[0]].images))
        #print(np.all(self.data.images[0] == self[self.indices[0]].images))
        #print(self.images[0])
        return self