def to_pillow(image): return Image.fromarray(image[:, :, ::-1].copy()) # There is another way # img_bytes = cv2.imencode('.png', image)[1].tostring() # return Image.open(BytesIO(img_bytes))