utils/dash_utils.py
def merge_preds(polygon_id: str, tile_name: str, savedir: str, config: CfgNode) -> None:
    """Merges subgrid predictions to build an image for whole polygon

    Args:
        polygon_id (str): Id of polygon selected for prediction
        tile_name (str): Name of the tile from the polygon
        savedir (str): Saving directory
        config (CfgNode): App config
    """
    polygon_dir = os.path.join(config.DATA_DIR, str(polygon_id))
    whole_img = cv2.imread(os.path.join(polygon_dir, f"{tile_name}.png"))
    for pred_path in glob.glob(
        os.path.join(polygon_dir, f"{tile_name}", "alphablend", "*.png")
    ):
        parts = os.path.splitext(os.path.split(pred_path)[1])[0].split("_")
        x_min = int(parts[2])
        y_min = int(parts[3])
        x_max = int(parts[4])
        y_max = int(parts[5])
        subgrid = cv2.imread(pred_path)
        whole_img[x_min:x_max, y_min:y_max, :] = subgrid

    cv2.imwrite(savedir, whole_img)
Merges subgrid predictions to build an image for whole polygon

    Args:
        polygon_id (str): Id of polygon selected for prediction
        tile_name (str): Name of the tile from the polygon
        savedir (str): Saving directory
        config (CfgNode): App config
    
Merges subgrid predictions to build an image for whole polygon
Merges subgrid predictions to build an image for whole polygon
def merge_preds(polygon_id: str, tile_name: str, savedir: str, config: CfgNode) -> None:
    polygon_dir = os.path.join(config.DATA_DIR, str(polygon_id))
    whole_img = cv2.imread(os.path.join(polygon_dir, f"{tile_name}.png"))
    for pred_path in glob.glob(
        os.path.join(polygon_dir, f"{tile_name}", "alphablend", "*.png")
    ):
        parts = os.path.splitext(os.path.split(pred_path)[1])[0].split("_")
        x_min = int(parts[2])
        y_min = int(parts[3])
        x_max = int(parts[4])
        y_max = int(parts[5])
        subgrid = cv2.imread(pred_path)
        whole_img[x_min:x_max, y_min:y_max, :] = subgrid
    cv2.imwrite(savedir, whole_img)
def merge_preds ( polygon_id : str , tile_name : str , savedir : str , config : CfgNode ) -> None : polygon_dir = os . path . join ( config . DATA_DIR , str ( polygon_id ) ) whole_img = cv2 . imread ( os . path . join ( polygon_dir , f"{tile_name}.png" ) ) for pred_path in glob . glob ( os . path . join ( polygon_dir , f"{tile_name}" , "alphablend" , "*.png" ) ) : parts = os . path . splitext ( os . path . split ( pred_path ) [ 1 ] ) [ 0 ] . split ( "_" ) x_min = int ( parts [ 2 ] ) y_min = int ( parts [ 3 ] ) x_max = int ( parts [ 4 ] ) y_max = int ( parts [ 5 ] ) subgrid = cv2 . imread ( pred_path ) whole_img [ x_min : x_max , y_min : y_max , : ] = subgrid cv2 . imwrite ( savedir , whole_img )
Merges subgrid predictions to build an image for whole polygon
Merges subgrid predictions to build an image for whole polygon
"""Merges subgrid predictions to build an image for whole polygon

    Args:
        polygon_id (str): Id of polygon selected for prediction
        tile_name (str): Name of the tile from the polygon
        savedir (str): Saving directory
        config (CfgNode): App config
    """
polygon_id
str
Id of polygon selected for prediction
Id of polygon selected for prediction
tile_name
str
Name of the tile from the polygon
Name of the tile from the polygon
savedir
str
None
config
CfgNode
None