Skip to content

Commit

Permalink
Create setup.py and configs, minimize dependencies
Browse files Browse the repository at this point in the history
* Disable blending.py, make pallette requirements optional

* Move marching cubes into toplevel setup.py, remove all python command invocations from CMake

* Add pyproject.toml, convert bnurbs cythonize to toplevel setup.py

* Leave terrain/opengl as independent install scripts

* Move version to a txt file

* Install flip fluids into pip bpy's addons folder

* Reduce commits via better __init__.pys

* Use pip install -e . in setup.py, update infinigen_gpl pointer

* Move remainder of install.sh to setup.py, move version to __init__.__version__, add build commands to Makefile

* Only run build_deps in the right steps, add options to disable terrain etc

* Move scripts to examples

* Tweak setup.py

* add tabulate req
  • Loading branch information
araistrick authored and pvl-bot committed Oct 4, 2023
1 parent f1c3e24 commit c4a14d6
Show file tree
Hide file tree
Showing 31 changed files with 309 additions and 326 deletions.
13 changes: 12 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
build_terrain:
rm -r infinigen/terrain/*.egg-info
rm -r infinigen/terrain/__pycache__
rm -r infinigen/terrain/build
bash infinigen/tools/install/compile_terrain.sh

build_custom_groundtruth:
bash ./infinigen/tools/install/compile_opengl.sh

build_flip_fluids:
bash ./infinigen/tools/install/compile_flip_fluids.sh

DOCKER_BUILD_PROGRESS ?= auto
DOCKER_TAG ?= infinigen_docker_img

Expand Down Expand Up @@ -100,4 +112,3 @@ docker-run-no-gpu-opengl:
-e "BLENDER=/opt/infinigen/blender/blender" \
-v $(PWD)/outputs:/opt/infinigen/outputs \
"$(DOCKER_TAG)" /bin/bash

11 changes: 10 additions & 1 deletion docs/Installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,21 @@ You will not be able to pull or merge infinigen v1.0.1 into a v1.0.0 repo withou
</details closed>

**Run these commands to get started**

Install dependencies:
```
# on Linux
# on Mac
arch -arm64 brew install llvm open-mpi libomp glm glew
```

```
git clone --recursive https://github.com/princeton-vl/infinigen.git
cd infinigen
conda create --name infinigen python=3.10
conda activate infinigen
bash install.sh
python setup.py build_ext
```
`install.sh` may take significant time to download Blender and compile all source files.
Ignore non-fatal warnings. See [Getting Help](#getting-help) for guidelines on posting github issues
Expand Down
42 changes: 21 additions & 21 deletions examples/generate_nature.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,6 @@
animation_policy, instance_scatter, detail,
)

from infinigen.assets.creatures import (
CarnivoreFactory, HerbivoreFactory, FishFactory, FishSchoolFactory, \
BeetleFactory, AntSwarmFactory, BirdFactory, SnakeFactory, \
CrustaceanFactory, FlyingBirdFactory, CrabFactory, LobsterFactory, SpinyLobsterFactory, \
DragonflyFactory
)

from infinigen.assets.scatters import (
pebbles, grass, snow_layer, ground_leaves, ground_twigs, \
chopped_trees, pinecone, fern, flowerplant, monocot, ground_mushroom, \
Expand All @@ -42,11 +35,18 @@
)

from infinigen.assets import (
fluid, cactus, cactus, trees, monocot, rocks, underwater
fluid,
cactus,
cactus,
trees,
monocot,
rocks,
underwater,
creatures,
lighting,
weather
)
from infinigen.terrain import Terrain
from infinigen.assets.lighting import sky_lighting, glowing_rocks, caustics_lamp
from infinigen.assets.weather import kole_clouds, particles, cloud

from infinigen.core.util import (
blender as butil,
Expand All @@ -56,7 +56,6 @@
from infinigen.core.util.organization import Tags
from infinigen.core.util.random import sample_registry, random_general
from infinigen.core.util.math import FixedSeed, int_hash

from infinigen.core import execute_tasks, surface

@gin.configurable
Expand All @@ -81,7 +80,7 @@ def add_coarse_terrain():
underwater_domain = params.get('underwater_domain_tags')
nonliving_domain = params.get('nonliving_domain_tags')

p.run_stage('fancy_clouds', kole_clouds.add_kole_clouds)
p.run_stage('fancy_clouds', weather.kole_clouds.add_kole_clouds)

season = p.run_stage('season', trees.random_season, use_chance=False)
logging.info(f'{season=}')
Expand Down Expand Up @@ -118,7 +117,7 @@ def add_bushes(terrain_mesh):
p.run_stage('bushes', add_bushes, terrain_mesh)

def add_clouds(terrain_mesh):
cloud_factory = cloud.CloudFactory(int_hash((scene_seed, 0)), coarse=True, terrain_mesh=terrain_mesh)
cloud_factory = weather.CloudFactory(int_hash((scene_seed, 0)), coarse=True, terrain_mesh=terrain_mesh)
placement.scatter_placeholders(cloud_factory.spawn_locations(), cloud_factory)
p.run_stage('clouds', add_clouds, terrain_mesh)

Expand All @@ -136,7 +135,7 @@ def add_boulders(terrain_mesh):

def add_glowing_rocks(terrain_mesh):
selection = density.placement_mask(uniform(0.03, 0.3), normal_thresh=-1.1, select_thresh=0, tag=Tags.Cave)
fac = glowing_rocks.GlowingRocksFactory(int_hash((scene_seed, 0)), coarse=True)
fac = lighting.GlowingRocksFactory(int_hash((scene_seed, 0)), coarse=True)
placement.scatter_placeholders_mesh(terrain_mesh, fac,
overall_density=params.get("glow_rock_density", 0.025), selection=selection)
p.run_stage('glowing_rocks', add_glowing_rocks, terrain_mesh)
Expand Down Expand Up @@ -173,7 +172,7 @@ def camera_preprocess():
)
cam = cam_util.get_camera(0, 0)

p.run_stage('lighting', sky_lighting.add_lighting, cam, use_chance=False)
p.run_stage('lighting', lighting.sky_lighting.add_lighting, cam, use_chance=False)

# determine a small area of the terrain for the creatures to run around on
# must happen before camera is animated, as camera may want to follow them around
Expand All @@ -189,7 +188,8 @@ def add_ground_creatures(target):
fac_class = sample_registry(params['ground_creature_registry'])
fac = fac_class(int_hash((scene_seed, 0)), bvh=terrain_bvh, animation_mode='idle')
n = params.get('max_ground_creatures', randint(1, 4))
selection = density.placement_mask(select_thresh=0, tag='beach', altitude_range=(-0.5, 0.5)) if fac_class is CrabFactory else 1
selection = density.placement_mask(select_thresh=0, tag='beach', altitude_range=(-0.5, 0.5)) \
if fac_class is creatures.CrabFactory else 1
col = placement.scatter_placeholders_mesh(target, fac, num_placeholders=n, overall_density=1, selection=selection, altitude=0.2)
return list(col.objects)
pois += p.run_stage('ground_creatures', add_ground_creatures, target=terrain_center, default=[])
Expand Down Expand Up @@ -226,13 +226,13 @@ def flying_creatures():
deps = bpy.context.evaluated_depsgraph_get()
terrain_inview_bvh = mathutils.bvhtree.BVHTree.FromObject(terrain_inview, deps)

p.run_stage('caustics', lambda: caustics_lamp.add_caustics(terrain_near))
p.run_stage('caustics', lambda: lighting.caustics_lamp.add_caustics(terrain_near))

def add_fish_school():
n = random_general(params.get("max_fish_schools", 3))
for i in range(n):
selection = density.placement_mask(0.1, select_thresh=0, tag=underwater_domain)
fac = FishSchoolFactory(randint(1e7), bvh=terrain_inview_bvh)
fac = creatures.FishSchoolFactory(randint(1e7), bvh=terrain_inview_bvh)
col = placement.scatter_placeholders_mesh(terrain_near, fac, selection=selection,
overall_density=1, num_placeholders=1, altitude=2)
placement.populate_collection(fac, col)
Expand All @@ -241,7 +241,7 @@ def add_fish_school():
def add_bug_swarm():
n = randint(1, params.get("max_bug_swarms", 3) + 1)
selection = density.placement_mask(0.1, select_thresh=0, tag=land_domain)
fac = AntSwarmFactory(randint(1e7), bvh=terrain_inview_bvh, coarse=True)
fac = creatures.AntSwarmFactory(randint(1e7), bvh=terrain_inview_bvh, coarse=True)
col = placement.scatter_placeholders_mesh(terrain_inview, fac,
selection=selection, overall_density=1, num_placeholders=n, altitude=2)
placement.populate_collection(fac, col)
Expand Down Expand Up @@ -330,8 +330,8 @@ def add_corals(target):
p.run_stage('decorative_plants', lambda: decorative_plants.apply(terrain_near,
selection=density.placement_mask(scale=uniform(0.05, 0.2), select_thresh=uniform(0.5, 0.65), tag=land_domain, return_scalar=True)))

p.run_stage('wind', particles.wind_effector)
p.run_stage('turbulence', particles.turbulence_effector)
p.run_stage('wind', weather.particles.wind_effector)
p.run_stage('turbulence', weather.particles.turbulence_effector)
emitter_off = Vector((0, 0, 5)) # to allow space to fall into frame from off screen

def add_leaf_particles():
Expand Down
3 changes: 3 additions & 0 deletions examples/scripts/hello_world.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
python -m infinigen.datagen.manage_jobs --output_folder outputs/hello_world --num_scenes 1 --specific_seed 0 \
--configs desert.gin simple.gin --pipeline_configs local_16GB.gin monocular.gin blender_gt.gin --pipeline_overrides LocalScheduleHandler.use_gpu=False \
$@
11 changes: 11 additions & 0 deletions examples/scripts/hello_world_stepbystep.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Generate a scene layout
python examples/generate_nature.py -- --seed 0 --task coarse -g desert.gin simple.gin --output_folder outputs/helloworld/coarse

# Populate unique assets
python examples/generate_nature.py -- --seed 0 --task populate fine_terrain -g desert.gin simple.gin --input_folder outputs/helloworld/coarse --output_folder outputs/helloworld/fine

# Render RGB images
python examples/generate_nature.py -- --seed 0 --task render -g desert.gin simple.gin --input_folder outputs/helloworld/fine --output_folder outputs/helloworld/frames

# Render again for accurate ground-truth
python examples/generate_nature.py -- --seed 0 --task render -g desert.gin simple.gin --input_folder outputs/helloworld/fine --output_folder outputs/helloworld/frames -p render.render_image_func=@flat/render_image
File renamed without changes.
2 changes: 1 addition & 1 deletion examples/scripts/render_video_1080p.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ HOSTFIRST=$(hostname | tr "." "\n" | head -n 1)
JOBNAME=$(date '+%m_%d_%H_%M').$HOSTFIRST.$1

python -m infinigen.datagen.manage_jobs --output_folder outputs/$JOBNAME \
--num_scenes 100 --pipeline_config $@ stereo_video cuda_terrain opengl_gt_noshortrender \
--num_scenes 100 --pipeline_config $@ stereo_video cuda_terrain opengl_gt_noshortrender upload \
--wandb_mode online --cleanup big_files \
--warmup_sec 40000 \
--config high_quality_terrain
File renamed without changes.
1 change: 1 addition & 0 deletions infinigen/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = '1.1.0'
8 changes: 5 additions & 3 deletions infinigen/assets/creatures/util/geometry/blending.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@
from infinigen.core.util.math import FixedSeed
from infinigen.core.util import blender as butil

from infinigen.assets.creatures.geometry.nurbs import blender_mesh_from_pydata, compute_cylinder_topology
from infinigen.assets.creatures.geometry import nurbs
from infinigen.assets.creatures.geometry import nurbs, lofting, skin_ops
from infinigen.assets.creatures.util.geometry.nurbs import blender_mesh_from_pydata, compute_cylinder_topology
from infinigen.assets.creatures.util.geometry import nurbs
from infinigen.assets.creatures.util.geometry import nurbs, lofting, skin_ops

raise NotImplementedError ('blending.py not currently used, please re-add shapely as a dependency and delete this line')

from shapely.geometry import Polygon, Point, LineString
import shapely
Expand Down
21 changes: 0 additions & 21 deletions infinigen/assets/creatures/util/geometry/cpp_utils/setup_linux.py

This file was deleted.

23 changes: 0 additions & 23 deletions infinigen/assets/creatures/util/geometry/cpp_utils/setup_macos.py

This file was deleted.

This file was deleted.

11 changes: 10 additions & 1 deletion infinigen/assets/fluid/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
from .fluid_scenecomp_additions import cached_fire_scenecomp_options
from .fluid_scenecomp_additions import cached_fire_scenecomp_options
from .fluid import set_fire_to_assets
from .asset_cache import FireCachingSystem
from .cached_factory_wrappers import (
CachedBoulderFactory,
CachedBushFactory,
CachedCactusFactory,
CachedCreatureFactory,
CachedTreeFactory
)
3 changes: 3 additions & 0 deletions infinigen/assets/lighting/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import sky_lighting
from .caustics_lamp import CausticsLampFactory
from .glowing_rocks import GlowingRocksFactory
3 changes: 2 additions & 1 deletion infinigen/assets/rocks/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from . import *
from .blender_rock import BlenderRockFactory
from .boulder import BoulderFactory
3 changes: 3 additions & 0 deletions infinigen/assets/weather/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import particles, cloud
from .cloud import CloudFactory
from .kole_clouds import add_kole_clouds
Loading

0 comments on commit c4a14d6

Please sign in to comment.