Render gym environments to a web browser.
Project description
Render Gym Environments to a Web Browser.
While working on a head-less server, it can be a little tricky to render and see your environment simulation. This script allows you to render your environment onto a browser by just adding one line to your code.
Installation
xvfb-run -s "-screen 0 1400x900x24" bash # Run this if you're using a head-less server.
pip3 install render_browser
Or you can install from the source by cloning this repo and running pip3 install ..
Usage
Put your code in a function and replace your normal env.render() with yield env.render(mode='rgb_array'). Encapsulate this function with the render_browser decorator.
import gym
from render_browser import render_browser
@render_browser
def test_policy(policy):
# Your function/code here.
env = gym.make('Breakout-v0')
obs = env.reset()
while True:
yield env.render(mode='rgb_array')
# ... run policy ...
obs, rew, _, _ = env.step(action)
test_policy(policy)
When you visit your_ip:5000 on your browser, test_policy() will be called and you'll be able to see the rendered environment on your browser window.
TODO
- Stop flask server once the rendering stops - so that render_browser can be called more than once in a single run.
- Allow I/P from keyboard on the browser, useful for teleoperation in robotic environments.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file render_browser-0.3.tar.gz.
File metadata
- Download URL: render_browser-0.3.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b008a7180c92d2f36e4b10d17c0519d83782093b4656891dd71e8f955003499f
|
|
| MD5 |
7fef66ae2de0698ba68d9fd923f36c09
|
|
| BLAKE2b-256 |
f4793ccf8f7d2086cfb8e68c78bf6f30e79a578254e8a57d7f70ce03df93a375
|
File details
Details for the file render_browser-0.3-py3-none-any.whl.
File metadata
- Download URL: render_browser-0.3-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e5bdae2ab7fe7f76cb49fae7c6c96570f4754320a3ea26e588be97b05b7513af
|
|
| MD5 |
7280ee20cb26c07d90b8e3301c8336c4
|
|
| BLAKE2b-256 |
32f42de5ee0cb894f6e0d23940164a6949474938380d1220ad4bfc90e3dd829e
|