コード例 #1
0
def main(argv):
  config = {'width': FLAGS.width,
            'height': FLAGS.height,
            'graph_width': FLAGS.width,
            'graph_height': FLAGS.height,
            'graph_zoom': 1,
            'full_graph': True,
            'proportion_of_panos_with_coins': 0.0,
            'action_spec': 'streetlearn_fast_rotate',
            'observations': ['view_image', 'graph_image', 'yaw']}
  with open(FLAGS.list_pano_ids_yaws, 'r') as f:
    lines = f.readlines()
    pano_ids_yaws = [(line.split('\t')[0], float(line.split('\t')[1]))
                     for line in lines]
  config = default_config.ApplyDefaults(config)
  game = coin_game.CoinGame(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, pano_ids_yaws)
コード例 #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,
        '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)