Сделать патч для blenderproc #5

Open
opened 2023-03-11 16:48:00 +03:00 by movefasta · 2 comments
movefasta commented 2023-03-11 16:48:00 +03:00 (Migrated from gitlab.com)

Модуль для генерации датасетов Blenderproc работает с собственной версией Blender, которую подгружает в момент установки. Сама установка достаточно сложна (см. blenderproc/python/utility/SetupUtility.py).
Чтобы сделать blenderproc пакетом в nix, нужно разработать патч, который помощью переменной окружения (например, USE_BPY) пропускает сложную установку пакета в init-модуле, а использует python-модуль bpy, собранный в рамках этого оверлея. Соответственно, нужно передать для установки пути к python и bpy в /nix/store.

Модуль для генерации датасетов Blenderproc работает с собственной версией Blender, которую подгружает в момент установки. Сама установка достаточно сложна (см. [blenderproc/python/utility/SetupUtility.py](https://github.com/DLR-RM/BlenderProc/blob/iss_blender_3.4.1/blenderproc/python/utility/SetupUtility.py)). Чтобы сделать blenderproc пакетом в nix, нужно разработать патч, который помощью переменной окружения (например, `USE_BPY`) пропускает сложную установку пакета в [__init__-модуле](https://github.com/DLR-RM/BlenderProc/blob/main/blenderproc/__init__.py), а использует python-модуль `bpy`, собранный в рамках этого оверлея. Соответственно, нужно передать для установки пути к python и bpy в /nix/store.
movefasta commented 2023-05-28 23:11:50 +03:00 (Migrated from gitlab.com)

Есть описание как можно сделать из blenderproc python модуль

https://github.com/DLR-RM/BlenderProc/issues/840#issuecomment-1484038029

You need to make sure you have python 3.10 as your interpreter to download bpy, and to download all python packages that BlenderProc needs. (You can look them up in the DefaultConfig.py file in the BlenderProc repo)

Then, do this steps:

Include the option of using bpy:
In the __ init __.py file in the blenderproc directory - I've introduced a new environment variable, called it "USING_BPY_PYTHON_MODULE", and when I include it in my python environment - I check for it first in the __ init __.py file - and import all of blenderproc API modules (copy lines 21-38)

Change if statement to elif in line 12 (now 32). The script would now check first for my environment variable, and then for the rest of blenderproc options.

In the Initializer.py script in the utility directory - include one more line of code in line 34 for setting the language.
if bpy.context.preferences.view.language: and put lines 34-36 under that if statement.
In bpy module, there are no languages that are loaded into the list above that blenderproc checks, so you need to check first if there are any languages in the list, and if there are - change it to English as blenderproc does. If not - ignore.

Lastly - you need to make sure you included your new env variable in the environment you are working on, and gave it a value.

Of course this is just a tweak. I do not guarantee that the code will be correct in all cases. It currently works well in the cases I tested.
Enjoy!

The code I included in the __ init __.py file:
if "USING_BPY_PYTHON_MODULE" in os.environ: from .api import loader from .api import utility from .api import sampler from .api import math from .python.utility.Initializer import init, clean_up from .api import postprocessing from .api import writer from .api import material from .api import lighting from .api import camera from .api import renderer from .api import world from .api import constructor from .api import types # pylint: disable=redefined-builtin from .api import object from .api import filter # pylint: enable=redefined-builtin

Есть описание как можно сделать из blenderproc python модуль https://github.com/DLR-RM/BlenderProc/issues/840#issuecomment-1484038029 You need to make sure you have python 3.10 as your interpreter to download bpy, and to download all python packages that BlenderProc needs. (You can look them up in the DefaultConfig.py file in the BlenderProc repo) Then, do this steps: Include the option of using bpy: In the __ init __.py file in the blenderproc directory - I've introduced a new environment variable, called it "USING_BPY_PYTHON_MODULE", and when I include it in my python environment - I check for it first in the __ init __.py file - and import all of blenderproc API modules (copy lines 21-38) Change if statement to elif in line 12 (now 32). The script would now check first for my environment variable, and then for the rest of blenderproc options. In the Initializer.py script in the utility directory - include one more line of code in line 34 for setting the language. if bpy.context.preferences.view.language: and put lines 34-36 under that if statement. In bpy module, there are no languages that are loaded into the list above that blenderproc checks, so you need to check first if there are any languages in the list, and if there are - change it to English as blenderproc does. If not - ignore. Lastly - you need to make sure you included your new env variable in the environment you are working on, and gave it a value. Of course this is just a tweak. I do not guarantee that the code will be correct in all cases. It currently works well in the cases I tested. Enjoy! The code I included in the __ init __.py file: if "USING_BPY_PYTHON_MODULE" in os.environ: from .api import loader from .api import utility from .api import sampler from .api import math from .python.utility.Initializer import init, clean_up from .api import postprocessing from .api import writer from .api import material from .api import lighting from .api import camera from .api import renderer from .api import world from .api import constructor from .api import types # pylint: disable=redefined-builtin from .api import object from .api import filter # pylint: enable=redefined-builtin
movefasta commented 2024-03-22 12:17:50 +03:00 (Migrated from gitlab.com)

Для генерации датасета также нужны пакеты python:
numpy

Для генерации датасета также нужны пакеты python: numpy
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: robossembler/nix-overlay#5
No description provided.