def main(args):
    cfg = default_cfg.clone()
    cfg.merge_from_file(args.config_file)
    cfg.merge_from_list(args.opts)
    cfg.freeze()

    output_folder = mkdir(cfg.OUTPUT_FOLDER)
    assert_proper_output_dir(args.config_file, output_folder)

    start_time = time.time()

    processes = []
    case_names = cfg.CASE_NAMES
    if len(case_names) == 0:
        case_names = sorted([dir_name for dir_name in os.listdir(cfg.ANNOTATION_FOLDER) if
                             os.path.isdir(os.path.join(cfg.ANNOTATION_FOLDER, dir_name)) and "." not in dir_name])
    if args.start_index is None:
        start_index = get_host_id() % args.stride
    else:
        start_index = args.start_index
    case_names = case_names[start_index::args.stride]

    manager = Manager()
    n_filter = manager.Semaphore(1)
    args.n_filter = n_filter

    for case_name in case_names:
        p = Process(target=run_updater, args=(cfg, args, case_name))
        processes.append(p)
        p.start()
        break  #ERASE
    for p in processes:
        p.join()

    if not args.only_plot:
        for case_name in case_names:
            results = read_serialized(os.path.join(output_folder, "results", "{}.json".format(case_name)))
            print(case_name,
                  {key: result for key, result in results[case_name].items() if key in ["sum", "mean", "max"]})

    print('| finish with time ', time.time() - start_time)
Esempio n. 2
0
    scene = dict(case_name=case_name,
                 objects=objects,
                 occluders=occluders,
                 sim=sim,
                 rendering=rendering,
                 video=video)
    write_serialized(scene,
                     os.path.join(TRAIN_CONFIG_FOLDER, case_name + ".yaml"))
    return scene


def main(case_id, args):
    while True:
        config = generate_config("train_{:05d}".format(case_id), args)
        valid = generate(EasyDict(config), args)
        if valid:
            break


if __name__ == '__main__':
    args = parse_args()
    catch_abort()
    worker_args = []
    if args.start_index is None:
        args.start_index = args.start + get_host_id() % args.stride
    for i in range(args.start_index, args.end, args.stride):
        worker_args.append((i, args))

    with Pool(2) as p:
        p.starmap(main, worker_args)