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)

  

posted on 2019-01-10 17:39  cdekelon  阅读(159)  评论(0)    收藏  举报

导航