Skip to content

Commit b79ca46

Browse files
committed
Version 1.0.0
1 parent 78b66fc commit b79ca46

28 files changed

Lines changed: 1432 additions & 0 deletions

.flake8

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[flake8]
2+
docstring-convention = google
3+
extend-ignore = E501, E731
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Credit: https://github.com/niketagrawal
2+
3+
name: Build-sphinx-docs
4+
5+
# Controls when the workflow will run
6+
on:
7+
# Triggers the workflow on push or pull request events but only for the main branch
8+
push:
9+
branches: [ main ]
10+
pull_request:
11+
branches: [ main ]
12+
13+
# Allows you to run this workflow manually from the Actions tab
14+
workflow_dispatch:
15+
16+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
17+
jobs:
18+
# This workflow contains a single job called "build"
19+
build:
20+
# The type of runner that the job will run on
21+
runs-on: ubuntu-latest
22+
23+
# Steps represent a sequence of tasks that will be executed as part of the job
24+
steps:
25+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
26+
- uses: actions/checkout@v2
27+
28+
- name: Set up Python 3.10
29+
uses: actions/setup-python@v2
30+
with:
31+
python-version: "3.10"
32+
# Runs a single command using the runners shell
33+
- name: Run a one-line script
34+
run: echo Hello, world!
35+
36+
- name: Install dependencies
37+
run: |
38+
python -m pip install --upgrade pip
39+
pip install -r requirements.txt
40+
41+
- name: Install ghp-import
42+
run: |
43+
pip install ghp-import
44+
45+
- name: Build HTML
46+
run: |
47+
cd docs/
48+
make html
49+
50+
- name: Configure Git for push
51+
run: |
52+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
53+
git config --global user.name "github-actions[bot]"
54+
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git
55+
56+
- name: Run ghp-import
57+
run: |
58+
ghp-import -n -p -f docs/_build/html
59+
60+
# Runs a set of commands using the runners shell
61+
- name: Run a multi-line script
62+
run: |
63+
echo Add other actions to build,
64+
echo test, and deploy your project.

.gitignore

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
share/python-wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
MANIFEST
28+
29+
# PyInstaller
30+
# Usually these files are written by a python script from a template
31+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
32+
*.manifest
33+
*.spec
34+
35+
# Installer logs
36+
pip-log.txt
37+
pip-delete-this-directory.txt
38+
39+
# Unit test / coverage reports
40+
htmlcov/
41+
.tox/
42+
.nox/
43+
.coverage
44+
.coverage.*
45+
.cache
46+
nosetests.xml
47+
coverage.xml
48+
*.cover
49+
*.py,cover
50+
.hypothesis/
51+
.pytest_cache/
52+
cover/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
.pybuilder/
76+
target/
77+
78+
# Jupyter Notebook
79+
.ipynb_checkpoints
80+
81+
# IPython
82+
profile_default/
83+
ipython_config.py
84+
85+
# pyenv
86+
# For a library or package, you might want to ignore these files since the code is
87+
# intended to run in multiple environments; otherwise, check them in:
88+
# .python-version
89+
90+
# pipenv
91+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
93+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
94+
# install all needed dependencies.
95+
#Pipfile.lock
96+
97+
# UV
98+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99+
# This is especially recommended for binary packages to ensure reproducibility, and is more
100+
# commonly ignored for libraries.
101+
#uv.lock
102+
103+
# poetry
104+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105+
# This is especially recommended for binary packages to ensure reproducibility, and is more
106+
# commonly ignored for libraries.
107+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108+
#poetry.lock
109+
110+
# pdm
111+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
112+
#pdm.lock
113+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
114+
# in version control.
115+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
116+
.pdm.toml
117+
.pdm-python
118+
.pdm-build/
119+
120+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
121+
__pypackages__/
122+
123+
# Celery stuff
124+
celerybeat-schedule
125+
celerybeat.pid
126+
127+
# SageMath parsed files
128+
*.sage.py
129+
130+
# Environments
131+
.env
132+
.venv
133+
env/
134+
venv/
135+
ENV/
136+
env.bak/
137+
venv.bak/
138+
139+
# Spyder project settings
140+
.spyderproject
141+
.spyproject
142+
143+
# Rope project settings
144+
.ropeproject
145+
146+
# mkdocs documentation
147+
/site
148+
149+
# mypy
150+
.mypy_cache/
151+
.dmypy.json
152+
dmypy.json
153+
154+
# Pyre type checker
155+
.pyre/
156+
157+
# pytype static type analyzer
158+
.pytype/
159+
160+
# Cython debug symbols
161+
cython_debug/
162+
163+
# PyCharm
164+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
165+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
166+
# and can be added to the global gitignore or merged into this file. For a more nuclear
167+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
168+
#.idea/
169+
170+
# PyPI configuration file
171+
.pypirc
172+
173+
# Output files
174+
output/**
175+
176+
# Experiments
177+
experiments/train.py
178+
experiments/train.sh
179+
experiments/requirements.txt
180+
181+
# Data
182+
data/objaverse/

.pre-commit-config.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.4.0
4+
hooks:
5+
- id: check-symlinks
6+
- id: trailing-whitespace
7+
args: [--markdown-linebreak-ext=md]
8+
- id: end-of-file-fixer
9+
- id: check-yaml
10+
- id: check-toml
11+
- id: check-ast
12+
- id: check-added-large-files
13+
- id: check-merge-conflict
14+
- id: detect-private-key
15+
- id: debug-statements
16+
- repo: https://github.com/pycqa/isort
17+
rev: 5.12.0
18+
hooks:
19+
- id: isort
20+
- repo: https://github.com/PyCQA/flake8
21+
rev: 7.0.0
22+
hooks:
23+
- id: flake8
24+
args: [--max-line-length=127]
25+
additional_dependencies: [
26+
'flake8-docstrings==1.7.0',
27+
'flake8-quotes==3.4.0',
28+
]

README.md

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# scripted-renderer-dev
2+
3+
This project is a **3D rendering tool** that takes any 2 Blender objects and renders them on a plane with customizable orientations, positions, distances, and camera angles.
4+
5+
## Setup
6+
7+
### Step 1: Clone the Repository
8+
9+
Clone this repository to your local machine:
10+
11+
```bash
12+
git clone https://github.com/compling-wat/scripted-renderer-dev.git
13+
cd scripted-renderer-dev
14+
```
15+
16+
### Step 2: Install Blender 4.3
17+
18+
Download and install **[Blender 4.3](https://www.blender.org/download/)**.
19+
20+
### Step 3: Set Up the Environment
21+
22+
1. Locate where Blender 4.3 is installed:
23+
```bash
24+
which/where blender
25+
```
26+
2. Open a terminal and navigate into the Blender installation directory (path varies by operating system):
27+
```bash
28+
cd /path/to/blender/site-packages/
29+
```
30+
3. Create a `.pth` file named `scripted-renderer-dev.pth` and add the absolute path to the `src` directory of the cloned repository:
31+
```bash
32+
echo "/path/to/scripted-renderer-dev/src" > /path/to/blender/site-packages/scripted-renderer-dev.pth
33+
```
34+
- _Note: if you encounter errors on Windows, ensure the file encoding is **UTF-8 with BOM**._
35+
36+
## Usage
37+
38+
The repository contains a `scripts` folder with example shell scripts for using this tool. First **cd** into this directory.
39+
40+
### **Camera Settings**
41+
42+
To set the camera configurations for the rendered images, you can add the following parameters to your script:
43+
```bash
44+
--camera-tilt X # Set camera tilt in degrees
45+
--camera-pan X # Set camera pan in degrees
46+
--camera-height X # Set camera height in meters
47+
--camera-focal-length X # Set focal length in millimeters
48+
```
49+
50+
### **Rendering Multiple Images**
51+
52+
To render all possible combinations of 2 objects under the `data` directory, use the `--render-random` parameter as shown in the `render_multiple.sh` script.
53+
- The generates images into a **main directory** for each combination of 2 objects within into the **specified image output folder**, along with **4 subdirectories** within the **main directory**:
54+
55+
- `[object1]_[object2]_left` (object2 to the left of object1)
56+
- `[object1]_[object2]_right` (object2 to the right of object1)
57+
- `[object1]_[object2]_front` (object2 to the front of object1)
58+
- `[object1]_[object2]_behind` (object2 to the back of object1)
59+
60+
- For each image, it also generates a corresponding `json` file with detailed information on the camera settings, and positions, rotations, orientations, and relative perspectives of the objects in the **specified scene output folder**.
61+
62+
- You can specify the following constraints:
63+
```bash
64+
--objects [list of objects] # Select specific objects to render
65+
--distance-between-objects X # Set object distance in meters (default: 3)
66+
--max-images N # Set max images (orientations combinations) per subdirectory (default: 1)
67+
--max-camera-configs N # Set max number of camera configurations per image (default: 1)
68+
```
69+
70+
- If you do not specify `--objects`, the list of objects will be set to all objects in the `data` folder.
71+
- If you do not specify `--max-camera-configs`, you must fix a specific camera configuration for all images in the script.
72+
73+
_This script can be used for generating an extensive **spatial reasoning dataset** for **vision-language models**._
74+
75+
### **Rendering a Single Image**
76+
77+
For controlled rendering of 2 selected objects, navigate to the `render_single.sh` script for an example usage.
78+
79+
- Unlike rendering multiple
80+
81+
- Now, since you are only generating 1 image, you have the following additional customizations:
82+
```bash
83+
--direction [left, right, behind, front] # Set object 2’s position relative to object1
84+
--object1-rotation X # Set object 1's rotation to X degrees clockwise (default: 0)
85+
--object2-rotation X # Set object 2's rotation to X degrees clockwise (default: 0)
86+
```
87+
88+
- In this case, you must specify a camera setting as well as the `--direction` parameter.
89+
90+
_This script is useful for **testing and fine-tuning** object placements before batch rendering._
91+
92+
### **Adding AI-generated Backgrounds (EXTRA)**
93+
94+
All the images rendered are just 2 objects on a white surface with a light grey "sky". If you would like to add a custom (more realistic) background to each image in your image output folder, you can navigate to the `generate_backgrounds.sh` script. Note: this feature is still under experimentation.
95+
96+
- Here, you can customize the `PROMPT` argument to guide the background generation process.
97+
98+
- The process utilizes the [**Stable Diffusion XL inpainting model**](https://huggingface.co/diffusers/stable-diffusion-xl-1.0-inpainting-0.1) to modify specific regions of images with custom backgrounds.
99+
100+
_The goal is to enable comparisons between a fine-tuned spatial reasoning model’s performance on the original dataset versus a version with more realistic backgrounds._
101+
102+
## Configuration
103+
104+
The tool's settings, such as **output directories, image resolution, and other scene configurations**, can be customized in `config.json` under the `src` directory.
105+
106+
You can also add your own objects by placing `.blend` files inside the `data` folder and specifying their properties in `properties.json`.

data/.DS_Store

6 KB
Binary file not shown.

data/load_objects.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
git clone https://github.com/compling-wat/FORG3D-object-data.git
2+
mv FORG3D-object-data/* .
3+
rm -rf FORG3D-object-data
4+
rm LICENSE

0 commit comments

Comments
 (0)