ravens/dataset.py
def _save_images(self, episode_len, color_l, depth_l, info_l, outdir, i_ep):
        """For each item (timestep) in this episode, save relevant images."""

        for t in range(episode_len):
            assert color_l[t].shape == (3, 480, 640, 3), color_l[t].shape
            assert depth_l[t].shape == (3, 480, 640), depth_l[t].shape

            # Recall that I added 'extras' to the info dict at each time.
            info = info_l[t]
            info_r = info['extras']

            # We saved three color/depth images per time step.
            for k in range(3):
                c_img = color_l[t][k]
                d_img = depth_l[t][k]
                assert c_img.dtype == 'uint8', c_img.dtype
                assert d_img.dtype == 'float32', d_img.dtype
                d_img = process_depth(img=d_img)

            # Andy uses U.reconstruct_heightmap(color, depth, configs, ...)
            obs_input = {'color': color_l[t], 'depth': depth_l[t]}
            colormap, heightmap = get_heightmap(obs_input)
            heightmap_proc = process_depth(img=heightmap)

            # Save image that combines the interesting ones above, makes it
            # easier to copy and paste. Horizontally concatenate images and
            # save. Also convert to BGR because OpenCV assumes that format
            # but PyBullet uses RGB (to be consistent). Network should be
            # seeing RGB images I believe (but just be consistent).
            c_img_front = color_l[t][0]  # Shape (480, 640, 3)
            c_img_front = cv2.resize(c_img_front, (426,320)) # numpy shape: (320,426)
            barrier = np.zeros((320,4,3))  # Black barrier of 4 pixels
            combo = np.concatenate((
                    cv2.cvtColor(c_img_front, cv2.COLOR_BGR2RGB),
                    barrier,
                    cv2.cvtColor(colormap, cv2.COLOR_RGB2BGR),
                    barrier,
                    heightmap_proc),
                axis=1)

            # Optionally include title with more details, but env dependent.
            suffix_all = f'{i_ep:06d}-{t:02d}-OVERALL.png'
            suffix_all = self._change_name(suffix_all, info_r)
            cv2.imwrite(os.path.join(outdir,suffix_all), combo)
For each item (timestep) in this episode, save relevant images.
For each item (timestep) in this episode, save relevant images.
For each item ( timestep ) in this episode save relevant images .
def _save_images(self, episode_len, color_l, depth_l, info_l, outdir, i_ep):
        for t in range(episode_len):
            assert color_l[t].shape == (3, 480, 640, 3), color_l[t].shape
            assert depth_l[t].shape == (3, 480, 640), depth_l[t].shape
            info = info_l[t]
            info_r = info['extras']
            for k in range(3):
                c_img = color_l[t][k]
                d_img = depth_l[t][k]
                assert c_img.dtype == 'uint8', c_img.dtype
                assert d_img.dtype == 'float32', d_img.dtype
                d_img = process_depth(img=d_img)
            obs_input = {'color': color_l[t], 'depth': depth_l[t]}
            colormap, heightmap = get_heightmap(obs_input)
            heightmap_proc = process_depth(img=heightmap)
            c_img_front = color_l[t][0]  
            c_img_front = cv2.resize(c_img_front, (426,320)) 
            barrier = np.zeros((320,4,3))  
            combo = np.concatenate((
                    cv2.cvtColor(c_img_front, cv2.COLOR_BGR2RGB),
                    barrier,
                    cv2.cvtColor(colormap, cv2.COLOR_RGB2BGR),
                    barrier,
                    heightmap_proc),
                axis=1)
            suffix_all = f'{i_ep:06d}-{t:02d}-OVERALL.png'
            suffix_all = self._change_name(suffix_all, info_r)
            cv2.imwrite(os.path.join(outdir,suffix_all), combo)
def _save_images ( self , episode_len , color_l , depth_l , info_l , outdir , i_ep ) : for t in range ( episode_len ) : assert color_l [ t ] . shape == ( 3 , 480 , 640 , 3 ) , color_l [ t ] . shape assert depth_l [ t ] . shape == ( 3 , 480 , 640 ) , depth_l [ t ] . shape info = info_l [ t ] info_r = info [ 'extras' ] for k in range ( 3 ) : c_img = color_l [ t ] [ k ] d_img = depth_l [ t ] [ k ] assert c_img . dtype == 'uint8' , c_img . dtype assert d_img . dtype == 'float32' , d_img . dtype d_img = process_depth ( img = d_img ) obs_input = { 'color' : color_l [ t ] , 'depth' : depth_l [ t ] } colormap , heightmap = get_heightmap ( obs_input ) heightmap_proc = process_depth ( img = heightmap ) c_img_front = color_l [ t ] [ 0 ] c_img_front = cv2 . resize ( c_img_front , ( 426 , 320 ) ) barrier = np . zeros ( ( 320 , 4 , 3 ) ) combo = np . concatenate ( ( cv2 . cvtColor ( c_img_front , cv2 . COLOR_BGR2RGB ) , barrier , cv2 . cvtColor ( colormap , cv2 . COLOR_RGB2BGR ) , barrier , heightmap_proc ) , axis = 1 ) suffix_all = f'{i_ep:06d}-{t:02d}-OVERALL.png' suffix_all = self . _change_name ( suffix_all , info_r ) cv2 . imwrite ( os . path . join ( outdir , suffix_all ) , combo )
For each item (timestep) in this episode, save relevant images.
For each item ( timestep ) in this episode save relevant images .
"""For each item (timestep) in this episode, save relevant images.""" # Recall that I added 'extras' to the info dict at each time. # We saved three color/depth images per time step. # Andy uses U.reconstruct_heightmap(color, depth, configs, ...) # Save image that combines the interesting ones above, makes it # easier to copy and paste. Horizontally concatenate images and # save. Also convert to BGR because OpenCV assumes that format # but PyBullet uses RGB (to be consistent). Network should be # seeing RGB images I believe (but just be consistent). # Shape (480, 640, 3) # numpy shape: (320,426) # Black barrier of 4 pixels # Optionally include title with more details, but env dependent.
self
episode_len
color_l
depth_l
info_l
outdir
i_ep