def get_id_photo_output(image, text):
    """
    Get the special size and background photo.

    Args:
        img(numpy:ndarray): The image array.
        size(str): The size user specified.
        bg(str): The background color user specified.
        download_size(str): The size for image saving.

    """
    image_ori = image.copy()
    image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
    masks = mask_generator.generate(image)
    pred_result, pseudo_map = masks2pseudomap(masks)  # PIL Image
    added_pseudo_map = visualize(
        image, pred_result, color_map=get_color_map_list(256))
    cropped_objects = []
    image_pil = Image.fromarray(image)
    for mask in masks:
        bbox = [
            mask["bbox"][0], mask["bbox"][1], mask["bbox"][0] + mask["bbox"][2],
            mask["bbox"][1] + mask["bbox"][3]
        ]
        cropped_objects.append(
            segment_image(image_pil, mask["segmentation"]).crop(bbox))

    scores = image_text_match(cropped_objects, str(text))
    text_matching_masks = []
    for idx, score in enumerate(scores):
        if score < 0.05:
            continue
        text_matching_mask = Image.fromarray(
            masks[idx]["segmentation"].astype('uint8') * 255)
        text_matching_masks.append(text_matching_mask)

    image_pil_ori = Image.fromarray(image_ori)
    alpha_image = Image.new('RGBA', image_pil_ori.size, (0, 0, 0, 0))
    alpha_color = (255, 0, 0, 180)

    draw = ImageDraw.Draw(alpha_image)
    for text_matching_mask in text_matching_masks:
        draw.bitmap((0, 0), text_matching_mask, fill=alpha_color)

    result_image = Image.alpha_composite(
        image_pil_ori.convert('RGBA'), alpha_image)
    res_download = download(result_image)
    return result_image, added_pseudo_map, res_download

    Get the special size and background photo.

    Args:
        img(numpy:ndarray): The image array.
        size(str): The size user specified.
        bg(str): The background color user specified.
        download_size(str): The size for image saving.

    
contrib/SegmentAnything/scripts/text_to_sam_clip.py