ins_seg/datasets/bdd100k.py
def mask_merge(
    img_name: str,
    scores: List[float],
    segms: List[np.ndarray],  # type: ignore
    colors: List[List[int]],
    bitmask_base: str,
) -> None:
    """Merge masks into a bitmask png file."""
    bitmask = np.zeros((*SHAPE, 4), dtype=np.uint8)
    sorted_idxs = np.argsort(scores)
    for idx in sorted_idxs:
        mask = mask_utils.decode(segms[idx])
        for i in range(4):
            bitmask[..., i] = (
                bitmask[..., i] * (1 - mask) + mask * colors[idx][i]
            )
    bitmask_path = osp.join(bitmask_base, img_name.replace(".jpg", ".png"))
    bitmask_dir = osp.split(bitmask_path)[0]
    if not osp.exists(bitmask_dir):
        os.makedirs(bitmask_dir)
    bitmask_pil = Image.fromarray(bitmask)
    bitmask_pil.save(bitmask_path)
Merge masks into a bitmask png file.
Merge masks into a bitmask png file.
Merge masks into a bitmask png file .
def mask_merge(
    img_name: str,
    scores: List[float],
    segms: List[np.ndarray],  
    colors: List[List[int]],
    bitmask_base: str,
) -> None:
    bitmask = np.zeros((*SHAPE, 4), dtype=np.uint8)
    sorted_idxs = np.argsort(scores)
    for idx in sorted_idxs:
        mask = mask_utils.decode(segms[idx])
        for i in range(4):
            bitmask[..., i] = (
                bitmask[..., i] * (1 - mask) + mask * colors[idx][i]
            )
    bitmask_path = osp.join(bitmask_base, img_name.replace(".jpg", ".png"))
    bitmask_dir = osp.split(bitmask_path)[0]
    if not osp.exists(bitmask_dir):
        os.makedirs(bitmask_dir)
    bitmask_pil = Image.fromarray(bitmask)
    bitmask_pil.save(bitmask_path)
def mask_merge ( img_name : str , scores : List [ float ] , segms : List [ np . ndarray ] , colors : List [ List [ int ] ] , bitmask_base : str , ) -> None : bitmask = np . zeros ( ( * SHAPE , 4 ) , dtype = np . uint8 ) sorted_idxs = np . argsort ( scores ) for idx in sorted_idxs : mask = mask_utils . decode ( segms [ idx ] ) for i in range ( 4 ) : bitmask [ ... , i ] = ( bitmask [ ... , i ] * ( 1 - mask ) + mask * colors [ idx ] [ i ] ) bitmask_path = osp . join ( bitmask_base , img_name . replace ( ".jpg" , ".png" ) ) bitmask_dir = osp . split ( bitmask_path ) [ 0 ] if not osp . exists ( bitmask_dir ) : os . makedirs ( bitmask_dir ) bitmask_pil = Image . fromarray ( bitmask ) bitmask_pil . save ( bitmask_path )
Merge masks into a bitmask png file.
Merge masks into a bitmask png file .
# type: ignore """Merge masks into a bitmask png file."""
img_name
str
scores
List[float]
segms
List[np.ndarray]
colors
List[List[int]]
bitmask_base
str