Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into iss_724_surface_li…
Browse files Browse the repository at this point in the history
…ghting
  • Loading branch information
cornerfarmer committed Jul 28, 2021
2 parents 0b0ff68 + 306f709 commit 26bcf50
Show file tree
Hide file tree
Showing 47 changed files with 249 additions and 93 deletions.
39 changes: 39 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
name: Bug report
about: Create a report to help us improve
title: "[BUG]:"
labels: bug
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**General Information**
1. Which BlenderProc verison are you using?

2. On which operating system are you?

3. Have you checked the issue tracker to see if a similar issue has been opened?

4. Have you changed BlenderProc in anyway besides the config file? If yes, are you sure that this change does not affect the problem you are having?

**To Reproduce**
Steps to reproduce the behavior:
1. Provide the full command you used to run BlenderProc:
`python run.py ....`
2. Provide the full config yaml file, you used:
```yaml
{}
```
3. Provide a link to all 3D models you used, if they are from one of the publicly available supported datasets, provide the name or path so that it is possible to reproduce the error.

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Additional context**
Add any other context about the problem here.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: "[FEATURE]: "
labels: enhancement
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
18 changes: 18 additions & 0 deletions .github/ISSUE_TEMPLATE/request-for-dataset-support.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
name: Request for dataset support
about: Suggest a dataset which should be supported
title: "[DATASET]: "
labels: enhancement
assignees: ''

---

**Please describe the dataset which you think should be supported by BlenderProc, please also provide a link to the dataset.**
A clear and concise description of the dataset and a link to it.

**Describe the solution you'd like**
A clear and concise description of how you want to use the dataset, for which problem are you trying to generate data, be as specific as possible to ensure that in the end the correct data will be provided.
E.g. If you want to use the dataset for semantic segmentation it is crucial that all objects have a `category_id` label.

**Additional context**
Add any other context or screenshots about the feature request here.
21 changes: 21 additions & 0 deletions change_log.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,27 @@

# Version History

## Version 1.12.0 23th July 2021
- switch to blender 2.93, with that textures are now stored on the GPU between different frames increasing the speed drastically
- moved a lot of modules to the python API
- all camera samplers
- all writer classes
- sampler and getters
- surface lighting
- random room constructor
- all outer API functions work now with numpy arrays instead of mathutils classes
- regroup all examples to make them more easily accessible
- refactoring of the LabelIdMapping class
- sampler.Path now has a `return_all` and `random_samples` option
- add support for the new 3D front labels and script to find them more easily in the future
- AMASS now also supports `torch=1.8.1+cu111`, to better support modern GPUs
- refactor download script for haven
- added a flag to not center objects from the ShapeNet dataset
- added a platform independent unzipping function to solve the problems on windows
- add function to return the default_value or the connected node based on the input name of a BSDF shader node of a material
- fix for MacOS, where the blender version was not used in prior installations, leading to the problem that users had to remove blender on their own
- the writer now correctly writes the fov if asked

## Version 1.11.1 18th May 2021
- fix a bug on mac os, where the blender python path has changed
- fix a bug in the BlenderLoaderModule which caused that the setting of custom properties was not successful
Expand Down
2 changes: 1 addition & 1 deletion docs/prepare_markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

shutil.copy(str(example), str(output_example / "README.md"))

shutil.copytree(examples.parent / "images", output.parent / "images", dirs_exist_ok=True)
shutil.copytree(examples.parent / "images", output.parent / "images")
shutil.copy(examples.parent / "README.md", output.parent)
shutil.copy(examples.parent / "change_log.md", output.parent)
shutil.copy(examples.parent / "CONTRIBUTING.md", output.parent)
Expand Down
49 changes: 26 additions & 23 deletions docs/source/ext/moduleoverview.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,32 +52,35 @@ def generate_collapsible_classlist(app, fromdocname, classes, container, caption
container += toc

def generate_examples_sidebar(app, fromdocname, container):
toc = nodes.bullet_list()

ref = nodes.reference('', '')
ref['refuri'] = app.builder.get_relative_uri(fromdocname, "examples/README")
ref.append(nodes.Text("Examples"))
module_item = nodes.list_item('', addnodes.compact_paragraph('', '', ref), classes=["toctree-l1"])
if fromdocname.startswith("examples/"):
module_item["classes"].append('current')
toc += module_item

subtree = nodes.bullet_list()
module_item += subtree

examples = Path(__file__).absolute().parent.parent / "examples"
for example in sorted(examples.rglob("*/README.md"), key=lambda x: x.parent.name):
ref = nodes.reference('', '')
ref['refuri'] = app.builder.get_relative_uri(fromdocname, str(example).replace(str(examples), "examples").replace("README.md", "README"))
ref.append(nodes.Text(example.parent.name))
class_item = nodes.list_item('', addnodes.compact_paragraph('', '', ref), classes=["toctree-l2"])

if fromdocname == ref['refuri'].replace(".html", ""):
class_item['classes'].append('current')
subtree += class_item

container += nodes.caption("Examples", '', *[nodes.Text("Examples")])
for example_groups in [examples / group for group in ["basics", "advanced", "datasets"]]:
if example_groups.is_dir():
toc = nodes.bullet_list()

container += toc
ref = nodes.reference('', '')
ref['refuri'] = app.builder.get_relative_uri(fromdocname, "examples/" + example_groups.name + "/README")
ref.append(nodes.Text(example_groups.name.capitalize()))
module_item = nodes.list_item('', addnodes.compact_paragraph('', '', ref), classes=["toctree-l1"])
if fromdocname.startswith("examples/" + example_groups.name):
module_item["classes"].append('current')
toc += module_item

subtree = nodes.bullet_list()
module_item += subtree

for example in sorted(example_groups.rglob("*/README.md"), key=lambda x: x.parent.name):
ref = nodes.reference('', '')
ref['refuri'] = app.builder.get_relative_uri(fromdocname, str(example).replace(str(examples), "examples").replace("README.md", "README"))
ref.append(nodes.Text(example.parent.name))
class_item = nodes.list_item('', addnodes.compact_paragraph('', '', ref), classes=["toctree-l2"])

if fromdocname == ref['refuri'].replace(".html", ""):
class_item['classes'].append('current')
subtree += class_item

container += toc

def generate_sidebar(app, fromdocname):
env = app.builder.env
Expand Down
2 changes: 1 addition & 1 deletion examples/advanced/auto_shading/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ python run.py examples/advanced/auto_shading/config.yaml examples/advanced/auto_
```

* `examples/advanced/auto_shading/config.yaml`: path to the configuration file with pipeline configuration.
* `examples/advanced/auto_shading/camera_positions`: text file with parameters of camera positions.
* `examples/advanced/auto_shading/camera_position`: text file with parameters of camera positions.
* `examples/advanced/auto_shading/scene.blend`: path to the blend file with the basic scene.
* `examples/advanced/auto_shading/output`: path to the output directory.

Expand Down
2 changes: 1 addition & 1 deletion examples/advanced/coco_annotations/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

# Set some category ids for loaded objects
for j, obj in enumerate(objs):
obj.set_cp("category_id", j)
obj.set_cp("category_id", j+1)

# define a light and set its location and energy level
light = Light()
Expand Down
2 changes: 1 addition & 1 deletion examples/advanced/diffuse_color_image/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ python scripts/visHdf5Files.py examples/advanced/diffuse_color_image/output/0.hd

* This module imports an .obj file into the scene.
* The path of the .obj file should be configured via the parameter `path`.
* Here we are using the first argument given, in the upper command the output path is set to `examples/advanced/diffuse_color_image/scene.obj`.
* Here we are using the first argument given, in the upper command the output path is set to `examples/resources/scene.obj`.

#### RgbRenderer

Expand Down
3 changes: 0 additions & 3 deletions examples/basics/basic/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,5 @@
# render the whole pipeline
data = RendererUtility.render()

# post process the data and remove the redundant channels in the distance image
data["distance"] = PostProcessingUtility.trim_redundant_channels(data["distance"])

# write the data to a .hdf5 container
WriterUtility.save_to_hdf5(args.output_dir, data)
8 changes: 4 additions & 4 deletions examples/basics/camera_object_pose/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ Execute in the BlenderProc main directory, if this is the first time BlenderProc
downloaded blender, see the config-file if you want to change the installation path:

```
python run.py examples/basic_object_pose/config.yaml examples/basic_object_pose/obj_000004.ply examples/basic_object_pose/output
python run.py examples/basics/camera_object_pose/config.yaml examples/basics/camera_object_pose/obj_000004.ply examples/basics/camera_object_pose/output
```

* `examples/basic_object_pose/config.yaml`: path to the configuration file with pipeline configuration.
* `examples/basics/camera_object_pose/config.yaml`: path to the configuration file with pipeline configuration.

The arguments afterwards are used to fill placeholders like `<args:0>` inside this config file.
* `examples/basic_object_pose/obj_000004.ply`: path to the model file, here a basic object from the `hb` dataset.
* `examples/basic_object_pose/output`: path to the output directory.
* `examples/basics/camera_object_pose/obj_000004.ply`: path to the model file, here a basic object from the `hb` dataset.
* `examples/basics/camera_object_pose/output`: path to the output directory.

## Steps

Expand Down
4 changes: 2 additions & 2 deletions examples/datasets/suncg_with_cam_sampling/main.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from src.utility.CameraUtility import CameraUtility
from src.utility.MathUtility import MathUtility
from src.utility.SetupUtility import SetupUtility
SetupUtility.setup([])

from src.utility.CameraUtility import CameraUtility
from src.utility.MathUtility import MathUtility
from src.utility.sampler.SuncgPointInRoomSampler import SuncgPointInRoomSampler
from src.utility.LabelIdMapping import LabelIdMapping
from src.utility.MeshObjectUtility import MeshObject
Expand Down
2 changes: 1 addition & 1 deletion examples/datasets/suncg_with_improved_mat/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SUNCG scene with improved materials

<p align="center">
<img src="../../readme.jpg" alt="Front readme image" width=430>
<img src="../../../images/readme.jpg" alt="Front readme image" width=430>
</p>

In contrast to the SUNCG basic example, we improve the materials loaded by SUNCG.
Expand Down
13 changes: 5 additions & 8 deletions run.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import argparse
import os
from os.path import join
import tarfile
import zipfile
from os.path import join
import subprocess
import shutil
import signal
import sys
from sys import platform, version_info

from src.utility.SetupUtility import SetupUtility

if version_info.major == 3:
from urllib.request import urlretrieve
else:
Expand All @@ -19,6 +16,7 @@

import uuid
from src.utility.ConfigParser import ConfigParser
from src.utility.SetupUtility import SetupUtility


parser = argparse.ArgumentParser(add_help=False)
Expand Down Expand Up @@ -81,6 +79,7 @@
blender_path = os.path.join(blender_install_path, blender_version)
elif platform == "darwin":
blender_version += "-macos-x64"
blender_install_path = os.path.join(blender_install_path, blender_version)
blender_path = os.path.join(blender_install_path, "Blender.app")
elif platform == "win32":
blender_version += "-windows-x64"
Expand Down Expand Up @@ -135,8 +134,7 @@ def __call__(self, block_num, block_size, total_size):

if platform == "linux" or platform == "linux2":
if version_info.major == 3:
with tarfile.open(file_tmp) as tar:
tar.extractall(blender_install_path)
SetupUtility.extract_file(blender_install_path, file_tmp, "TAR")
else:
with contextlib.closing(lzma.LZMAFile(file_tmp)) as xz:
with tarfile.open(fileobj=xz) as f:
Expand All @@ -156,8 +154,7 @@ def __call__(self, block_num, block_size, total_size):
subprocess.Popen(["rm {}".format(os.path.join(blender_install_path, blender_version + ".dmg"))], shell=True).wait()
# add Blender.app path to it
elif platform == "win32":
with zipfile.ZipFile(file_tmp) as z:
z.extractall(blender_install_path)
SetupUtility.extract_file(file_tmp, blender_install_path)
# rename the blender folder to better fit our existing scheme
for folder in os.listdir(blender_install_path):
if os.path.isdir(os.path.join(blender_install_path, folder)) and folder.startswith("blender-" + major_version):
Expand Down
14 changes: 5 additions & 9 deletions scripts/download_cc_textures.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from sys import version_info
from sys import version_info, path
if version_info.major == 2:
raise Exception("This script only works with python3.x!")

import os
import csv
import subprocess
import requests

path.append(os.path.join(os.path.dirname(__file__), ".."))
from src.utility.SetupUtility import SetupUtility

if __name__ == "__main__":
# setting the default header, else the server does not allow the download
Expand Down Expand Up @@ -56,11 +56,7 @@
if not os.path.exists(current_folder):
os.makedirs(current_folder)
current_file_path = os.path.join(current_folder, "{}.zip".format(asset))
request = requests.get(link, headers=headers)
with open(current_file_path, "wb") as file:
file.write(request.content)

subprocess.call(["unzip {} -d {}> /dev/null".format(current_file_path, current_folder)], shell=True)
os.remove(current_file_path)
response = requests.get(link, headers=headers)
SetupUtility.extract_from_response(current_folder, response)

print("Done downloading textures, saved in {}".format(cc_texture_dir))
10 changes: 5 additions & 5 deletions scripts/download_ikea.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from sys import version_info
from sys import version_info, path

if version_info.major == 2:
raise Exception("This script only works with python3.x!")
Expand All @@ -10,6 +10,8 @@
import subprocess
import shutil

path.append(os.path.join(os.path.dirname(__file__), ".."))
from src.utility.SetupUtility import SetupUtility

def split_object_according_to_groups(file_path, folder):
"""
Expand Down Expand Up @@ -80,11 +82,9 @@ def split_object_according_to_groups(file_path, folder):

# unzip the zip file
print("Unzipping the zip file...")
cmd = "unzip {} > /dev/null".format(zip_file_path)
subprocess.call(cmd, shell=True, cwd=os.path.dirname(zip_file_path))

os.remove(zip_file_path)
ikea_dir = os.path.join(ikea_dir, "IKEA")
SetupUtility.extract_file(ikea_dir, zip_file_path)
os.remove(zip_file_path)

subprocess.call("chmod -R a+rw *", shell=True, cwd=ikea_dir)

Expand Down
8 changes: 4 additions & 4 deletions scripts/download_pix3d.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
from sys import version_info
from sys import version_info, path

if version_info.major == 2:
raise Exception("This script only works with python3.x!")

import os
from urllib.request import urlretrieve, build_opener, install_opener
import subprocess
import shutil

from utils import ProgressBar
path.append(os.path.join(os.path.dirname(__file__), ".."))
from src.utility.SetupUtility import SetupUtility


if __name__ == "__main__":
Expand All @@ -32,8 +33,7 @@

# unzip the zip file
print("Unzip the zip file.")
cmd = "unzip {}".format(zip_file_path)
subprocess.call(cmd, shell=True, cwd=os.path.dirname(zip_file_path))
SetupUtility.extract_file(pix3d_dir, zip_file_path)

os.remove(zip_file_path)
shutil.rmtree(os.path.join(pix3d_dir, "img"))
Expand Down
Loading

0 comments on commit 26bcf50

Please sign in to comment.