nexusbert commited on
Commit
b08eeb5
·
1 Parent(s): 723e0cd
Files changed (2) hide show
  1. renderer.py +17 -2
  2. requirements.txt +2 -2
renderer.py CHANGED
@@ -1,4 +1,5 @@
1
  import os
 
2
 
3
  import numpy as np
4
  import trimesh
@@ -6,6 +7,14 @@ from typing import Tuple, Optional
6
 
7
  os.environ['PYOPENGL_PLATFORM'] = 'osmesa'
8
 
 
 
 
 
 
 
 
 
9
  try:
10
  import pyrender
11
  except Exception as e:
@@ -16,8 +25,14 @@ except Exception as e:
16
  print("Using EGL platform")
17
  except Exception as e2:
18
  print(f"Warning: pyrender import failed with egl: {e2}")
19
- os.environ['PYOPENGL_PLATFORM'] = 'osmesa'
20
- import pyrender
 
 
 
 
 
 
21
 
22
 
23
  class AvatarRenderer:
 
1
  import os
2
+ import sys
3
 
4
  import numpy as np
5
  import trimesh
 
7
 
8
  os.environ['PYOPENGL_PLATFORM'] = 'osmesa'
9
 
10
+ try:
11
+ from OpenGL import osmesa
12
+ if not hasattr(osmesa, 'OSMesaCreateContextAttribs'):
13
+ osmesa.OSMesaCreateContextAttribs = osmesa.OSMesaCreateContext
14
+ print("Patched OSMesaCreateContextAttribs to use OSMesaCreateContext")
15
+ except Exception as patch_error:
16
+ print(f"Could not patch OSMesa: {patch_error}")
17
+
18
  try:
19
  import pyrender
20
  except Exception as e:
 
25
  print("Using EGL platform")
26
  except Exception as e2:
27
  print(f"Warning: pyrender import failed with egl: {e2}")
28
+ try:
29
+ os.environ['PYOPENGL_PLATFORM'] = 'glx'
30
+ import pyrender
31
+ print("Using GLX platform")
32
+ except Exception as e3:
33
+ print(f"Warning: pyrender import failed with glx: {e3}")
34
+ os.environ['PYOPENGL_PLATFORM'] = 'osmesa'
35
+ import pyrender
36
 
37
 
38
  class AvatarRenderer:
requirements.txt CHANGED
@@ -10,6 +10,6 @@ Pillow
10
  scikit-learn
11
  git+https://github.com/mattloper/chumpy.git
12
  scipy
13
- PyOpenGL
14
- PyOpenGL-accelerate
15
 
 
10
  scikit-learn
11
  git+https://github.com/mattloper/chumpy.git
12
  scipy
13
+ PyOpenGL==3.1.6
14
+ PyOpenGL-accelerate==3.1.6
15