Giter Club home page Giter Club logo

Comments (12)

bayerj avatar bayerj commented on July 23, 2024 3

I have been using streamlit for showing the renderings. If you have the html, it is as easy as this:

import streamlit.components.v1 as components
html_string = load_html_rendering()    # this would have to be dumped in a different process
components.html(html_string, height=500)

Then reloading the streamlit app shows it. That's also nice to show all kinds of other analytics. Here is a screenshot of an app I built:

Screenshot 2021-09-07 at 21 25 17

from brax.

erikfrey avatar erikfrey commented on July 23, 2024 2

OK, rendering to pixels is now available, but not yet documented. If you'd like to try it, please check out:

https://github.com/google/brax/blob/main/brax/io/image.py

Please keep in mind this is CPU rendering, so better for eval rendering and other programmatic use cases, rather than training. We will move to GPU/TPU rendering in the future, which should be suitable for training.

In the coming days we'll update our colabs with an example of how to use it, and also make env.render return rgb arrays using this module.

from brax.

EelcoHoogendoorn avatar EelcoHoogendoorn commented on July 23, 2024 1

animation

Didnt spend any time on styling or prettyness yet, but fwiw, here is a torus getting a shove...

from brax.

kayuksel avatar kayuksel commented on July 23, 2024

Yes, that would be a great feature, even if that means not rendering whole batch but a selected one.
If we could render all of them in a single scene (where they do not collide), that could also be good.

from brax.

erikfrey avatar erikfrey commented on July 23, 2024

We have begun work on this. No ETA yet but it's an active priority for us.

from brax.

EelcoHoogendoorn avatar EelcoHoogendoorn commented on July 23, 2024

Interesting; that streamlit thing looks pretty slick.

I was running into the same issues myself; not very familiar with 3JS and I think itd be cleaner to keep the visualization within python. Or at least have multiple rendering options available.

The best thing I can come up with would be to use the high level vispy/scene module; which is a similar high level API to 3JS; though its a bit stale in terms of maintenance... but I suppose its fine for putting some cylinders and boxes on screen. Not sure if there is a better option in the python ecosystem; doing it in raw pyopengl sure would be a kludge.

from brax.

erikfrey avatar erikfrey commented on July 23, 2024

An example of how to use it programmatic rendering is now live at notebooks/environments.ipynb

from brax.

EelcoHoogendoorn avatar EelcoHoogendoorn commented on July 23, 2024

Thanks @erikfrey ! Ive also found use in the programmatic rendering, ive found it a better debug workflow for me in making changes to the physics than having to switch to notebooks and restarting those.

Ive been implementing a vispy based rendering as well; partially as an exercise, but also because im more familiar with it. It a pretty clean 200 lines of code and as far as I can tell its feature-complete in the sense that it works for all envs i tested it on. One thing I like about vispy is that it allows you to drop into raw opengl if required; I can see that being nice if wanting to visualize the rollout of a large batch efficiently using instancing if that becomes useful. Also it works both to generate static images as well as windowed interaction (or in notebooks too i think tho i havnt tested that), and it uses the GPU if available, obviously.

However, not sure what to do with this code. Since I cant/wont promise maintenance with future updates myself perhaps I could create a PR for this inside the experimental submodule?

from brax.

erikfrey avatar erikfrey commented on July 23, 2024

@EelcoHoogendoorn that's awesome! Offhand do you know how fast it renders on CPU only? Can you open a new issue and point us to your example code using vispy? If it works well, I think this would be a candidate for Brax to support, as GPU rendering is on our roadmap.

from brax.

EelcoHoogendoorn avatar EelcoHoogendoorn commented on July 23, 2024

Hmm, just looking at the contributors license, I am reminded I should check this with my employer. Not that this has anything to do with my day job, but they havn't been particularly clear about what they think is ok and what isn't. Hopefully ill get some clarity on that soon.

Didnt test on CPU yet. Given the simplicity of the scenes, I expect it to be fine. In my experience in combining opengl and python, the hard part is not getting bogged down by python overhead. Im currently precomputing all qp->4x4 logic, so an animation loop consist of just updating those 4x4s in the scenegraph, and one draw call per body in the system. I wont vouch for how performant even that will be in python if you are aiming for 1000s of independent non-instanced bodies, but I dont expect fill rate or anything like that to be your biggest enemy, on a modern cpu, with scenes of more typical complexity.

from brax.

EelcoHoogendoorn avatar EelcoHoogendoorn commented on July 23, 2024

Speaking of which, I see that my manager is also on github. Hi @amoshaviv, what are our OS contribution policies like nowadays?

from brax.

yardenas avatar yardenas commented on July 23, 2024

@erikfrey what's the timeline on the GPU rendering project? I might be able to contribute some parts.

from brax.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.