- paddle.vision.ops. read_file ( filename, name=None )
Reads and outputs the bytes contents of a file as a uint8 Tensor with one dimension.
filename (str) – Path of the file to be read.
name (str, optional) – The default value is None. Normally there is no need for user to set this property. For more information, please refer to Name.
A uint8 tensor.
import cv2 import paddle fake_img = (np.random.random( (400, 300, 3)) * 255).astype('uint8') cv2.imwrite('fake.jpg', fake_img) img_bytes = paddle.vision.ops.read_file('fake.jpg') print(img_bytes.shape)