Comments (11)
Hi Henry,
I'm not seeing that behavior anywhere on my machine. I didn't implement any multithreading in my load code, so if it's happening, it's happening in trimesh
. Can you give me an example of the mesh file you're trying to load?
from pyrender.
Hi Matt,
Here's my code. When I comment out the second line (the pyrender command) but keep the trimesh command, it appears to only use up a single core of my CPU as expected.
tm = trimesh.base.Trimesh(vertices=smpl_vertices, faces=smpl_faces)
smpl_mesh = pyrender.Mesh.from_trimesh(tm, material=self.human_mat, wireframe = True)
zip file with numpy arrays for faces and vertices below:
verts_faces.zip
There are about 7000 vertices and a similar number of faces.
Henry
from pyrender.
Hey Henry, that mesh looks pretty reasonable on my computer, I didn't notice any core-maxing with the latest versions of trimesh/pyrender. What does it look like if you try running it with a profiler, like cProfile or pyinstrument?
In [1]: import numpy as np
In [2]: import trimesh
In [3]: v = np.load('smpl_vertices.npy')
In [4]: f = np.load('smpl_faces.npy')
In [5]: %timeit m = trimesh.Trimesh(v, f)
The slowest run took 10.21 times longer than the fastest. This could mean that an intermediate result is being cached.
100 loops, best of 3: 2.67 ms per loop
In [6]: m = trimesh.Trimesh(v, f)
In [8]: import pyrender
In [9]: %timeit p = pyrender.Mesh.from_trimesh(m)
The slowest run took 25.02 times longer than the fastest. This could mean that an intermediate result is being cached.
1000 loops, best of 3: 243 µs per loop
from pyrender.
Hi,
So I think I have found how I can reproduce the problem better, but I have not solved it and it does not appear to happen when using pyrender and trimesh in isolation from the rest of my program.
If I don't regenerate the mesh and just use it as you did, there is no problem. However, each time I loop I'm regenerating the mesh vertices and faces using the SMPL human parametrization. If I print out the mesh verts and faces to the terminal, use the trimesh command, etc, there is no extra CPU usage. But If I regenerate the mesh vertices and use Mesh.from_trimesh()
concurrently, the problem exists.
Here are screenshots showing a hacky profiling:
Normal case:
Smpl regen + trimesh + pyrender: (problem case, it looks ludicrous on the 32 core machine)
So weird.
Henry C.
from pyrender.
Anyway, thanks to Matt and Mike for the quick responses!
Henry C.
from pyrender.
Oh interesting. One thing it could be is auto-generated vertex normals requested in the from_trimesh
call. Those are calculated with a scipy sparse matrix which is suspiciously fast and heavily parallelized. Maybe try with smooth=False
and see if it still happens? IE:
smpl_mesh = pyrender.Mesh.from_trimesh(tm, material=self.human_mat, wireframe = True, smooth=False)
from pyrender.
Mike,
Interesting thought.
I tried setting smooth to False- doesn't work, though. Same problem.
Henry C.
from pyrender.
Also,
I tried changing the vertex positions manually every loop rather than having the SMPL parameterization do it - by adding a very small increment to the float value of each vertex x,y,z of 0.00001. In that case, the problem goes away. So it appears it's not just a matter of recreating arbitrary vertices and faces, rather it's something to do with the SMPL calculation.
Henry C.
from pyrender.
Closing this as it seems to not be an issue that can be fixed in pyrender.
from pyrender.
I have to render a series of meshes[path_objs
]. When I do as the following, memory grows until it crashes. How to avoid this situation?
Memory growth seems to be related to mesh_pr = pyrender.Mesh.from_trimesh(mesh_tri)
.
THANKS~
scene = pyrender.Scene(bg_color=[1.0, 1.0, 1.0, 1.0], ambient_light=(0.5, 0.5, 0.5))
cam = pyrender.PerspectiveCamera(yfov=np.pi / 4., znear=0.05, zfar=5.0, aspectRatio=1.0)
scene.add(cam, pose=np.eye(4))
r = pyrender.OffscreenRenderer(viewport_width=1080,
viewport_height=1080,
point_size=1.0)
for path_obj in path_objs:
mesh_tri = trimesh.load(path_obj, process=False)
mesh_pr = pyrender.Mesh.from_trimesh(mesh_tri)
node_mesh = pyrender.Node(mesh=mesh_pr)
scene.add_node(node_mesh)
color, depth = r.render(scene)
imageio.imwrite(path_img, color)
imageio.imwrite(path_img[:-4] + '_d.png', (depth * 1000).astype(np.uint16))
scene.remove_node(node_mesh)
from pyrender.
@mikedh could you please let me know where you downloaded the smpl_vertices.npy
from?
I cannot find it on SMPL website Download page
from pyrender.
Related Issues (20)
- Rendering light HOT 2
- error in material.SpecularGlossinessMaterial()
- Request for Assistance: Obtaining Pixel-to-Face Index in Pyrender
- BROKEN LINK: Google colab notebooks HOT 1
- Invalid device ID (0), Pyrender NOT working on Python 3.10 HOT 5
- Inverted triangles?
- How to retrieve intrinsic camera parameters from PerspectiveCamera
- Textures rendering slanted
- Sphere Rendered with Non-reflective Material Not Appearing Black
- offscreen error
- 'Viewer' object has no attribute 'render'. Did you mean: '_render'?
- Interpolation artifacts in segmentation masks.
- Unable to get color on running the bottle example code HOT 1
- Wrong depth rendering in WSL-ubuntu environment
- Path3D type error when loading trimesh scene
- GLB is not rendered correctly HOT 1
- How to properly merge the Scenes from multiple trimeshes?
- Request for Release of Tag 0.1.46 with auto_start Option
- Cannot render SpecularGlossinessMaterial HOT 1
- jupyter notebook support?
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 pyrender.