tool/video_completion.py
def edge_completion(args, EdgeGenerator, corrFlow, flow_mask, mode):
    """Calculate flow edge and complete it.
    """

    if mode not in ['forward', 'backward']:
        raise NotImplementedError

    imgH, imgW, _, nFrame = corrFlow.shape
    Edge = np.empty(((imgH, imgW, 0)), dtype=np.float32)

    for i in range(nFrame):
        print("Completing {0} flow edge {1:2d} <---> {2:2d}".format(mode, i, i + 1), '\r', end='')
        flow_mask_img = flow_mask[:, :, i] if mode == 'forward' else flow_mask[:, :, i + 1]

        flow_img_gray = (corrFlow[:, :, 0, i] ** 2 + corrFlow[:, :, 1, i] ** 2) ** 0.5
        flow_img_gray = flow_img_gray / flow_img_gray.max()

        edge_corr = canny(flow_img_gray, sigma=2, mask=(1 - flow_mask_img).astype(bool))
        edge_completed = infer(args, EdgeGenerator, torch.device(DEVICE), flow_img_gray, edge_corr, flow_mask_img)
        Edge = np.concatenate((Edge, edge_completed[..., None]), axis=-1)

    return Edge
Calculate flow edge and complete it.
    
Calculate flow edge and complete it.
Calculate flow edge and complete it .
def edge_completion(args, EdgeGenerator, corrFlow, flow_mask, mode):
    if mode not in ['forward', 'backward']:
        raise NotImplementedError
    imgH, imgW, _, nFrame = corrFlow.shape
    Edge = np.empty(((imgH, imgW, 0)), dtype=np.float32)
    for i in range(nFrame):
        print("Completing {0} flow edge {1:2d} <---> {2:2d}".format(mode, i, i + 1), '\r', end='')
        flow_mask_img = flow_mask[:, :, i] if mode == 'forward' else flow_mask[:, :, i + 1]
        flow_img_gray = (corrFlow[:, :, 0, i] ** 2 + corrFlow[:, :, 1, i] ** 2) ** 0.5
        flow_img_gray = flow_img_gray / flow_img_gray.max()
        edge_corr = canny(flow_img_gray, sigma=2, mask=(1 - flow_mask_img).astype(bool))
        edge_completed = infer(args, EdgeGenerator, torch.device(DEVICE), flow_img_gray, edge_corr, flow_mask_img)
        Edge = np.concatenate((Edge, edge_completed[..., None]), axis=-1)
    return Edge
def edge_completion ( args , EdgeGenerator , corrFlow , flow_mask , mode ) : if mode not in [ 'forward' , 'backward' ] : raise NotImplementedError imgH , imgW , _ , nFrame = corrFlow . shape Edge = np . empty ( ( ( imgH , imgW , 0 ) ) , dtype = np . float32 ) for i in range ( nFrame ) : print ( "Completing {0} flow edge {1:2d} <---> {2:2d}" . format ( mode , i , i + 1 ) , '\r' , end = '' ) flow_mask_img = flow_mask [ : , : , i ] if mode == 'forward' else flow_mask [ : , : , i + 1 ] flow_img_gray = ( corrFlow [ : , : , 0 , i ] ** 2 + corrFlow [ : , : , 1 , i ] ** 2 ) ** 0.5 flow_img_gray = flow_img_gray / flow_img_gray . max ( ) edge_corr = canny ( flow_img_gray , sigma = 2 , mask = ( 1 - flow_mask_img ) . astype ( bool ) ) edge_completed = infer ( args , EdgeGenerator , torch . device ( DEVICE ) , flow_img_gray , edge_corr , flow_mask_img ) Edge = np . concatenate ( ( Edge , edge_completed [ ... , None ] ) , axis = - 1 ) return Edge
Calculate flow edge and complete it.
Calculate flow edge and complete it .
"""Calculate flow edge and complete it.
    """
args
EdgeGenerator
corrFlow
flow_mask
mode