Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_unity_command():
c = ai2thor.controller.Controller()
assert c.unity_command(650, 550) == [
c.executable_path(),
'-screen-fullscreen',
'0',
'-screen-quality',
'7',
'-screen-width',
'650',
'-screen-height',
'550']
c = ai2thor.controller.Controller(quality='Low', fullscreen=True)
assert c.unity_command(650, 550) == [
c.executable_path(),
'-screen-fullscreen',
'1',
def test_scene_names():
c = ai2thor.controller.Controller()
assert len(c.scene_names()) == 120
def build_class_dataset(context):
import concurrent.futures
import ai2thor.controller
import multiprocessing as mp
mp.set_start_method("spawn")
controller = ai2thor.controller.Controller()
executor = concurrent.futures.ProcessPoolExecutor(max_workers=4)
futures = []
for scene in controller.scene_names():
print("processing scene %s" % scene)
futures.append(executor.submit(class_dataset_images_for_scene, scene))
for f in concurrent.futures.as_completed(futures):
scene = f.result()
print("scene name complete: %s" % scene)
# sometimes crashes here for placing mug onto table top which should be fine except distance?
# import pdb;pdb.set_trace()
print(e)
test = 5
reward = calculate_reward(mug_id)
break
else:
action = ACTION_SPACE[action_int]
event = controller.step(action)
return event, reward, is_episode_finished(t)
# todo add if cup is visible to agent?
if __name__ == '__main__':
controller = ai2thor.controller.Controller()
controller.start()
controller.reset('FloorPlan28')
event = controller.step(dict(action='Initialize', gridSize=0.25))
mugs = [obj for obj in event.metadata['objects'] if obj['objectType'] == 'Mug']
mugs_ids_collected_and_placed = set()
# Create replay memory which will store the transitions
memory = ReplayMemory(capacity=replay_memory_size)
if load_model:
print("Loading model from: ", model_savefile)
model = torch.load(model_savefile)
else:
model = Net(len(ACTION_SPACE)).double()
os.kill(self.unity_pid, signal.SIGKILL)
class BFSSearchPoint:
def __init__(self, start_position, move_vector, heading_angle=0.0, horizon_angle=0.0):
self.start_position = start_position
self.move_vector = defaultdict(lambda: 0.0)
self.move_vector.update(move_vector)
self.heading_angle = heading_angle
self.horizon_angle = horizon_angle
def target_point(self):
x = self.start_position['x'] + self.move_vector['x']
z = self.start_position['z'] + self.move_vector['z']
return dict(x=x, z=z)
class BFSController(Controller):
def __init__(self, grid_size=0.25):
super(BFSController, self).__init__()
self.rotations = [0, 90, 180, 270]
self.horizons = [330, 0, 30]
self.allow_enqueue = True
self.queue = deque()
self.seen_points = []
self.visited_seen_points = []
self.grid_points = []
self.grid_size = grid_size
self._check_visited = False
self.distance_threshold = self.grid_size / 5.0
def visualize_points(self, scene_name, wait_key=10):
import cv2