Ejemplo n.º 1
0
    print('Saved models:')

    # Check paths from hparams, filter out models whose files exist on disk
    filtered_models = {}
    for model in hparams['models']:
        if os.path.isfile(model):
            filtered_models[int(model.split('.')[0].split('_')[-1])] = model
    filtered_models = list(dict(sorted(filtered_models.items(), key=lambda kv: kv[0])).values())

    for index, model in enumerate(filtered_models):
        print(f'{index+1}. {model}')

    # Ask user for a model to choose
    model = filtered_models[int(input('Choose the model (empty - most recent one): ') or '0') - 1]

    print('Starting...')

    # Kill Carla processes if there are any and start simulator
    start_carla(playing=True)

    # Run Carla settings (weather, NPC control) in a separate thread
    pause_object = PauseObject()
    carla_settings = CarlaEnvSettings(0, [pause_object], car_npcs=hparams['car_npcs'])
    carla_settings_thread = Thread(target=carla_settings.update_settings_in_loop, daemon=True)
    carla_settings_thread.start()

    # Play
    print(f'Starting agent ({model})...')
    play_agent(model, pause_object, ConsoleStats.print_short)
Ejemplo n.º 2
0
from sources import get_carla_exec_command, kill_carla_processes, CarlaEnvSettings, CARLA_SETTINGS_STATE

if __name__ == '__main__':

    print('Starting...')

    # overal start time
    start_time = time.time()

    # Create required folders
    os.makedirs('models', exist_ok=True)
    os.makedirs('tmp', exist_ok=True)
    os.makedirs('checkpoint', exist_ok=True)

    # Kill Carla processes if there are any and start simulator
    start_carla()

    # Load hparams if they are being saved by trainer
    hparams = get_hparams()
    if hparams:
        # If everything is ok, update start time by previous running time
        start_time -= hparams['duration']

    # Spawn limited trainer process and get weights' size
    print('Calculating weights size...')
    weights_size = Value('L', 0)
    p = Process(target=check_weights_size,
                args=(hparams['model_path'] if hparams else False,
                      weights_size),
                daemon=True)
    p.start()