示例#1
0
文件: run_demo.py 项目: rythei/Guide
def create_env(house="02f594bb5d8c5871bde0d8c8db20125b"):
    api = objrender.RenderAPI(w=600, h=450, device=0)
    cfg = create_default_config('/home/rythei/guide/SUNCG/house')

    if house is None:
        env = Environment(api, TEST_HOUSE, cfg)
    else:
        env = Environment(api, house, cfg)
    env.reset()

    return env
示例#2
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('--data_file',
                        default='../path_data/cleaned_human_demo_data.json',
                        type=str)
    parser.add_argument('--suncg_house_dir',
                        default='../../suncg_data/house',
                        type=str)
    parser.add_argument('--mode',
                        default='rgb',
                        type=str,
                        choices=['rgb', 'semantic', 'instance', 'depth'])
    parser.add_argument('--demo_id', default=0, type=int)
    parser.add_argument('--width', type=int, default=800)
    parser.add_argument('--height', type=int, default=600)
    parser.add_argument('--device', type=int, default=0)
    args = parser.parse_args()
    with open(args.data_file, 'r') as f:
        data = json.load(f)
    demo = data[args.demo_id]

    cfg = create_default_config('.')
    api = objrender.RenderAPI(args.width, args.height, device=args.device)
    api.printContextInfo()

    obj_path = pathlib.Path(args.suncg_house_dir).joinpath(
        demo['house_id'], 'house.obj')
    print('You select house id: {0:s}'.format(demo['house_id']))
    api.loadScene(str(obj_path.resolve()), cfg['modelCategoryFile'],
                  cfg['colorFile'])
    cam = api.getCamera()
    api_mode = getattr(RenderMode, args.mode.upper())
    api.setMode(api_mode)

    for t in count():
        mat = np.array(api.render())
        if api_mode == RenderMode.DEPTH:
            infmask = mat[:, :, 1]
            mat = mat[:, :, 0] * (infmask == 0)
        else:
            mat = mat[:, :, ::-1]

        if api_mode == RenderMode.INSTANCE:
            center_rgb = mat[args.height // 2, args.width // 2, ::-1]
            center_instance = api.getNameFromInstanceColor(
                center_rgb[0], center_rgb[1], center_rgb[2])
            print("Instance ID in the center: ", center_instance)
        exit_flag = key_control(mat, cam)
        if exit_flag:
            break
示例#3
0
    if args.datasets:
        pbrs_houses = set()
        for dset_path in args.datasets:
            with open(dset_path, 'r') as f:
                dset = json.load(f)
            dset_houses = {cam['house_id'] for cam in dset}
            pbrs_houses |= dset_houses
        pbrs_houses = sorted(pbrs_houses)
    else:
        pbrs_houses = sorted(os.listdir(osp.join(args.suncg_dir, 'camera')))

    if args.nbr_houses and args.nbr_houses < len(pbrs_houses):
        pbrs_houses = pbrs_houses[:args.nbr_houses]

    global cfg
    cfg = create_default_config('.', colormap='fine')
    if args.model_blacklist:
        cfg['modelBlacklistFile'], cfg['catBlacklist'], cfg[
            'modelBlacklist'] = gen_blacklist(args.model_blacklist,
                                              cfg['modelCategoryFile'])
    else:
        cfg['catBlacklist'] = cfg['modelBlacklist'] = set()

    global logger
    logger = setup_mp_logger(args.logfile)

    invalid_houses = InvalidHouses(osp.join(result_dir, 'invalid.json'))
    manager, invalid_houses_proxy = invalid_houses.get_proxy()

    #Run rendering
    run_mp_house3d(devices=args.devices,
示例#4
0
from itertools import count

from House3D import objrender, create_default_config
from House3D.objrender import RenderMode

if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('obj')
    parser.add_argument('--width', type=int, default=800)
    parser.add_argument('--height', type=int, default=600)
    parser.add_argument('--device', type=int, default=0)
    parser.add_argument('--interactive', action='store_true',
                        help='run interactive rendering (does not work under ssh)')
    args = parser.parse_args()

    cfg = create_default_config('.')

    api = objrender.RenderAPI(args.width, args.height, device=args.device)
    api.printContextInfo()

    api.loadScene(args.obj, cfg['modelCategoryFile'], cfg['colorFile'])
    cam = api.getCamera()

    modes = [RenderMode.RGB, RenderMode.SEMANTIC, RenderMode.INSTANCE, RenderMode.DEPTH]
    for t in count():
        mode = modes[t % len(modes)]
        api.setMode(mode)
        mat = np.array(api.render())
        if mode == RenderMode.DEPTH:
            infmask = mat[:, :, 1]
            mat = mat[:, :, 0] * (infmask == 0)
示例#5
0
    1. GTX 1080, EGL backend
    1proc, 1gpu: 708fps
    3proc, 1gpu: 556x3fps, 52% GPU util
    5proc, 1gpu: 430x5fps, 71% GPU util
    """
    parser = argparse.ArgumentParser()
    parser.add_argument('obj')
    parser.add_argument('--num-proc', type=int, default=1)
    parser.add_argument('--num-gpu', type=int, default=1)
    parser.add_argument('--width', type=int, default=120)
    parser.add_argument('--height', type=int, default=90)
    args = parser.parse_args()

    prefix = os.path.dirname(os.path.dirname(args.obj))
    house_id = os.path.basename(os.path.dirname(args.obj))

    global cfg
    cfg = create_default_config(prefix)

    procs = []
    for i in range(args.num_proc):
        device = i % args.num_gpu
        procs.append(mp.Process(target=worker, args=(i, house_id, device)))

    for p in procs:
        p.start()

    for p in procs:
        p.join()