(self, callback_data, batch_ind, imgs_to_store, img_batch_data, C, H, W)
Store images
Store images
Store images
def store_images(self, callback_data, batch_ind, imgs_to_store, img_batch_data, C, H, W):
        """
        Store images
        """
        n_imgs = len(imgs_to_store)
        if n_imgs:
            img_data = img_batch_data[:, imgs_to_store].get()
            img_store = callback_data.create_group('deconv/img/batch_' + str(batch_ind))

            # Store uint8 HWC formatted data for plotting
            img_hwc8 = img_store.create_dataset("HWC_uint8", (H, W, C, n_imgs),
                                                dtype='uint8', compression=True)
            img_hwc_f32 = np.transpose(img_data.reshape((C, H, W, n_imgs)), (1, 2, 0, 3))
            img_hwc8[:] = self.scale_to_rgb(img_hwc_f32)

            # keep image in native format to use for fprop in visualization
            # don't need this beyond runtime so avoid writing to file
            self.raw_img_cache[batch_ind] = img_data

            # Keep a lookup from img_ind -> file position
            # In order to store only needed imgs from batch in flat prealloc array
            self.raw_img_key[batch_ind] = dict()
            for i, img_idx in enumerate(imgs_to_store):
                img_store.attrs[str(img_idx)] = i
                self.raw_img_key[batch_ind][img_idx] = i
def store_images ( self , callback_data , batch_ind , imgs_to_store , img_batch_data , C , H , W ) : n_imgs = len ( imgs_to_store ) if n_imgs : img_data = img_batch_data [ : , imgs_to_store ] . get ( ) img_store = callback_data . create_group ( 'deconv/img/batch_' + str ( batch_ind ) ) # Store uint8 HWC formatted data for plotting img_hwc8 = img_store . create_dataset ( "HWC_uint8" , ( H , W , C , n_imgs ) , dtype = 'uint8' , compression = True ) img_hwc_f32 = np . transpose ( img_data . reshape ( ( C , H , W , n_imgs ) ) , ( 1 , 2 , 0 , 3 ) ) img_hwc8 [ : ] = self . scale_to_rgb ( img_hwc_f32 ) # keep image in native format to use for fprop in visualization # don't need this beyond runtime so avoid writing to file self . raw_img_cache [ batch_ind ] = img_data # Keep a lookup from img_ind -> file position # In order to store only needed imgs from batch in flat prealloc array self . raw_img_key [ batch_ind ] = dict ( ) for i , img_idx in enumerate ( imgs_to_store ) : img_store . attrs [ str ( img_idx ) ] = i self . raw_img_key [ batch_ind ] [ img_idx ] = i