https://github.com/cheind/pytorch-blender

:sweat_drops: Seamless, distributed, real-time integration of Blender into PyTorch data pipelines

https://github.com/cheind/pytorch-blender

Science Score: 33.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: arxiv.org
  • Committers with academic emails
    2 of 6 committers (33.3%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (15.8%) to scientific vocabulary

Keywords

blender openai-gym pytorch reinforcement-learning zmq
Last synced: 6 months ago · JSON representation

Repository

:sweat_drops: Seamless, distributed, real-time integration of Blender into PyTorch data pipelines

Basic Info
  • Host: GitHub
  • Owner: cheind
  • License: mit
  • Language: Python
  • Default Branch: develop
  • Homepage:
  • Size: 28.1 MB
Statistics
  • Stars: 582
  • Watchers: 31
  • Forks: 46
  • Open Issues: 9
  • Releases: 4
Topics
blender openai-gym pytorch reinforcement-learning zmq
Created about 7 years ago · Last pushed over 2 years ago
Metadata Files
Readme Changelog License

Readme.md

Build Status

blendtorch

blendtorch is a Python framework to seamlessly integrate Blender into PyTorch for deep learning from artificial visual data. We utilize Eevee, a new physically based real-time renderer, to synthesize images and annotations in real-time and thus avoid stalling model training in many cases.

If you find the project helpful, you consider citing it.

Feature summary - Data Generation: Stream distributed Blender renderings directly into PyTorch data pipelines in real-time for supervised learning and domain randomization applications. Supports arbitrary pickle-able objects to be send alongside images/videos. Built-in recording capability to replay data without Blender. Bi-directional communication channels allow Blender simulations to adapt during network training.
More info [examples/datagen], [examples/compositornormalsdepth], [examples/densityopt] - OpenAI Gym Support: Create and run remotely controlled Blender gyms to train reinforcement agents. Blender serves as simulation, visualization, and interactive live manipulation environment.
More info [examples/control]

The figure below visualizes the basic concept of blendtorch used in the context of generating artificial training data for a real-world detection task.


Fig 1: With Blendtorch, you are able to train your PyTorch modules on massively randomized artificial data generated by Blender simulations.

Getting started

  1. Read the installation instructions below
  2. To get started with blendtorch for training data training read [examples/datagen].
  3. To learn about using blendtorch for creating reinforcement training environments read [examples/control].

Prerequisites

This package has been tested with - Blender >= 2.83/2.91/3.0/3.1 (Python >= 3.7) - PyTorch >= 1.5/1.10 (Python >= 3.7)

running Windows 10 and Linux. Other versions might work as well, but have not been tested.

Installation

blendtorch is composed of two distinct sub-packages: - bendtorch.btt located in pkg_pytorch and - blendtorch.btb located in pkg_blender,

providing the PyTorch and Blender views on blendtorch. bendtorch.btt will be installed to your local Python environment, while blendtorch.btb will be installed to the Python environment that ships with Blender.

  1. Clone this repository

    git clone https://github.com/cheind/pytorch-blender.git <DST>

  2. Extend PATH

    Ensure Blender executable is in your environments lookup PATH. On Windows this can be accomplished by set PATH=c:\Program Files\Blender Foundation\Blender 2.91;%PATH% On Ubuntu when blender is installed using snap, the path may be included by adding the following line to your ~/.bashrc, export PATH=/snap/blender/current/${PATH:+:${PATH}}

  3. Complete Blender settings

    Open Blender at least once, and complete the initial settings. If this step is missed, some of the tests (especially the tests relating RL) will fail (Blender 2.91).

  4. Install blendtorch.btb

    Run blender --background --python <DST>/scripts/install_btb.py to blendtorch-btb into the Python environment bundled with Blender.

  5. Install blendtorch.btt

    Run pip install -e <DST>/pkg_pytorch installs blendtorch-btt into the Python environment that you intend to run PyTorch from.

  6. Install gym [optional]

    While not required, it is advised to install OpenAI gym if you intend to use blendtorch for reinforcement learning pip install gym

  7. Install dev requirements [optional]

    This step is optional. If you plan to run the unit tests pip install -r requirements_dev.txt pytest tests/

Troubleshooting

Run blender --version and check if the correct Blender version (>=2.83) is written to console. Next, ensure that blendtorch-btb installed correctly blender --background --python-use-system-env --python-expr "import blendtorch.btb as btb; print(btb.__version__)" which should print blendtorch version number on success. Next, ensure that blendtorch-btt installed correctly python -c "import blendtorch.btt as btt; print(btt.__version__)" which should print blendtorch version number on success.

Architecture

Please see [examples/datagen] and [examples/control] for an in-depth architectural discussion. Bi-directional communication is explained in [examples/densityopt].

Runtimes

The following tables show the mean runtimes per batch (8) and per image for a simple Cube scene (640x480xRGBA). See benchmarks/benchmark.py for details. The timings include rendering, transfer, decoding and batch collating. Reported timings are for Blender 2.8. Blender 2.9 performs equally well on this scene, but is usually faster for more complex renderings.

| Blender Instances | Runtime sec/batch | Runtime sec/image | Arguments| |:-:|:-:|:-:|:-:| | 1 | 0.236 | 0.030| UI refresh| | 2 | 0.14 | 0.018| UI refresh| | 4 | 0.099 | 0.012| UI refresh| | 5 | 0.085 | 0.011| no UI refresh|

Note: If no image transfer is needed, i.e in reinforcement learning of physical simulations, 2000Hz are easily achieved.

Cite

The code accompanies our academic work [1],[2] in the field of machine learning from artificial images. Please consider the following publications when citing blendtorch ``` @inproceedings{blendtorchicpr2020cheind, author = {Christoph Heindl, Lukas Brunner, Sebastian Zambal and Josef Scharinger}, title = {BlendTorch: A Real-Time, Adaptive Domain Randomization Library}, booktitle = { 1st Workshop on Industrial Machine Learning at International Conference on Pattern Recognition (ICPR2020) }, year = {2020}, }

@inproceedings{robotposeetfa2019cheind, author={Christoph Heindl, Sebastian Zambal, Josef Scharinger}, title={Learning to Predict Robot Keypoints Using Artificially Generated Images}, booktitle={ 24th IEEE International Conference on Emerging Technologies and Factory Automation (ETFA) },
year={2019} } ```

Caveats

  • Despite offscreen rendering is supported in Blender 2.8x it requires a UI frontend and thus cannot run in --background mode. If your application does not require offscreen renderings you may enable background usage (see tests/ for examples).
  • The renderings produced by Blender are by default in linear color space and thus will appear darker than expected when displayed.

Owner

  • Name: Christoph Heindl
  • Login: cheind
  • Kind: user
  • Location: Austrian area

I am a computer scientist working at the interface of perception, robotics and deep learning.

GitHub Events

Total
  • Issues event: 4
  • Watch event: 20
  • Issue comment event: 8
  • Fork event: 3
Last Year
  • Issues event: 4
  • Watch event: 20
  • Issue comment event: 8
  • Fork event: 3

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 556
  • Total Committers: 6
  • Avg Commits per committer: 92.667
  • Development Distribution Score (DDS): 0.518
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Christoph Heindl c****l@g****m 268
Heindl Christoph c****d@p****t 208
Heindl Christoph c****d@p****l 57
szamba s****l@p****t 19
Kent Gauen g****k@p****u 3
Körber, Marian Karl m****r@d****e 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 9 months ago

All Time
  • Total issues: 26
  • Total pull requests: 6
  • Average time to close issues: about 2 months
  • Average time to close pull requests: 3 months
  • Total issue authors: 18
  • Total pull request authors: 4
  • Average comments per issue: 1.88
  • Average comments per pull request: 3.17
  • Merged pull requests: 3
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 4
  • Pull requests: 0
  • Average time to close issues: about 11 hours
  • Average time to close pull requests: N/A
  • Issue authors: 3
  • Pull request authors: 0
  • Average comments per issue: 2.0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • cheind (6)
  • yihao19 (2)
  • NowLoadY (1)
  • Amit12690 (1)
  • BluePrintRandom (1)
  • rafaveguim (1)
  • kkaytekin (1)
  • caseybasichis (1)
  • kfarivar (1)
  • ggaziv (1)
  • mjoe67886 (1)
  • bamps53 (1)
  • YoursTruely (1)
  • fan6zh (1)
  • TaeilJin (1)
Pull Request Authors
  • gauenk (2)
  • FrancescoPinto (1)
  • narcodix (1)
  • Majanao (1)
Top Labels
Issue Labels
enhancement (3)
Pull Request Labels

Dependencies

pkg_blender/requirements.txt pypi
  • minexr >=1.0.0
  • numpy >=1.18.2
  • pyopengl >=3.1.5
  • pyzmq >=18.1.1
  • supershape >=1.1.0
pkg_pytorch/requirements.txt pypi
  • matplotlib >=3.1.1
  • numpy >=1.18.2
  • psutil >=5.8.0
  • pyzmq >=18.1
  • torch >=1.3.1
requirements_dev.txt pypi
  • gym >=0.17.2 development
  • pytest >=3.9.3 development