BlenderProc icon indicating copy to clipboard operation
BlenderProc copied to clipboard

[FEATURE]: Allow BlenderProc to be used as a Python package

Open hummat opened this issue 2 years ago • 2 comments

Is your feature request related to a problem? Please describe. Right now BlenderProc seems to be usable only as a stand alone program and not as a Python package. Additionally, a Blender installation is required.

Describe the solution you'd like Given a Python script my_script.py like so:

from blenderproc.python.utility import Initializer
from blenderproc.api import renderer

Initializer.init(clean_up_scene=False)
renderer.render(verbose=True)

I would like to be able to run it using python my_script.py.

Describe alternatives you've considered I've largely achieved this by simply commenting everything in BlenderProc/blenderproc/__init__.py and installing BPY using pip install bpy. This is just a hack of course and no real solution.

Additional context As BlenderProc allows for a much more intuitive interaction with the Blender Python API compared to directly using BPY (comparable to, but much more extensive than, EasyBPY), I believe this to be a nice feature, e.g. for visualization callbacks in training pipelines.

hummat avatar May 22 '23 08:05 hummat

Probably duplicate of #840

hummat avatar May 22 '23 08:05 hummat

Not sure if this is related but using BlenderProc (or BPY from pip?) in this fashion seems to lead to memory leaks. Memory usage is increasing linearly with each call to render and after execution I'm seeing the following message:

Freeing memory after the leak detector has run. This can happen when using static variables in C++ that are defined outside of functions. To fix this error, use the 'construct on first use' idiom. Error: Not freed memory blocks: 25165, total unfreed memory 23.370861 MB

The amount of unfreed memory indicated depends on the number of calls to render.

hummat avatar May 25 '23 06:05 hummat