iffyloop / TripoSR-Bake

Generate 3D meshes from a single 2D image using TripoSR, complete with manual geometry editing and texture baking support
The Unlicense
48 stars 0 forks source link

Generation crashes in 02-texture.py on step 4/5 and headless server #1

Closed Nomad1 closed 4 months ago

Nomad1 commented 4 months ago

Hi Thanks for the interesting fork of the TripSR project! I just tested it and can't finish the texture generation since it uses some OpenGL features that are rarely available on servers. Here is the log:

(2/5): Load mesh
(3/5): Generate UVs
(4/5): Rasterize UV atlas
Traceback (most recent call last):
  File "/home/gorbuz/content/TripoSR-Bake/02-texture.py", line 268, in <module>
    main()
  File "/home/gorbuz/content/TripoSR-Bake/02-texture.py", line 245, in main
    rasterize_result = run_rasterize(args, mesh_result, xatlas_result)
  File "/home/gorbuz/content/TripoSR-Bake/02-texture.py", line 53, in run_rasterize
    ctx = moderngl.create_context(standalone=True)
  File "/home/gorbuz/.local/lib/python3.10/site-packages/moderngl/__init__.py", line 1936, in create_context
    ctx.mglo, ctx.version_code = mgl.create_context(glversion=require, mode=mode, **settings)
  File "/home/gorbuz/.local/lib/python3.10/site-packages/glcontext/__init__.py", line 90, in create
    return x11.create_context(**kwargs)
Exception: (standalone) XOpenDisplay: cannot open display

I haven't looked at the code yet, so it might be an easy fix or a key showstopper. Will post there if anything changes.

iffyloop commented 4 months ago

@Nomad1 I don't have time to look into it today, but there are a few references in the ModernGL docs which may be helpful to look at in your case: https://moderngl.readthedocs.io/en/latest/install/using-moderngl-in-ci.html https://moderngl.readthedocs.io/en/latest/techniques/headless_ubuntu_18_server.html

Nomad1 commented 4 months ago

So the fix is relatively easy: a headless machine has to run Xvfb before the second stage. The easiest way is to install xvfb and run it as shown in the articles linked by @iffyloop:

sudo apt-get install xvfb
export DISPLAY=:99.0
Xvfb :99 -screen 0 640x480x24 &
iffyloop commented 4 months ago

Great, glad to hear that worked for you and thanks for sharing here on the issue tracker. Also, I see you posted another issue with a bugfix - really appreciate you contributing back to the project! If you're using this tool heavily and don't mind sharing about your use case then I'd be really interested to hear from you, also may have some advice on how to improve output quality/postprocess (am planning to wrap everything up in a nice one-click GUI app sometime but haven't gotten to it yet). Here is a link to a Discord server for another of my products, if you join this you should be able to DM me (tinydaw) directly: https://discord.com/invite/phPnkQQ37s