Ejemplo n.º 1
0
def get_mean_std(
    scenes, 
    data_name = 'images.hdf5',
    datadir = '../mixed_offline_data/',
    ):
    
    scene_names = get_scene_names(scenes)

    trans = T.Compose([
        T.ToTensor(),
        #T.Normalize(mean=[0,0,0],std=[1,1,1],inplace=True)
    ])
    means = []
    stds = []
    pbar = tqdm(total = states_num(scenes, preload=data_name))
    for s in scene_names:
        data = {}
        loader = h5py.File(os.path.join(datadir,s,data_name),"r",)
        num = len(list(loader.keys()))
        for k in loader.keys():
            vobs = trans(loader[k][:])
            #vobs = torch.tensor(loader[k][:])
            means.append(torch.mean(vobs, dim=[1,2]))
            stds.append(torch.std(vobs, dim=[1,2]))
            pbar.update(1)
        loader.close()

    mean = torch.mean(torch.stack(means), dim=0)
    std = torch.std(torch.stack(stds), dim=0)
    return dict(mean=mean,std=std)
Ejemplo n.º 2
0
        json.dump(ips, f)


test_scenes = {
    'kitchen': range(1, 21),
    'living_room': range(1, 21),
    'bedroom': range(1, 21),
    'bathroom': range(1, 21),
}
out_name = 'min_len.json'

graph_name = 'nop_graph.json'
visible_file_name = 'visible_object_map.json'
datadir = '../mixed_offline_data/'

scene_names = get_scene_names(test_scenes)
print(f'making for {len(scene_names)} scenes')

p = tqdm(total=len(scene_names))

for scene_name in scene_names:
    p.update(1)

    with open(
            os.path.join(datadir, scene_name, graph_name),
            "r",
    ) as f:
        graph_json = json.load(f)
    with open(
            os.path.join(datadir, scene_name, visible_file_name),
            "r",
Ejemplo n.º 3
0
    'living_room': range(1, 21),
    'bedroom': range(1, 21),
    'bathroom': range(1, 21),
}
image_name = 'images.hdf5'
datadir = '../mixed_offline_data/'
fc_name = 'resnet50fc.hdf5'
score_name = 'resnet50score'

trans = T.Compose([
    T.ToTensor(),
    T.Normalize(mean=[0.5265, 0.4560, 0.3682],
                std=[0.0540, 0.0554, 0.0567],
                inplace=True)
])
scene_names = get_scene_names(scenes)
resmodel = my_resnet50().cuda()
print(f'making for {len(scene_names)} scenes')

pbar = tqdm(total=states_num(scenes, preload=image_name))
for scene_name in scene_names:

    fc_writer = h5py.File(os.path.join(datadir, scene_name, fc_name), 'w')
    score_writer = h5py.File(os.path.join(datadir, scene_name, score_name),
                             'w')
    RGBloader = h5py.File(
        os.path.join(datadir, scene_name, image_name),
        "r",
    )

    for k in RGBloader.keys():