INNER CODE UNIT · Python
read_image
towhee-io/examples · image/image_animation/utils.py:20
def read_image(file: BytesIO) -> np.ndarray:
'''
Reads the image received in byte format
and convert into PIL.Image format
Args:
- file (BytesIO): Receives a byte stream of file
Returns:
- (PIL.Image): A PIL Image object translated from byte stream
'''
image = Image.open(BytesIO(file))
return image
def translate_image(input_img: Image, model: str) -> np.ndarray:
'''
Convert the input PIL based on provided model