Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@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)
@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)
@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
@action
def action2(self):
""" action2 """
print(" action 2", self.indices)
return self
@action
def normalize_images(self):
"""Normalize pixel values to (0, 1)."""
self.images = self.images / 255.
return self
@action
@inbatch_parallel('items', target='for')
def some(self, item):
print("some:", type(item), "len:", len(item.images)) #, item.corners, item.shapes)
@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]]))
@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),)
@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
@action
def print(self):
print(self.items)
return self