Convert fp16 to jpg
import cv2
import numpy as np
height = 64 # Height of the model input images
width = 64 # Width of the model input images
image_file = "5938dde6f51cd200a32e7608.fp16"
image = np.fromfile(image_file, dtype=np.float16)
image = np.reshape(image, [3,height,width]).astype(np.float32)
image = image*255.0
image = np.transpose(image, (1,2,0)) #above reshape into CHW, so need to transpose back to HWC. Otherwise, the image is wrong.
cv2.imwrite('t.jpg', image)
浙公网安备 33010602011771号