Computer Vision
- class towhee.hub.builtin.operators.computer_vision.image_load
load image from paths, file objects or memory blocks.
- Returns
output image
- Return type
ndarray
Examples:
>>> from towhee.hub import preclude >>> from towhee.functional import DataCollection >>> dc = ( ... DataCollection.range(5) ... .tensor_random(shape=[100, 100, 3]) ... .image_dump() ... ).to_list()
>>> ( ... DataCollection(dc).image_load() ... .map(lambda x: x.shape) ... ).to_list() [(100, 100, 3), (100, 100, 3), (100, 100, 3), (100, 100, 3), (100, 100, 3)]
- class towhee.hub.builtin.operators.computer_vision.image_dump(ext='.JPEG')[source]
dump image to a binary buffer.
- class towhee.hub.builtin.operators.computer_vision.image_resize(dsize=None, fx=None, fy=None, interpolation=None)[source]
resize an image.
- Parameters
dsize ((int, int), optional) – target image size. Defaults to None.
fx (float, optional) – scale factor for x axis. Defaults to None.
fy (float, optional) – scale factor for y axis. Defaults to None.
interpolation (str|int, optional) – interpolation method, see detailed document for cv2.resize. Defaults to None.
- Returns
output image.
- Return type
ndarray
Examples:
>>> from towhee.functional import DataCollection >>> dc = ( ... DataCollection.range(5) ... .tensor_random(shape=[100, 100, 3]) ... .image_resize(dsize=[10, 10], interpolation='nearest') ... ) >>> dc.select['shape']().as_raw().to_list() [(10, 10, 3), (10, 10, 3), (10, 10, 3), (10, 10, 3), (10, 10, 3)]
- class towhee.hub.builtin.operators.computer_vision.image_convert_color(code)[source]
convert image color space.
- Parameters
code (str|int) – color space conversion string or code
- Returns
output image.
- Return type
ndarray
Examples:
>>> from towhee.functional import DataCollection >>> import numpy as np >>> ( ... DataCollection([np.ones([1,1, 3], dtype=np.uint8)]) ... .image_convert_color(code='rgb2gray') ... .to_list() ... ) [array([[1]], dtype=uint8)]
- class towhee.hub.builtin.operators.computer_vision.image_filter(ddepth, kernel)[source]
image filter.
- class towhee.hub.builtin.operators.computer_vision.image_blur(ksize)[source]
image blur.
- Parameters
ksize ([int]) – kernel size, for example: [3, 3].
- Returns
output image
- Return type
ndarray
>>> from towhee.functional import DataCollection >>> import numpy as np >>> ( ... DataCollection([np.ones([5,5], dtype=np.uint8)]) ... .image_blur(ksize=[3,3]) ... .to_list() ... ) [array([[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]], dtype=uint8)]