You need to convert the image to 255 and uint8, and then turn back.
real_image = cv2.cvtColor(real_image,cv2.COLOR_GRAY2RGB)
real_image = cv2.resize(real_image,(256,256))
real_image *= 255
real_image = real_image.astype(np.uint8)
real_image = cv2.applyColorMap(real_image, cv2.COLORMAP_HOT)
real_image = np.asarray(real_image/255, dtype=np.float32)