Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: dataloader #39

Merged
merged 21 commits into from
Aug 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ jobs:
enable-sccache: "true"

- name: lint
run: cargo clippy -- -Dwarnings
run: cargo clippy --all -- -Dwarnings
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ Cargo.lock
**/*.rs.bk
*.pdb

*.py
build/
*.egg-info/
__pycache__/
*.pyc
.venv/

data/

*.ply
*.gcloud
Expand Down
22 changes: 19 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,33 @@ exclude = [
default-run = "viewer"


[workspace]
members = [
".",
"ffi",
]


[features]
default = [
"asset_pipeline",
"development",
"extension-module",
"multi_threaded",
"plucker",
"viewer",
]

asset_pipeline = [
multi_threaded = [
"bevy/multi_threaded",
]

development = ["bevy/dynamic_linking"]

extension-module = ["pyo3/extension-module"]

perftest = []
plucker = []
python = ["extension-module", "webgpu"]

viewer = [
"bevy-inspector-egui",
Expand All @@ -71,14 +82,19 @@ bevy_args = "1.6"
bevy-inspector-egui = { version = "0.25", optional = true }
bevy_panorbit_camera = { version = "0.19", optional = true, features = ["bevy_egui"] }
clap = { version = "4.4", features = ["derive"] }
futures-intrusive = "0.5"
glob = "0.3"
itertools = "0.13"
noise = { version = "0.9" }
pollster = "0.3"
# TODO: conditional pyo3 based on python feature
pyo3 = { version = "0.22", features = ["macros"] }
rand = "0.8"
rayon = { version = "1.10", optional = true }
serde = "1.0"
strum = "0.26"
strum_macros = "0.26"
wgpu = "0.20.0"


[target.'cfg(target_arch = "wasm32")'.dependencies]
Expand Down Expand Up @@ -143,5 +159,5 @@ path = "src/lib.rs"

[[bin]]
name = "viewer"
path = "tools/viewer.rs"
path = "src/viewer.rs"
required-features = ["viewer"]
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,32 @@ bevy zeroverse synthetic reconstruction dataset generator. view the [live demo](
- [X] generate parameteric zeroverse primitives
- [X] primitive deformation
- [x] procedural zeroverse composite environments
- [x] online torch dataloader
- [x] safetensor chunking
- [ ] primitive boolean operations
- [ ] primitive pbr wireframe
- [ ] online dataloader
- [ ] primitive 4d augmentation


## dataloader

![Alt text](docs/bevy_zeroverse_dataloader_grid.webp)

```python
from bevy_zeroverse_dataloader.dataloader import BevyZeroverseDataset
from torch.utils.data import DataLoader

dataset = BevyZeroverseDataset(
editor=False, headless=True, num_cameras=6,
width=640, height=360, num_samples=1e6,
)
dataloader = DataLoader(
dataset, batch_size=4, shuffle=True, num_workers=1,
)

for batch in dataloader:
visualize(batch)
```


## mat-synth
Expand Down
Binary file added docs/bevy_zeroverse_dataloader_grid.webp
Binary file not shown.
38 changes: 38 additions & 0 deletions ffi/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[package]
name = "bevy_zeroverse_ffi"
version = "0.1.0"
edition = "2021"


[features]
default = ["extension-module"]

extension-module = [
"bevy_zeroverse/extension-module",
"pyo3/extension-module",
]


[dependencies]
bevy_zeroverse = { path = "../", default-features = false, features = ["python"] }
image = "0.25"
ndarray = { version = "0.15", features = ["blas"] }
once_cell = "1.19"
pyo3 = { version = "0.22", features = ["macros"] }
pyo3-log = "0.11"


[dependencies.bevy]
version = "0.14"
default-features = false
features = [
"bevy_asset",
"bevy_render",
"bevy_ui",
"bevy_winit",
]


[lib]
name = "bevy_zeroverse"
path = "src/lib.rs"
62 changes: 62 additions & 0 deletions ffi/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# bevy_zeroverse python bindings

install `bevy_zeroverse` to your python environment with `pip install ffi` (from repository root)

install `bevy_zeroverse_dataloader` to your python environment with `pip install ffi/python`


## test

`cargo test -p bevy_zeroverse_ffi --no-default-features`


## dataloader

torch dataloader API for online bevy_zeroverse batch generation.

run the test script with `python ffi/python/test.py` to see the dataloader in action.

```python
from bevy_zeroverse_dataloader.dataloader import BevyZeroverseDataset
from torch.utils.data import DataLoader


dataset = BevyZeroverseDataset(
editor=False, headless=True, num_cameras=6,
width=640, height=360, num_samples=1e6,
)
dataloader = DataLoader(dataset, batch_size=2, shuffle=True, num_workers=1)


for batch in dataloader:
visualize(batch)
```


<!-- ### macos setup -->

<!-- ```bash
LIBTORCH_PATH=$(python3 -c "import site; print(site.getsitepackages()[0] + '/torch/lib')")
export DYLD_LIBRARY_PATH=$LIBTORCH_PATH:$DYLD_LIBRARY_PATH
``` -->


### windows setup

```bash
export PYO3_PYTHON="/c/Users/{user}/.pyenv/pyenv-win/versions/3.11.7/python.exe"
export PATH="/c/Users/{user}/.pyenv/pyenv-win/versions/3.11.7/libs:$PATH"
```

#### rust-analyzer


```json
...
"rust-analyzer.server.extraEnv": {
"CARGO_TARGET_DIR": "target/analyzer",
"PYO3_PYTHON": "C:\\Users\\{user}\\.pyenv\\pyenv-win\\versions\\3.11.7\\python.exe",
"LIB": "C:\\Users\\{user}\\.pyenv\\pyenv-win\\versions\\3.11.7\\libs"
},
...
```
3 changes: 3 additions & 0 deletions ffi/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["setuptools", "setuptools-rust", "wheel"]
build-backend = "setuptools.build_meta"
Loading
Loading