Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot visualize inside Google Colab #132

Open
monacv opened this issue Mar 19, 2021 · 5 comments
Open

cannot visualize inside Google Colab #132

monacv opened this issue Mar 19, 2021 · 5 comments

Comments

@monacv
Copy link

monacv commented Mar 19, 2021

Hello,

Could you please guide me how to interactively or even statically visualize the obj file inside Google Colab?

import pywavefront
from pywavefront import visualization

obj = pywavefront.Wavefront('Data/examples/plane.obj')

visualization.draw(obj)

Error is:


---------------------------------------------------------------------------

NoSuchDisplayException                    Traceback (most recent call last)

<ipython-input-33-fcec2c1ce422> in <module>()
      1 import pywavefront
----> 2 from pywavefront import visualization
      3 
      4 obj = pywavefront.Wavefront('Data/examples/plane.obj')
      5 

7 frames

/usr/local/lib/python3.7/dist-packages/pyglet/canvas/xlib.py in __init__(self, name, x_screen)
    121         self._display = xlib.XOpenDisplay(name)
    122         if not self._display:
--> 123             raise NoSuchDisplayException('Cannot connect to "%s"' % name)
    124 
    125         screen_count = xlib.XScreenCount(self._display)

NoSuchDisplayException: Cannot connect to "None"

Screenshot from 2021-03-18 20-40-55

@greenmoss
Copy link
Collaborator

I would interpret that to mean it is looking for an X11 server. Does Google Colab support that?

I did a quick search and turned up this Stackoverflow:

https://stackoverflow.com/questions/60886590/how-to-setup-pyglet-to-work-with-manim-in-colab

Seems Colab may support pyvirtualdisplay. Can you give that a shot?

@monacv
Copy link
Author

monacv commented Mar 19, 2021

Hi Kurt,

Thanks a lot for your response. So pyvirtualdisplay didn't work for me following the StackOverflow example
also not sure how to connect it with the visualization of piglet

could you please elaborate with a code example?
Screenshot from 2021-03-18 21-18-31
Screenshot from 2021-03-18 21-18-25

@greenmoss
Copy link
Collaborator

Looks like you need Xvfb (X virtual frame buffer). Is that something you have to manually add in Colab?

I did another search, and in this answer the person is first using apt to install xvfb:

https://stackoverflow.com/questions/50107530/how-to-render-openai-gym-in-google-colab

Can you try that?

@einarf
Copy link
Member

einarf commented Mar 19, 2021

Could be easier to use trimesh for this : https://github.com/mikedh/trimesh

It does support inline visualization with tree.js. I have not used Google Colab much but I assume things working in notebook will also work there.

@monacv
Copy link
Author

monacv commented Mar 19, 2021

@einarf yeah I initially tried that and got this error
Screenshot from 2021-03-19 14-28-50

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants