def make_new_batch(bn): # how many frames of action its allowed to take action_length = ACTION_LENGTH #(bsize - i) / 3 # how long it waits after action end action_wait = ACTION_WAIT bsize = BATCH_SIZE start = BATCH_SIZE * bn end = BATCH_SIZE * (bn + 1) print("Getting new %d-%d" % (start, end)) ims = [] objs = [] norms = [] infolist = [] for i in range(bsize): print(i) info, narray, oarray, imarray = handle_message(sock, write=True, outdir=path, prefix=str(bn) + '_' + str(i)) msg = {'n': 4, 'msg': {"msg_type": "CLIENT_INPUT", "get_obj_data": False, "actions": []}} oarray1 = 256**2 * oarray[:, :, 0] + 256 * oarray[:, :, 1] + oarray[:, :, 2] obs = np.unique(oarray1) msg['msg']['ang_vel'] = [0, .15, 0] obs = obs[obs > 20] if(len(obs) > 0): chosen = obs.max() print(chosen) action = {} action['force'] = [3000, 3000, 0] action['torque'] = [0, 10, 0] action['id'] = str(chosen) action['action_pos'] = [] #map(float, chosen) msg['msg']['actions'].append(action) sock.send_json(msg['msg'])
def make_new_batch(bn): # how many frames of action its allowed to take action_length = ACTION_LENGTH #(bsize - i) / 3 # how long it waits after action end action_wait = ACTION_WAIT bsize = BATCH_SIZE start = BATCH_SIZE * bn end = BATCH_SIZE * (bn + 1) print("Getting new %d-%d" % (start, end)) ims = [] objs = [] norms = [] infolist = [] chosen = False chosen_obj = -1 chosen_frac = 0 teleport_counter = 0 move = 0 for i in range(bsize): #print(i) info, narray, oarray, imarray = handle_message(sock, write=True, outdir=path, prefix=str(bn) + '_' + str(i)) msg = {'n': 4, 'msg': {"msg_type": "CLIENT_INPUT", "get_obj_data": False, "actions": []}} oarray1 = 256**2 * oarray[:, :, 0] + 256 * oarray[:, :, 1] + oarray[:, :, 2] #move forward for two steps if(move < 10): move = move + 1 msg['msg']['vel'] = [0, 0, .25] #turn if(move >= 10 and move < 15): move = move + 1 msg['msg']['ang_vel'] = [0, .3, 0] if(move >= 15): move = 0 print move # choose closest object #if (chosen == False): # print 'I am choosing an object' # oarray1 = 256**2 * oarray[:, :, 0] + 256 * oarray[:, :, 1] + oarray[:, :, 2] # obs = np.unique(oarray1) # obs = obs[obs > 20] # if (len(obs) > 0): # fracs = [] # for o in obs: # frac = (oarray1 == o).sum() / float(np.prod(oarray.shape)) # fracs.append(frac) # max_id = np.argmax(fracs) # chosen_obj = obs[max_id] # chosen_frac = fracs[max_id] # chosen = True # else: # # turn if no object found # msg['msg']['ang_vel'] = [0, .3, 0] # move towards closest object #if (chosen == True and chosen_frac < 0.005): # print 'I am moving closer to object ' + str(chosen_obj) # xs, ys = (oarray1 == chosen_obj).nonzero() # pos = np.round(np.array(zip(xs, ys)).mean(0)) # print pos # # # lost object # if len(pos) == 1: # if math.isnan(pos): # chosen = False # continue # # if np.abs(SCREEN_WIDTH / 2 - pos[1]) < 30: # d = 0 # else: # d = -0.1 * np.sign(SCREEN_WIDTH / 2 - pos[1]) # msg['msg']['vel'] = [0, 0, .25] # msg['msg']['ang_vel'] = [0, d, 0] # move object #if (chosen == True and chosen_frac > 0.005): # print 'I am pushing object' + str(chosen_obj) # action = {} # action['force'] = [0, 3000, 0] # action['torque'] = [0, 0, 0] # action['id'] = str(chosen_obj) # action['action_pos'] = [] # msg['msg']['actions'].append(action) # chosen = False # teleport every 10 steps #if(teleport_counter == 20): # msg['msg']['teleport_random'] = True # teleport_counter = 0 #teleport_counter = teleport_counter + 1 #print(obs) #msg['msg']['ang_vel'] = [0, .15, 0] #action = {} #action['force'] = [3000, 3000, 0] #action['torque'] = [0, 10, 0] #action['id'] = str(chosen) #action['action_pos'] = [] #map(float, chosen) #msg['msg']['actions'].append(action) sock.send_json(msg['msg'])
def make_new_batch(bn): global number_of_frames global reset global tstart # how many frames of action its allowed to take action_length = ACTION_LENGTH #(bsize - i) / 3 # how long it waits after action end action_wait = ACTION_WAIT bsize = BATCH_SIZE start = BATCH_SIZE * bn end = BATCH_SIZE * (bn + 1) if not valid[start: end].all(): print("Getting new %d-%d" % (start, end)) ims = [] objs = [] norms = [] infolist = [] for i in range(bsize): number_of_frames = number_of_frames + 1; print(i) info, narray, oarray, imarray = handle_message(sock, write=True, outdir=path, prefix=str(bn) + '_' + str(i)) if(reset == True): tstart = time.time() reset = False msg = {'n': 4, 'msg': {"msg_type": "CLIENT_INPUT", "get_obj_data": False, "actions": []}} if i == 0: if bn == 0: msg['msg']['get_obj_data'] = True #print('turning at %d ... ' % i) #msg['msg']['ang_vel'] = [0, 10 * (rng.uniform() - 1), 0] #msg['msg']['vel'] = [0, 0, 1] msg['msg']['teleport_random'] = True chosen = False action_started = False action_done = False action_ind = 0 objpi = [] aset = achoice[:] amult = MULTSTART else: oarray1 = 256**2 * oarray[:, :, 0] + 256 * oarray[:, :, 1] + oarray[:, :, 2] obs = np.unique(oarray1) obs = obs[obs > 18] obs = obs[obs < 256] if len(obs) == 0: print('turning at %d ... ' % i) msg['msg']['ang_vel'] = [0, 10 * (2 * rng.uniform() - 1), 0] msg['msg']['vel'] = [0, 0, 2 * (2 * rng.uniform() - 1)] action_done = False action_started = False action_ind = 0 objpi = [] aset = achoice[:] amult = MULTSTART chosen = False g = 7.5 * (2 * rng.uniform() - 1) else: fracs = [] for o in obs: frac = (oarray1 == o).sum() / float(np.prod(oarray.shape)) fracs.append(frac) if not chosen or (chosen_o not in obs and ((not action_started) or action_done)): action_started = False action_done = False action_ind = 0 objpi = [] aset = achoice[:] amult = MULTSTART chosen_o = choose(obs[np.argsort(fracs)[-10:]]) chosen = True print('Choosing object', chosen_o) g = 15. * (2 * rng.uniform() - 1) a = achoice[rng.randint(len(achoice))] if chosen_o not in obs.tolist(): frac0 = 0 else: frac0 = fracs[obs.tolist().index(chosen_o)] print('FRAC:', frac0, chosen, chosen_o, action_started, action_ind, action_done) if action_ind >= action_length + action_wait: action_done = True action_started = False action_ind = 0 if frac0 < 0.005 and not action_started: xs, ys = (oarray1 == chosen_o).nonzero() pos = np.round(np.array(zip(xs, ys)).mean(0)) if np.abs(SCREEN_WIDTH/2 - pos[1]) < 3: d = 0 else: d = -0.1 * np.sign(SCREEN_WIDTH/2 - pos[1]) msg['msg']['vel'] = [0, 0, .25] msg['msg']['ang_vel'] = [0, d, 0] print(pos, d) else: xs, ys = (oarray1 == chosen_o).nonzero() pos = np.round(np.array(zip(xs, ys)).mean(0)) objpi.append(pos) action = {} if action_started and not action_done: if chosen_o not in obs.tolist() and action_ind < action_length: action_ind = action_length if action_ind < action_length and len(objpi) > 2: dist = np.sqrt(((objpi[-2] - objpi[-1])**2).sum()) print('dist', dist) if dist < 1: action_ind = 0 aset.remove(a) if len(aset) == 0: amult += 1 aset = ((2 ** (amult)) * np.array(achoice)).tolist() a = aset[rng.randint(len(aset))] if amult > 10: action_done = True action_started = False print('choosing "a"', dist, a) action['force'] = [a, 100 * (2 ** amult), 0] action['torque'] = [0, g, 0] action['id'] = str(chosen_o) action['action_pos'] = map(float, objpi[-1]) print 'MOVE OBJECT! ' + str(chosen_o) else: print(action_ind, i, 'waiting') msg['msg']['vel'] = [0, 0, 0] msg['msg']['ang_vel'] = [0, 0, 0] msg['msg']['actions'] = [] action_ind += 1 if action_done or (action_ind >= action_length + action_wait): action_done = True chosen = False action_started = False elif not action_started: objpi = [] action_ind = 0 action_started = True action['id'] = str(chosen_o) action['force'] = [a, 100 * (2 ** amult), 0] action['torque'] = [0, g, 0] action['action_pos'] = map(float, pos) print 'MOVE OBJECT! ' + str(chosen_o) if 'id' in action: msg['msg']['actions'].append(action) infolist.append(msg['msg']) ims.append(imarray) norms.append(narray) objs.append(oarray) sock.send_json(msg['msg']) ims = np.array(ims) norms = np.array(norms) objs = np.array(objs) #infopath = os.path.join(infodir, str(bn) + '.json') #with open(infopath, 'w') as _f: # json.dump(infolist, _f) #images[start: end] = ims #normals[start: end] = norms #objects[start: end] = objs valid[start: end] = True
def make_new_batch(self, bn, sock, path, create_hdf5, use_tdw_msg): if(create_hdf5): self.valid, images, normals, objects, worldinfos, agentactions = self.get_hdf5_handles() # how many frames of action its allowed to take action_length = self.ACTION_LENGTH #(bsize - i) / 3 # how long it waits after action end action_wait = self.ACTION_WAIT waiting = False # how long it waits when it gets stuck before it turns away init_y_pos = 0 # look around variables look_init_direction = [0, 0, 0] look_length = 25 look_around = 0 look_is_looking = 1 look_i = 0 # turn variables turn_on = False turn_length = 5 bsize = self.BATCH_SIZE start = self.BATCH_SIZE * bn end = self.BATCH_SIZE * (bn + 1) if not self.valid[start: end].all(): print("Getting new %d-%d" % (start, end)) ims = [] objs = [] norms = [] infolist = [] infs = [] for i in range(bsize): print(i) info, narray, oarray, imarray = handle_message(sock, write=self.WRITE_FILES, outdir=path, prefix=str(bn) + '_' + str(i)) info = json.loads(info) obs_obj = info['observed_objects'] #Print object information #print '................' #print 'observed object 0' #print info['observed_objects'][0][0] #name #print info['observed_objects'][0][1] #ID #print info['observed_objects'][0][2] #position #print info['observed_objects'][0][3] #rotation #print info['observed_objects'][0][4] #isStatic print '................' #print 'avatar' #print info['avatar_position'] #print info['avatar_rotation'] #print info['avatar_up'] #print '................' msg = {'n': 4, 'msg': {"msg_type": "CLIENT_INPUT", "get_obj_data": True, "actions": []}} # if agent tilted move it back is_tilted = info['avatar_up'][1] < 0.99 if look_around == 0: look_around = self.rng.randint(5) + 1 # teleport and reinitialize if i == 0: if bn == 0: msg['msg']['get_obj_data'] = True msg['msg']['teleport_random'] = True msg['msg']['action_type'] = "TELEPORT" chosen = False action_started = False action_done = False action_ind = 0 objpi = [] objpi2 = [] aset = self.achoice[:] amult = self.MULTSTART # initial y-pos of agent init_y_pos = info['avatar_position'][1] elif look_around == 1: # first look sequence - select target angle if look_i == 0: # store init looking direction if look_is_looking == 1: look_init_direction = info['avatar_rotation'] target_angle = [] random_angle = (self.rng.randint(30) - 15) target_angle.append(random_angle) random_angle = self.rng.randint(360) - 180; while(abs(random_angle) < 140): random_angle = (self.rng.randint(360) - 180); target_angle.append(random_angle) target_angle.append(0) target_axis = self.rotate_smooth(info['avatar_forward'], info['avatar_angvel'], target_angle) #if look_is_looking % 2 != 0: # target_angle = look_init_direction look_i = look_i + 1 # end of one looking sequence if look_i == look_length: look_i = 0 look_is_looking += 1 if look_is_looking % 2 == 0: msg['msg']['ang_vel'] = self.stabilize(info['avatar_up'], info['avatar_angvel']) #print "STAB: " + str(info['avatar_forward']) else: msg['msg']['ang_vel'] = self.stabilize(info['avatar_forward'], info['avatar_angvel'], target_axis) msg['msg']['vel'] = [0, 0, 0] msg['msg']['action_type'] = "LOOK" print 'LOOK AROUND!' # stand back up elif is_tilted and self.use_stabilization: print('STANDING BACK UP') msg['msg']['ang_vel'] = self.stabilize(info['avatar_up'], info['avatar_angvel']) msg['msg']['action_type'] = "STANDUP" #action_done = False #action_started = False #action_ind = 0 #objpi = [] #aset = self.achoice[:] #amult = self.MULTSTART #chosen = False #g = 7.5 * (2 * self.rng.uniform() - 1) # object interactions else: oarray1 = 256**2 * oarray[:, :, 0] + 256 * oarray[:, :, 1] + oarray[:, :, 2] obs = np.unique(oarray1) # remove static objects from object list valido = [] for o in info['observed_objects']: if not o[4] and o[1] in obs: valido.append(o[1]) diff = set(valido).symmetric_difference(set(obs)) obs = np.array(valido) # remove static objects from objects image for d in diff: oarray1[oarray1 == d] = 0 # random searching for object if len(obs) == 0 and not waiting: print('turning at %d ... ' % i) if not turn_on: turn_on = True t = 0 target_angle = [] target_angle.append(0) random_angle = self.rng.randint(360) - 180; while(abs(random_angle) < 140): random_angle = (self.rng.randint(360) - 180); target_angle.append(random_angle) target_angle.append(0) target_axis = self.rotate_smooth(info['avatar_forward'], info['avatar_angvel'], target_angle) target_velocity = 2 * (2 * self.rng.uniform() - 1) if t == turn_length: turn_on = False t += 1 #msg['msg']['ang_vel'] = [0, 10 * (2 * self.rng.uniform() - 1), 0] msg['msg']['ang_vel'] = self.stabilize(info['avatar_forward'], info['avatar_angvel'], target_axis) msg['msg']['vel'] = [0, 0, 0.1 * target_velocity] msg['msg']['action_type'] = "SEARCHING" action_done = False action_started = False action_ind = 0 objpi = [] aset = self.achoice[:] amult = self.MULTSTART chosen = False g = 7.5 * (2 * self.rng.uniform() - 1) # object selection else: fracs = [] for o in obs: frac = (oarray1 == o).sum() / float(np.prod(oarray.shape)) fracs.append(frac) # choose new objects if not chosen or (chosen_o not in obs and ((not action_started) or action_done)): action_started = False action_done = False action_ind = 0 objpi = [] aset = self.achoice[:] amult = self.MULTSTART chosen_o, index_o = self.choose(obs[np.argsort(fracs)[-5:]]) chosen_o_name = obs_obj[self.find_in_observed_objects(chosen_o, obs_obj)][0] chosen = True print 'CHOOSING OBJECT ' + str(chosen_o) + " " + str(chosen_o_name) g = 15. * (2 * self.rng.uniform() - 1) a = self.achoice[self.rng.randint(len(self.achoice))] target_distance = self.rng.rand(1)[0] * 2 + 0.8 # determine fraction and position of chosen objects if chosen_o not in obs.tolist(): frac0 = 0 obs_dist = np.array([]) else: frac0 = fracs[obs.tolist().index(chosen_o)] obs_idx = self.find_in_observed_objects(chosen_o, obs_obj) if obs_idx != -1: pos3d = np.array(obs_obj[obs_idx][2]) obs_dist = np.linalg.norm(pos3d - np.array(info['avatar_position'])) #print('FRAC:', frac0, chosen, chosen_o, action_started, action_ind, action_done) # reset if action is done if action_ind >= action_length + action_wait or action_done and action_started: action_done = True action_started = False action_ind = 0 waiting = False # if object too far and no action is performed move closer if obs_dist.size != 0 and obs_dist > target_distance and not action_started: print 'MOVING CLOSER TO ' + str(chosen_o) + ' ' + str(chosen_o_name) print 'TARGET DISTANCE ' + str(target_distance) + ' > ' + str(obs_dist) xs, ys = (oarray1 == chosen_o).nonzero() pos = np.round(np.array(zip(xs, ys)).mean(0)) if np.abs(self.SCREEN_WIDTH/2 - pos[1]) < 10: d = 0 else: d = -0.1 * np.sign(self.SCREEN_WIDTH/2 - pos[1]) msg['msg']['vel'] = [0, 0, .25] msg['msg']['ang_vel'] = [0, d, 0] msg['msg']['action_type'] = "MOVING_CLOSER" # perform action on chosen object else: if action_ind == 0: # choose position of action pos, chosen_id = self.choose_action_position(oarray1, chosen_o) print 'ACTION POS: ' + str(chosen_o) + " " + str(chosen_id) # find object centroid xs, ys = (oarray1 == chosen_o).nonzero() centroid = np.round(np.array(zip(xs, ys)).mean(0)) objpi.append(centroid) action = {} action2 = {} # continue action if action_started and not action_done: # if object was lost, then wait if chosen_o not in obs.tolist() and action_ind < action_length: action_ind = action_length # if action is running and object is there, then perform action if action_ind < action_length and len(objpi) > 2: dist = np.sqrt(((objpi[-2] - objpi[-1])**2).sum()) # if object has not moved, reset action and remove already performed force from action set if dist < 1: action_ind = 0 aset.remove(a) # increase force if len(aset) == 0: amult += 1 aset = ((2 ** (amult)) * np.array(self.achoice)).tolist() a = aset[self.rng.randint(len(aset))] # marked as done if object still hasn't moved with biggest force if amult > 10: action_done = True action_started = False print('choosing "a"', dist, a) if action_type == 0: action['force'] = [a, 105 * (2 ** amult), 0] action['torque'] = [0, g, 0] action['id'] = str(chosen_id) action['object'] = str(chosen_o) action['action_pos'] = map(float, pos) msg['msg']['action_type'] = "MOVING_OBJECT" print 'MOVE OBJECT! ' + str(chosen_o) elif action_type == 1: idx = self.find_in_observed_objects(chosen_o, obs_obj) idx2 = self.find_in_observed_objects(chosen_o2, obs_obj) if(idx != -1 and idx2 != -1 and idx != idx2): pos_obj = np.array(obs_obj[idx][2]) pos_obj2 = np.array(obs_obj[idx2][2]) mov = pos_obj2 - pos_obj mov[1] = 0 #mov = mov / np.linalg.norm(mov) mov = 200 * (2 ** amult) * mov mov2 = -mov action['id'] = str(chosen_id) action['object'] = str(chosen_o) action['force'] = mov.tolist() action['torque'] = [0, g, 0] action['action_pos'] = map(float, pos) action2['id'] = str(chosen_id2) action2['object'] = str(chosen_o2) action2['force'] = mov2.tolist() action2['torque'] = [0, g, 0] action2['action_pos'] = map(float, pos2) msg['msg']['action_type'] = "CRASHING" action_ind = action_length print 'CRASH OBJECTS! ' + str(chosen_o) + ' ' + str(chosen_o2) + ' ' + str(mov) + ' ' + str(mov2) + ' ' + str(pos_obj) + ' ' + str(pos_obj2)+ ' ' + obs_obj[idx][0] + ' ' + obs_obj[idx2][0] else: print 'CRASH NOT FOUND!' msg['msg']['action_type'] = "NO_CRASH" elif action_type == 2: action['force'] = [0, self.rng.rand(1)[0] * 10 + 48, 0] action['torque'] = [0, 0, 0] action['id'] = str(chosen_id) action['object'] = str(chosen_o) action['action_pos'] = map(float, pos) msg['msg']['action_type'] = "LIFTING" print 'LIFT OBJECT! ' + str(action['force']) + ' ' + str(chosen_o) elif action_type == 3: action['force'] = [0, 0, 0] action['torque'] = [0, rotation_torque, 0] action['id'] = str(chosen_id) action['object'] = str(chosen_o) action['action_pos'] = map(float, pos) msg['msg']['action_type'] = "ROTATING" print 'ROTATE OBJECT! ' + str(action['torque']) + ' ' + str(chosen_o) else: print('WAITING') msg['msg']['vel'] = [0, 0, 0] msg['msg']['ang_vel'] = [0, 0, 0] msg['msg']['actions'] = [] msg['msg']['action_type'] = "WAITING" waiting = True action_ind += 1 if action_done or (action_ind >= action_length + action_wait): action_done = True chosen = False action_started = False waiting = False # start new action elif not action_started: chosen_o2 = chosen_o if len(obs) > 1: while (chosen_o2 == chosen_o): chosen_o2, index_o2 = self.choose(obs[np.argsort(fracs)[-10:]]) pos2, chosen_id2 = self.choose_action_position(oarray1, chosen_o2) objpi = [] objpi2 = [] action_ind = 0 action_type = self.rng.randint(4) action_started = True if action_type == 0: action['id'] = str(chosen_id) action['object'] = str(chosen_o) action['force'] = [a, 105 * (2 ** amult), 0] action['torque'] = [0, g, 0] action['action_pos'] = map(float, pos) msg['msg']['action_type'] = "MOVING_OBJECT" print 'MOVE OBJECT! ' + str(chosen_o) elif action_type == 1: idx = self.find_in_observed_objects(chosen_o, obs_obj) idx2 = self.find_in_observed_objects(chosen_o2, obs_obj) if(idx != -1 and idx2 != -1 and idx != idx2): pos_obj = np.array(obs_obj[idx][2]) pos_obj2 = np.array(obs_obj[idx2][2]) mov = pos_obj2 - pos_obj mov[1] = 0 #mov = mov / np.linalg.norm(mov) mov = 200 * (2 ** amult) * mov mov2 = -mov action['id'] = str(chosen_id) action['object'] = str(chosen_o) action['force'] = mov.tolist() action['torque'] = [0, g, 0] action['action_pos'] = map(float, pos) action2['id'] = str(chosen_id2) action2['object'] = str(chosen_o2) action2['force'] = mov2.tolist() action2['torque'] = [0, g, 0] action2['action_pos'] = map(float, pos2) msg['msg']['action_type'] = "CRASHING" action_ind = action_length print 'CRASH OBJECTS! ' + str(chosen_o) + ' ' + str(chosen_o2) + ' ' + str(mov) + ' ' + str(mov2) + ' ' + obs_obj[idx][0] + ' ' + obs_obj[idx2][0] else: action_done = True print 'CRASH NOT FOUND!' msg['msg']['action_type'] = "NO_CRASH" elif action_type == 2: action['force'] = [0, self.rng.rand(1)[0] * 10 + 48, 0] action['torque'] = [0, 0, 0] action['id'] = str(chosen_id) action['object'] = str(chosen_o) action['action_pos'] = map(float, pos) msg['msg']['action_type'] = "LIFTING" print 'LIFT OBJECT! ' + str(action['force']) + ' ' + str(chosen_o) elif action_type == 3: action['force'] = [0, 0, 0] rotation_torque = self.rng.rand(1)[0] * 100 - 50 while abs(rotation_torque) < 30: rotation_torque = self.rng.rand(1)[0] * 100 - 50 action['torque'] = [0, rotation_torque, 0] action['id'] = str(chosen_id) action['object'] = str(chosen_o) action['action_pos'] = map(float, pos) msg['msg']['action_type'] = "ROTATING" print 'ROTATE OBJECT! ' + str(action['torque']) + ' ' + str(chosen_o) # add action if new action defined if 'id' in action: msg['msg']['actions'].append(action) if 'id' in action2: msg['msg']['actions'].append(action2) # move down if not is_tilted and init_y_pos != info['avatar_position'][1]: #print('moving up/down') gravity = info['avatar_position'][1] - init_y_pos if 'vel' in msg['msg']: msg['msg']['vel'][1] = -0.1 * gravity else: msg['msg']['vel'] = [0, -0.1 * gravity, 0] #msg['msg']['output_formats'] = ["png", "png", "jpg"] if(not 'action_type' in msg['msg']): print("ERROR! Action not recognized") else: print(msg['msg']['action_type']) infolist.append(json.dumps(msg['msg'])) ims.append(imarray) norms.append(narray) infs.append(json.dumps(info)) objs.append(oarray) if use_tdw_msg: sock.send_json(msg) else: sock.send_json(msg['msg']) ims = np.array(ims) norms = np.array(norms) objs = np.array(objs) if(create_hdf5): #actioninfopath = os.path.join(path, str(bn) + '_action.json') #with open(actioninfopath, 'w') as _f: # json.dump(infolist, _f) #objectinfopath = os.path.join(path, str(bn) + '_objects.json') #with open(objectinfopath, 'w') as _f: # json.dump(infs, _f) images[start: end] = ims normals[start: end] = norms objects[start: end] = objs self.valid[start: end] = True worldinfos[start: end] = infs agentactions[start: end] = infolist if(create_hdf5): self.hdf5.flush()