Skip to main content

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

render_browser-0.2.tar.gz (2.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

render_browser-0.2-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file render_browser-0.2.tar.gz.

File metadata

  • Download URL: render_browser-0.2.tar.gz
  • Upload date:
  • Size: 2.5 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

Hashes for render_browser-0.2.tar.gz
Algorithm Hash digest
SHA256 473a3674f5becddf29a1e534bd7ec0d71413aa9c9afa716a831aec9aececd483
MD5 127daad50763f36ec525c4429f5470bf
BLAKE2b-256 438c5eee022d6fa3c6a18a125101a01b89b4e89d35efbc04f6405203cf6f9ee9

See more details on using hashes here.

File details

Details for the file render_browser-0.2-py3-none-any.whl.

File metadata

  • Download URL: render_browser-0.2-py3-none-any.whl
  • Upload date:
  • Size: 3.8 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

Hashes for render_browser-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 82cb5598839420ba162aab7a732024abe3ac5fb7ffb9d5a1bc8ccc11728fc5e8
MD5 a78cc740e195c4fe24123ac6bc54c318
BLAKE2b-256 01e2b8d8ef8f64fc855bd56294388536501e45d9c3892c2a4810771f37910647

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page