Comments (8)
Should work to do plt.imshow(env.render(mode='rgb_array')) inside of your notebook cell
from gym.
Here's one approach:
from gym.
Note import matplotlib.pyplot plt.imshow(env.render(mode='rgb_array'))
does not work in either notebook 5.0.0 or 5.1.0. I honestly don't think it would have worked in earlier editions, but some stuff with mimetypes have changed so I don't know if that's affecting it.
But should this have ever worked?:
from matplotlib import pyplot as plt
# plt.ion()
%matplotlib inline
import gym
env = gym.make('CartPole-v0')
env.reset()
for _ in range(1000):
plt.imshow(env.render(mode='rgb_array'))
env.step(env.action_space.sample()) # take a random action
from gym.
Wrote up a solution on StackOverflow:
from gym.
That sounds very exciting. I don't think we necessarily need pyglet support; the rgb_array
rendering mode might be interesting here -- it just returns the raw image, which we usually use for video encoding. As a first idea, you might want to try using env.render(mode='rgb_array')
, and then render the resulting np.ndarray
using e.g. matplotlib inside of IPython.
We're definitely open to merging something that makes this even easier, though!
from gym.
(Going to close for now; let us know if we can help with anything!)
from gym.
I can vouch for the solution by @patrickmineault as working, but I'm thinking this should be possible by using the IPython display mech for handling general mimetypes so long as the right spot can be hooked into directly.
from gym.
I avoided the matplotlib issues by simply doing:
import PIL
PIL.Image.fromarray(env.render(mode='rgb_array')).resize((320, 420))
There may still be an issue on servers without DISPLAYS, but that seems like a separate issue.
from gym.
Related Issues (20)
- Deepcopy env not working as expected HOT 6
- Segmentation Fault while trying to run Rviz in a wsl enviorment using VcXsrv HOT 1
- Is there any tools for changing the hyperparameter of the mujoco environment? HOT 1
- [Question] Modifying and Analyzing mujoco's qpos and qvel HOT 1
- installing gym[toy_text] bug HOT 1
- Could not find platform dependent libraries and kernel always busy. Im waiting and kernel still busy but my energyplus was completed succesfully. HOT 4
- Env.reset () is error HOT 2
- [Bug Report] Getting Error from "D:\PongDQN_RL\venv\lib\site-packages\gym\wrappers\compatibility.py" HOT 12
- [Question] Custom dtype in observation space
- [Bug Report] pusher-v4 in the environment doesn't collide the object for the fork HOT 1
- [Question] How to verify who is the winner of a game? HOT 3
- [bug] OpenAI gym set_level(50) not disabling logs HOT 1
- [Bug Report] Humanoidv4 doesnt include contact_cost in code, but still present in documentation HOT 4
- [Question] I am implementing a DQN on Atari. I have some shape related problems. HOT 1
- [Question] MUJOCO environment info ERROR in the gym documentation website HOT 2
- [Question] How do I edit the leaderboard? HOT 1
- [Question] AsyncVectorEnv getting hung up as `pip.recv()` not returning anything for `_check_observation_spaces` HOT 3
- [Question] Question title
- gym.error.UnregisteredEnv: No registered env with id: meme-v0 HOT 1
- AttributeError: attempted to get missing private attribute '_domain_file' HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gym.