Open Zasa-Y opened 1 year ago
Thanks! I set pyrender
and opengl
to exactly version pyrender==0.1.36, pyopengl==3.1.0
, but still had the error. Then I tried the solution in issue2, it works. The details are as follows:
Modify [site-packages/pyrender/renderer.py] in line 1059-1067:
glRenderbufferStorageMultisample(
GL_RENDERBUFFER, 4, GL_RGBA,
self.viewport_width, self.viewport_height
)
glBindRenderbuffer(GL_RENDERBUFFER, self._main_db_ms)
glRenderbufferStorageMultisample(
GL_RENDERBUFFER, 4, GL_DEPTH_COMPONENT24,
self.viewport_width, self.viewport_height
)
change these two 4 to 1.
Then, use this macro in front of the script to run MESA_GL_VERSION_OVERRIDE=4.1 python grounded_sam_osx_demo.py
Problem solved. Thanks again!
Hi, what's the version of your
pyrender
andopengl
? I also run on a headless device and I do not meet this problem. My setting is:pyrender==0.1.36, pyopengl==3.1.0, python=3.7
. I think you can refer to these two issues: issue1 and issue2.
Okay, happy to here this news :)
I am running this code in ssh environment without display device. I entered the following code:
export CUDA_VISIBLE_DEVICES=0 python grounded_sam_osx_demo.py \ --config GroundingDINO/groundingdino/config/GroundingDINO_SwinT_OGC.py \ --grounded_checkpoint checkpoint/groundingdino_swint_ogc.pth \ --sam_checkpoint checkpoint/sam_vit_h_4b8939.pth \ --osx_checkpoint checkpoint/osx_l_wo_decoder.pth.tar \ --input_image assets/osx/grounded_sam_osx_demo.png \ --output_dir "outputs" \ --box_threshold 0.3 \ --text_threshold 0.25 \ --text_prompt "humans, chairs" \ --device "cuda"
Then I got the following error:
╭─────────────────── Traceback (most recent call last) ─────────────────────╮ │ /workspace/Grounded-Segment-Anything/grounded_sam_osx_demo.py:276 in
│
│ 273 │ for i, label in enumerate(pred_phrases):
│ 274 │ │ if 'person' in label.lower() or 'man' in label.lower():
│ 275 │ │ │ boxes_human.append(boxes_filt[i])
│ ❱ 276 │ rendered_img = mesh_recovery(image, boxes_human)
│ 277 │ cv2.imwrite(os.path.join(output_dir, "grounded_sam_osx_output.jpg"), rendered_img)
│ 278 │
│ 279 │ # draw output image
│
│ /workspace/Grounded-Segment-Anything/grounded_sam_osx_demo.py:175 in mesh_recovery
│
│ 172 │ │ focal = [cfg.focal[0] / cfg.input_body_shape[1] bbox[2], cfg.focal[1] / cfg.in
│ 173 │ │ princpt = [cfg.princpt[0] / cfg.input_body_shape[1] bbox[2] + bbox[0],
│ 174 │ │ │ │ cfg.princpt[1] / cfg.input_body_shape[0] bbox[3] + bbox[1]]
│ ❱ 175 │ │ renderedimg, = render_mesh(vis_img[:, :, ::-1], mesh, smpl_x.face, {'focal':
│ 176 │ │ vis_img = rendered_img.copy()
│ 177 │
│ 178 │ return rendered_img
│
│ /workspace/Grounded-Segment-Anything/grounded-sam-osx/utils/vis.py:152 in render_mesh
│
│ 149 │ scene.add(camera)
│ 150 │
│ 151 │ # renderer
│ ❱ 152 │ renderer = pyrender.OffscreenRenderer(viewport_width=img.shape[1], viewport_height=i
│ 153 │
│ 154 │ # light
│ 155 │ light = pyrender.DirectionalLight(color=[1.0, 1.0, 1.0], intensity=0.8)
│
│ /opt/conda/envs/pytorch-1.12/lib/python3.9/site-packages/pyrender/offscreen.py:31 in init
│
│ 28 │ │
│ 29 │ │ self._platform = None
│ 30 │ │ self._renderer = None
│ ❱ 31 │ │ self._create()
│ 32 │
│ 33 │ @property
│ 34 │ def viewport_width(self):
│
│ /opt/conda/envs/pytorch-1.12/lib/python3.9/site-packages/pyrender/offscreen.py:149 in _create
│
│ 146 │ │ │ raise ValueError('Unsupported PyOpenGL platform: {}'.format(
│ 147 │ │ │ │ os.environ['PYOPENGL_PLATFORM']
│ 148 │ │ │ ))
│ ❱ 149 │ │ self._platform.init_context()
│ 150 │ │ self._platform.make_current()
│ 151 │ │ self._renderer = Renderer(self.viewport_width, self.viewport_height)
│ 152
│
│ /opt/conda/envs/pytorch-1.12/lib/python3.9/site-packages/pyrender/platforms/egl.py:186 in
│ init_context
│
│ 183 │ │ assert eglBindAPI(EGL_OPENGL_API)
│ 184 │ │
│ 185 │ │ # Create an EGL context
│ ❱ 186 │ │ self._egl_context = eglCreateContext(
│ 187 │ │ │ self._egl_display, configs[0],
│ 188 │ │ │ EGL_NO_CONTEXT, context_attributes
│ 189 │ │ )
│
│ /opt/conda/envs/pytorch-1.12/lib/python3.9/site-packages/OpenGL/platform/baseplatform.py:402 in
│ call
│
│ 399 │ │ return None
│ 400 │ def call( self, args, *named ):
│ 401 │ │ if self.load():
│ ❱ 402 │ │ │ return self( args, **named )
│ 403 │ │ else:
│ 404 │ │ │ from OpenGL import error
│ 405 │ │ │ raise error.NullFunctionError(
│
│ in OpenGL_accelerate.errorchecker._ErrorChecker.glCheckError:58
╰─────────────────────────────────────────────────────────╯
GLError: GLError(
err = 12297,
baseOperation = eglCreateContext,
cArguments = (
<OpenGL._opaque.EGLDisplay_pointer object at 0x7ff37e08b440>,
<OpenGL._opaque.EGLConfig_pointer object at 0x7ff37e08b4c0>,
<OpenGL._opaque.EGLContext_pointer object at 0x7ff37df985c0>,
<OpenGL.arrays.lists.c_int_Array_7 object at 0x7ff37e08b5c0>,
),
result = <OpenGL._opaque.EGLContext_pointer object at 0x7ff37e08bac0>
)
Please how can I solve this problem?