parser = argparse.ArgumentParser() parser.add_argument("-d", "--demo", required=True, help="Dir name to scan for demos") parser.add_argument("-e", "--env", default=DEFAULT_ENV, help="Environment name to load, default=" + DEFAULT_ENV) parser.add_argument("-o", "--output", required=True, help="Output prefix to save images") args = parser.parse_args() demo = vnc_demo.load_demo(args.demo, args.env, read_text=True) print("Loaded %d demo samples" % len(demo)) env = gym.make(args.env) env = universe.wrappers.experimental.SoftmaxClickMouse(env) for idx, (obs, action) in enumerate(demo): fname = "%s_%04d.png" % (args.output, idx) action_coords = env._points[action] img, text = obs wob_vnc.save_obs(img, fname, action_coords) print(fname, text) pass
help="Host with docker containers") args = parser.parse_args() device = torch.device("cuda" if args.cuda else "cpu") env_name = args.env if not env_name.startswith('wob.mini.'): env_name = "wob.mini." + env_name name = env_name.split('.')[-1] + "_" + args.name writer = SummaryWriter(comment="-wob_click_mm_" + name) saves_path = os.path.join(SAVES_DIR, name) os.makedirs(saves_path, exist_ok=True) demo_samples = None if args.demo: demo_samples = vnc_demo.load_demo(args.demo, env_name, read_text=True) if not demo_samples: demo_samples = None else: print("Loaded %d demo samples, will use them during training" % len(demo_samples)) env = gym.make(env_name) env = universe.wrappers.experimental.SoftmaxClickMouse(env) env = wob_vnc.MiniWoBCropper(env, keep_text=True) wob_vnc.configure( env, wob_vnc.remotes_url(port_ofs=args.port_ofs, hostname=args.host, count=REMOTES_COUNT))
parser.add_argument("--demo", help="Demo dir to load. Default=No demo") parser.add_argument("--host", default='localhost', help="Host with docker containers") args = parser.parse_args() env_name = args.env if not env_name.startswith('wob.mini.'): env_name = "wob.mini." + env_name name = env_name.split('.')[-1] + "_" + args.name writer = SummaryWriter(comment="-wob_click_" + name) saves_path = os.path.join(SAVES_DIR, name) os.makedirs(saves_path, exist_ok=True) demo_samples = None if args.demo: demo_samples = vnc_demo.load_demo(args.demo, env_name) if not demo_samples: demo_samples = None else: print("Loaded %d demo samples, will use them during training" % len(demo_samples)) env = gym.make(env_name) env = universe.wrappers.experimental.SoftmaxClickMouse(env) env = wob_vnc.MiniWoBCropper(env) wob_vnc.configure(env, wob_vnc.remotes_url(port_ofs=args.port_ofs, hostname=args.host, count=REMOTES_COUNT)) net = model_vnc.Model(input_shape=wob_vnc.WOB_SHAPE, n_actions=env.action_space.n) if args.cuda: net.cuda() print(net) optimizer = optim.Adam(net.parameters(), lr=LEARNING_RATE, eps=1e-3)
discr = env._action_to_discrete(event) discr2 = vnc_demo.mouse_to_action(x, y) assert discr == discr2 pass if __name__ == "__main__": # test_mouse_coords() parser = argparse.ArgumentParser() parser.add_argument("-d", "--demo", required=True, help="Dir name to scan for demos") parser.add_argument("-e", "--env", default=DEFAULT_ENV, help="Environment name to load, default=" + DEFAULT_ENV) parser.add_argument("-o", "--output", required=True, help="Output prefix to save images") args = parser.parse_args() demo = vnc_demo.load_demo(args.demo, args.env, read_text=True) print("Loaded %d demo samples" % len(demo)) env = gym.make(args.env) env = universe.wrappers.experimental.SoftmaxClickMouse(env) for idx, (obs, action) in enumerate(demo): fname = "%s_%04d.png" % (args.output, idx) action_coords = env._points[action] img, text = obs wob_vnc.save_obs(img, fname, action_coords) print(fname, text) pass