Hi, I want to load an image that is saved in a binary file and implement myself the loading part. So instead of define_graph having for example: FileReader, ImageDecoder, op, I will have loading of the file to numpy (for example numpy.fromfile) and then the op.
Is such thing possible?
example:
def define_graph(self):
numpy.fromfile(self.image_path, dtype=float32).reshape(100,100,3,1)
images = self.crop_mirror_normalize_0(images)
Thanks,
Vert
Hi,
You can use NumpyReader operator, ExternalSource or implement a custom operator in Python.
Hi,
You can use NumpyReader operator, ExternalSource or implement a custom operator in Python.
ExternalSource works perfectly. Thanks.
I created a base class to be subclassed and ops can be added.
here's the code:
class PipeLineExternalSource(Pipeline, ABC):
def __init__(self, batch_size, num_threads, device_id,
data: Iterable[np.ndarray], layout='HWC'):
"""
data is an iterable of batches of data.
So it can be an iterator that returns a batch of data every time __next__ is called.
Or it can be a list with one batch of a single image: [np.ndarray] where np.ndarray is of shape ()
"""
super().__init__(batch_size, num_threads, device_id, seed=12)
self.source = ops.ExternalSource(source=data, layout=layout)