Exemplo n.º 1
0
 def _buildOb(self):
     state, adj_loc_ls = env._get_panorama_states(self.sim)
     
     assert self.scanId== state.scanId
     #filePath = 'img_features_36*2048/'+ self.scanId + '/' + state.location.viewpointId + '.pt'
     #feature = torch.load(filePath)
     feature = [f.get_features(state) for f in image_features_list]
     
     #print(feature,_static_loc_embeddings[state.viewIndex])
     #print(feature.size(),_static_loc_embeddings[state.viewIndex].size())
     feature_with_loc = np.concatenate((feature[0], _static_loc_embeddings[state.viewIndex]), axis=-1)
     action_embedding = env._build_action_embedding(adj_loc_ls, feature[0])
     ob = {
         'scan' : state.scanId,
         'viewpoint' : state.location.viewpointId,
         'viewIndex' : state.viewIndex,
         'heading' : state.heading,
         'elevation' : state.elevation,
         'feature' : [feature_with_loc],
         'step' : state.step,
         'adj_loc_list' : adj_loc_ls,
         'action_embedding': action_embedding,
         'navigableLocations' : state.navigableLocations,
     }
     
     return ob
Exemplo n.º 2
0
def roll_out(scan, viewpoint, sim=sim, heading = 0, elevation = 0):
    sim.newEpisode(scan, viewpoint, heading, elevation)
    ended = False
    traj = []
    traj.append(viewpoint)
    for i in range(step):
        _, adj_loc_ls = env._get_panorama_states(sim)

        if len(adj_loc_ls) == 1:
            ended == True
        elif i == 0:
            next_loc = random.choice(adj_loc_ls[1:])
            nextViewpointId = next_loc['nextViewpointId']
            nextViewIndex = next_loc['absViewIndex']
            env._navigate_to_location(sim, nextViewpointId,nextViewIndex)
            traj.append(nextViewpointId)
        else:
            next_loc = adj_loc_ls[1]
            nextViewpointId = next_loc['nextViewpointId']
            nextViewIndex = next_loc['absViewIndex']
            env._navigate_to_location(sim, nextViewpointId,nextViewIndex)
            traj.append(nextViewpointId)
            
        if ended :
            print(adj_loc_ls)
            break
    
    return traj
Exemplo n.º 3
0
    def buildOb(self):
        state, adj_loc_ls = env._get_panorama_states(self.sim)

        assert self.scanId == state.scanId
        filePath = 'img_features_36*2048/' + self.scanId + '/' + state.location.viewpointId + '.pt'
        feature_pano = torch.load(filePath)
        feature = feature_pano[state.viewIndex]

        assert len(feature) == 1, 'for now, only work with MeanPooled feature'
        feature_with_loc = np.concatenate(
            (feature, _static_loc_embeddings[state.viewIndex]), axis=-1)
        action_embedding = env._build_action_embedding(adj_loc_list,
                                                       feature_pano)
        ob = {
            'instr_id': item['instr_id'],
            'scan': state.scanId,
            'viewpoint': state.location.viewpointId,
            'viewIndex': state.viewIndex,
            'heading': state.heading,
            'elevation': state.elevation,
            'feature': [feature_with_loc],
            'step': state.step,
            'adj_loc_list': adj_loc_list,
            'action_embedding': action_embedding,
            'navigableLocations': state.navigableLocations,
        }

        return ob
Exemplo n.º 4
0
 def _get_adj_loc_ls(self):  
     _, adj_loc_ls = env._get_panorama_states(self.sim)
     return adj_loc_ls