Пример #1
0
def main(argv):
  config = {'width': FLAGS.width,
            'height': FLAGS.height,
            'field_of_view': FLAGS.field_of_view,
            'graph_width': FLAGS.width,
            'graph_height': FLAGS.height,
            'graph_zoom': FLAGS.graph_zoom,
            'graph_black_on_white': FLAGS.graph_black_on_white,
            'goal_timeout': FLAGS.frame_cap,
            'frame_cap': FLAGS.frame_cap,
            'full_graph': (FLAGS.start_pano == ''),
            'start_pano': FLAGS.start_pano,
            'min_graph_depth': FLAGS.graph_depth,
            'max_graph_depth': FLAGS.graph_depth,
            'max_cache_size': FLAGS.max_cache_size,
            'proportion_of_panos_with_coins':
                FLAGS.proportion_of_panos_with_coins,
            'action_spec': 'streetlearn_fast_rotate',
            'observations': ['view_image_hwc', 'graph_image_hwc',
                             'target_latlng', 'prev_reward', 'prev_action']}
  config = default_config.ApplyDefaults(config)
  game = courier_game.CourierGame(config)
  env = streetlearn.StreetLearn(FLAGS.dataset_path, config, game)
  env.reset()
  pygame.init()
  screen = pygame.display.set_mode((FLAGS.width, FLAGS.height * 2))
  loop(env, screen)
Пример #2
0
def main(argv):
    config = {
        'width': FLAGS.width,
        'height': FLAGS.height,
        'field_of_view': FLAGS.field_of_view,
        'graph_width': FLAGS.width,
        'graph_height': FLAGS.height,
        'graph_zoom': FLAGS.graph_zoom,
        'graph_black_on_white': FLAGS.graph_black_on_white,
        'goal_timeout': FLAGS.frame_cap,
        'frame_cap': FLAGS.frame_cap,
        'full_graph': (FLAGS.start_pano == ''),
        'start_pano': FLAGS.start_pano,
        'min_graph_depth': FLAGS.graph_depth,
        'max_graph_depth': FLAGS.graph_depth,
        'max_cache_size': FLAGS.max_cache_size,
        'proportion_of_panos_with_coins': FLAGS.proportion_of_panos_with_coins,
        'action_spec': 'streetlearn_fast_rotate',
        'observations': ['view_image_hwc', 'graph_image_hwc', 'yaw', 'pitch']
    }
    config = default_config.ApplyDefaults(config)
    # Create as many configs and games as the batch size.
    games = []
    configs = []
    for k in range(FLAGS.batch_size):
        this_config = copy.copy(config)
        this_config['seed'] = k
        configs.append(this_config)
        games.append(courier_game.CourierGame(this_config))
    env = batched_streetlearn.BatchedStreetLearn(
        FLAGS.dataset_path,
        configs,
        games,
        num_env_per_shared_cache=FLAGS.num_env_per_shared_cache)
    env.reset()
    pygame.init()
    screen = pygame.display.set_mode(
        (FLAGS.width * FLAGS.batch_size, FLAGS.height * 2))
    loop(env, screen)
Пример #3
0
def main(argv):
    config = {
        'width':
        FLAGS.width,
        'height':
        FLAGS.height,
        'graph_width':
        FLAGS.width,
        'graph_height':
        FLAGS.height,
        'graph_zoom':
        1,
        'goal_timeout':
        FLAGS.frame_cap,
        'frame_cap':
        FLAGS.frame_cap,
        'full_graph': (FLAGS.start_pano == ""),
        'start_pano':
        FLAGS.start_pano,
        'min_graph_depth':
        FLAGS.graph_depth,
        'max_graph_depth':
        FLAGS.graph_depth,
        'proportion_of_panos_with_coins':
        FLAGS.proportion_of_panos_with_coins,
        'observations': [
            'view_image', 'graph_image', 'yaw', 'pitch', 'latlng',
            'target_latlng'
        ]
    }
    config = default_config.ApplyDefaults(config)
    game = courier_game.CourierGame(config)
    env = streetlearn.StreetLearn(FLAGS.dataset_path, config, game)
    env.reset()
    pygame.init()
    screen = pygame.display.set_mode((FLAGS.width, FLAGS.height * 2))
    loop(env, screen)
Пример #4
0
def main(argv):
    config = {
        'width':
        FLAGS.width,
        'height':
        FLAGS.height,
        'field_of_view':
        FLAGS.field_of_view,
        'graph_width':
        FLAGS.width,
        'graph_height':
        FLAGS.height,
        'graph_zoom':
        FLAGS.graph_zoom,
        'graph_black_on_white':
        FLAGS.graph_black_on_white,
        'show_shortest_path':
        FLAGS.show_shortest_path,
        'goal_timeout':
        FLAGS.frame_cap,
        'frame_cap':
        FLAGS.frame_cap,
        'full_graph': (FLAGS.start_pano == ''),
        'start_pano':
        FLAGS.start_pano,
        'min_graph_depth':
        FLAGS.graph_depth,
        'max_graph_depth':
        FLAGS.graph_depth,
        'reward_at_waypoint':
        FLAGS.reward_at_waypoint,
        'reward_at_goal':
        FLAGS.reward_at_goal,
        'instruction_file':
        FLAGS.instruction_file,
        'num_instructions':
        FLAGS.num_instructions,
        'max_instructions':
        FLAGS.max_instructions,
        'proportion_of_panos_with_coins':
        FLAGS.proportion_of_panos_with_coins,
        'observations': [
            'view_image_hwc', 'graph_image_hwc', 'yaw', 'thumbnails', 'pitch',
            'instructions', 'latlng', 'target_latlng'
        ]
    }
    if FLAGS.hide_goal:
        config['color_for_goal'] = color.Color(1.0, 1.0, 1.0)
    config = default_config.ApplyDefaults(config)
    if FLAGS.game == 'coin_game':
        game = coin_game.CoinGame(config)
    elif FLAGS.game == 'courier_game':
        game = courier_game.CourierGame(config)
    elif FLAGS.game == 'goal_instruction_game':
        game = goal_instruction_game.GoalInstructionGame(config)
    elif FLAGS.game == 'incremental_instruction_game':
        game = incremental_instruction_game.IncrementalInstructionGame(config)
    elif FLAGS.game == 'step_by_step_instruction_game':
        game = step_by_step_instruction_game.StepByStepInstructionGame(config)
    else:
        print('Unknown game: [{}]'.format(FLAGS.game))
        print('Run with --help for available options.')
        return
    env = streetlearn.StreetLearn(FLAGS.dataset_path, config, game)
    env.reset()

    # Configure pygame.
    pygame.init()
    pygame.font.init()
    if FLAGS.game == 'coin_game' or FLAGS.game == 'courier_game':
        subsampling = 1
        x_max = FLAGS.width
        y_max = FLAGS.height * 2
        logging.info('Rendering images at %dx%d', x_max, y_max)
    else:
        subsampling = int(np.ceil((FLAGS.max_instructions + 1) / 2))
        x_max = FLAGS.width + int(FLAGS.width / subsampling) + FLAGS.width_text
        y_max = FLAGS.height * 2
        logging.info('Rendering images at %dx%d, thumbnails subsampled by %d',
                     x_max, y_max, subsampling)
    screen = pygame.display.set_mode((x_max, y_max))
    font = pygame.font.SysFont('arial', FLAGS.font_size)

    loop(env, screen, x_max, y_max, subsampling, font)