Closed LudvigDubois closed 3 years ago
Thanks for the detailed question! Re-loading the scene many times within a single run script execution is not a pattern we use or see often, so it is hard to know exactly what is causing the issue (context bugs are notoriously opaque in Blender).
One suggestion would be to change the script so that each execution only loads one car, and then changes the HDRI and camera angle potentially hundreds of times. Camera angle changes and HDRI changes are much cheaper (memory/compute) than loading and segmenting a complicated object like a car. This does mean you would have to run your sim many times to get a variety of cars though (at which point I would recommend our scale backend to make that more convenient).
Appologies for a bit of a non-answer there, but hopefully its a bit helpful. Let us know how progress is going!
Thanks Hugo for the fast response! I will continue to try figuring out the context bug, but like you said, I think the way to go is to minimize the number of times I load a new car.
Hello,
I'm currently working on a python script to produce a car dataset using Blender and I use the zpy library quite a lot (very nice work btw !) .
My script is working like this. I start from a Blender scene containing only a plane (as a shadow catcher) and a camera. Then, I load a random car model and a random HDRI background from some folders. The car model is made of 100+ objects and I segment every object. Then, I move the camera around the car and I make a few renders. After that, I remove the car model and background image and start over with another car and background:
The script is working fine, but each time I load a new car, the segmentation part takes 1.5 to 2 seconds more. After a few hundreds cars, the segmentation takes several hundreds of seconds to complete, which makes the script unusable.
After searching for a bit, I found that even if you unlink data blocks from the scene (my functions remove_car() and remove_background() do that), the data blocks still remain in the blend file until you reload it. This is probably what makes the segmentation take more time, but I'm not sure.
In order to fix this, I decided to load a fresh scene after my renderings instead of removing all my data each time. I then replaced the last 2 lines of my code with this line:
Now, the problem is that when this line is called, it seems like I lose some "context" information because I get this error:
Now, I'm a bit at a loss here, since the Blender documentation on context is quite weak. Does anyone in the Zumo Labs team ever faced this issue? Sorry if this isn't the right place to ask this question.
Thanks a lot!