load.py
def debug_time_step(t, epidx, obs, act, extras, goal=None):
    """Save images and other stuff from time `t` in episode `epidx`."""
    pth = 'tmp'
    tt = str(t).zfill(2)

    # Convert from BGR to RGB to match what we see in the GUI.
    def save(fname, c_img):
        cv2.imwrite(fname, img=cv2.cvtColor(c_img, cv2.COLOR_BGR2RGB))

    # Save current color images from camera angles and the fused version.
    for img_idx, c_img in enumerate(obs['color']):
        fname = join(pth, f'ep_{epidx}_t{tt}_cimg_{img_idx}.png')
        save(fname, c_img)
    colormap_o, _ = get_heightmap(obs=obs)
    fname = join(pth, f'ep_{epidx}_t{tt}_cimg_fused.png')
    save(fname, colormap_o)

    # (If applicable) save the goal color images.
    if (goal is not None) and t == 1:
        for img_idx, c_img in enumerate(goal['color']):
            fname = join(pth, f'ep_{epidx}_t{tt}_cimg_{img_idx}_goal.png')
            save(fname, c_img)
        colormap_g, _ = get_heightmap(obs=goal)
        fname = join(pth, f'ep_{epidx}_t{tt}_cimg_fused_goal.png')
        save(fname, colormap_g)

    # Print the action.
    pose0 = act['params']['pose0']
    pose1 = act['params']['pose1']
    print(f"  pose0, pose1: {U.round_pose(pose0)}, {U.round_pose(pose1)}")

    # Attention. (Well, attn_input.png is also input to Transport...)
    fname1 = join(pth, f'ep_{epidx}_t{tt}_attn_input.png')
    fname2 = join(pth, f'ep_{epidx}_t{tt}_attn_heat_bgr.png')
    cv2.imwrite(fname1, extras['input_c'])
    cv2.imwrite(fname2, extras['attn_heat_bgr'])

    # Transport
    for idx, tran_heat in enumerate(extras['tran_heat_bgr']):
        idxstr = str(idx).zfill(2)
        fname = join(pth, f'ep_{epidx}_t{tt}_tran_rot_{idxstr}.png')
        if idx == extras['tran_rot_argmax']:
            fname = fname.replace('.png', '_rot_chosen.png')
        cv2.imwrite(fname, tran_heat)
Save images and other stuff from time `t` in episode `epidx`.
Save images and other stuff from time `t` in episode `epidx`.
Save images and other stuff from time ` t ` in episode ` epidx ` .
def debug_time_step(t, epidx, obs, act, extras, goal=None):
    pth = 'tmp'
    tt = str(t).zfill(2)
    def save(fname, c_img):
        cv2.imwrite(fname, img=cv2.cvtColor(c_img, cv2.COLOR_BGR2RGB))
    for img_idx, c_img in enumerate(obs['color']):
        fname = join(pth, f'ep_{epidx}_t{tt}_cimg_{img_idx}.png')
        save(fname, c_img)
    colormap_o, _ = get_heightmap(obs=obs)
    fname = join(pth, f'ep_{epidx}_t{tt}_cimg_fused.png')
    save(fname, colormap_o)
    if (goal is not None) and t == 1:
        for img_idx, c_img in enumerate(goal['color']):
            fname = join(pth, f'ep_{epidx}_t{tt}_cimg_{img_idx}_goal.png')
            save(fname, c_img)
        colormap_g, _ = get_heightmap(obs=goal)
        fname = join(pth, f'ep_{epidx}_t{tt}_cimg_fused_goal.png')
        save(fname, colormap_g)
    pose0 = act['params']['pose0']
    pose1 = act['params']['pose1']
    print(f"  pose0, pose1: {U.round_pose(pose0)}, {U.round_pose(pose1)}")
    fname1 = join(pth, f'ep_{epidx}_t{tt}_attn_input.png')
    fname2 = join(pth, f'ep_{epidx}_t{tt}_attn_heat_bgr.png')
    cv2.imwrite(fname1, extras['input_c'])
    cv2.imwrite(fname2, extras['attn_heat_bgr'])
    for idx, tran_heat in enumerate(extras['tran_heat_bgr']):
        idxstr = str(idx).zfill(2)
        fname = join(pth, f'ep_{epidx}_t{tt}_tran_rot_{idxstr}.png')
        if idx == extras['tran_rot_argmax']:
            fname = fname.replace('.png', '_rot_chosen.png')
        cv2.imwrite(fname, tran_heat)
def debug_time_step ( t , epidx , obs , act , extras , goal = None ) : pth = 'tmp' tt = str ( t ) . zfill ( 2 ) def save ( fname , c_img ) : cv2 . imwrite ( fname , img = cv2 . cvtColor ( c_img , cv2 . COLOR_BGR2RGB ) ) for img_idx , c_img in enumerate ( obs [ 'color' ] ) : fname = join ( pth , f'ep_{epidx}_t{tt}_cimg_{img_idx}.png' ) save ( fname , c_img ) colormap_o , _ = get_heightmap ( obs = obs ) fname = join ( pth , f'ep_{epidx}_t{tt}_cimg_fused.png' ) save ( fname , colormap_o ) if ( goal is not None ) and t == 1 : for img_idx , c_img in enumerate ( goal [ 'color' ] ) : fname = join ( pth , f'ep_{epidx}_t{tt}_cimg_{img_idx}_goal.png' ) save ( fname , c_img ) colormap_g , _ = get_heightmap ( obs = goal ) fname = join ( pth , f'ep_{epidx}_t{tt}_cimg_fused_goal.png' ) save ( fname , colormap_g ) pose0 = act [ 'params' ] [ 'pose0' ] pose1 = act [ 'params' ] [ 'pose1' ] print ( f"  pose0, pose1: {U.round_pose(pose0)}, {U.round_pose(pose1)}" ) fname1 = join ( pth , f'ep_{epidx}_t{tt}_attn_input.png' ) fname2 = join ( pth , f'ep_{epidx}_t{tt}_attn_heat_bgr.png' ) cv2 . imwrite ( fname1 , extras [ 'input_c' ] ) cv2 . imwrite ( fname2 , extras [ 'attn_heat_bgr' ] ) for idx , tran_heat in enumerate ( extras [ 'tran_heat_bgr' ] ) : idxstr = str ( idx ) . zfill ( 2 ) fname = join ( pth , f'ep_{epidx}_t{tt}_tran_rot_{idxstr}.png' ) if idx == extras [ 'tran_rot_argmax' ] : fname = fname . replace ( '.png' , '_rot_chosen.png' ) cv2 . imwrite ( fname , tran_heat )
Save images and other stuff from time `t` in episode `epidx`.
Save images and other stuff from time ` t ` in episode ` epidx ` .
"""Save images and other stuff from time `t` in episode `epidx`.""" # Convert from BGR to RGB to match what we see in the GUI. # Save current color images from camera angles and the fused version. # (If applicable) save the goal color images. # Print the action. # Attention. (Well, attn_input.png is also input to Transport...) # Transport
t
epidx
obs
act
extras
goal