INNER CODE UNIT · Python

translate_image

towhee-io/examples · image/image_animation/utils.py:35

def translate_image(input_img: Image, model: str) -> np.ndarray:
    '''
    Convert the input PIL based on provided model
    using anime gan towhee pipeline.

    Args:
    - input_img (PIL.Image): PIL.Image object
    - model (str): Model to be run on image

    Returns:
    - (PIL.Image): Returns a PIL Image object corresponding to translated image (RGB format)
    '''
    output_img = towhee.ops.img2img_translation.animegan(model_name = model)(input_img)
    out = np.array(output_img)
    out_rgb = cv2.cvtColor(out, cv2.COLOR_BGR2RGB)
    output = Image.fromarray(out_rgb)
    
    return output

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…