Skip to content

Commit

Permalink
Merge pull request #266 from princeton-vl/develop
Browse files Browse the repository at this point in the history
v1.8.2 bugfix
  • Loading branch information
araistrick committed Sep 17, 2024
2 parents 88fb49c + b0293a2 commit a231df3
Show file tree
Hide file tree
Showing 53 changed files with 1,421 additions and 1,341 deletions.
2 changes: 2 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
BasedOnStyle: Microsoft
ColumnLimit: 100
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ infinigen/assets/fluid/* @karhankayan
# Jerry will review all object assets except where specified below
infinigen/assets/objects/* @JerryLingjieMei
infinigen/assets/objects/creatures/* @araistrick
infinigen/assets/objects/trees/* @araistrick
infinigen/assets/objects/trees/* @araistrick
9 changes: 0 additions & 9 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,9 @@
[submodule "infinigen/datagen/customgt/dependencies/cnpy"]
path = infinigen/datagen/customgt/dependencies/cnpy
url = https://github.com/rogersce/cnpy.git
[submodule "infinigen/datagen/customgt/dependencies/indicators"]
path = infinigen/datagen/customgt/dependencies/indicators
url = https://github.com/p-ranav/indicators.git
[submodule "infinigen/datagen/customgt/dependencies/tinycolormap"]
path = infinigen/datagen/customgt/dependencies/tinycolormap
url = https://github.com/yuki-koyama/tinycolormap.git
[submodule "infinigen/datagen/customgt/dependencies/glm"]
path = infinigen/datagen/customgt/dependencies/glm
url = https://github.com/g-truc/glm.git
[submodule "infinigen/datagen/customgt/dependencies/fast_obj"]
path = infinigen/datagen/customgt/dependencies/fast_obj
url = https://github.com/thisistherk/fast_obj.git
[submodule "infinigen/datagen/customgt/dependencies/json"]
path = infinigen/datagen/customgt/dependencies/json
url = https://github.com/nlohmann/json.git
Expand Down
7 changes: 7 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,10 @@ v1.8.1
- Fix silent output from upload stage, remove export from upload
- Reduce solving time spent on small objects

v1.8.2
- Remove nonessential opengl_gt packages
- Fix CrabFactory crash, FruitContainerFactory unparent object, wall parts
- Fix nature particles not visible in render
- Add smbpy du and df commands
- Fix fineterrain not included in export for optimize_diskusage=True
- Update mesher_backend config name & default commands
9 changes: 6 additions & 3 deletions docs/ConfiguringInfinigen.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ We recommend this command as a starting point for generating high quality videos
```bash
python -m infinigen.datagen.manage_jobs --output_folder outputs/my_videos --num_scenes 500 \
--pipeline_config slurm monocular_video cuda_terrain opengl_gt \
--cleanup big_files --warmup_sec 60000 --config trailer_video high_quality_terrain
--cleanup big_files --warmup_sec 60000 --config trailer_video high_quality_terrain \
-p fine_terrain.mesher_backend="OcMesher"
```

#### Creating large-scale stereo datasets
Expand Down Expand Up @@ -219,7 +220,8 @@ python -m infinigen.datagen.manage_jobs --output_folder outputs/my_videos --num_
python -m infinigen.datagen.manage_jobs --output_folder outputs/my_videos --num_scenes 500 \
--pipeline_config slurm monocular_video cuda_terrain opengl_gt \
--cleanup big_files --warmup_sec 30000 --config trailer_video high_quality_terrain \
--overrides camera.camera_pose_proposal.altitude=["uniform", 20, 30]
--overrides camera.camera_pose_proposal.altitude=["uniform", 20, 30] \
-p fine_terrain.mesher_backend="OcMesher"
```

:bulb: The command shown is overriding `infinigen_examples/configs_nature/base.gin`'s default setting of `camera.camera_pose_proposal.altitude`. You can use a similar syntax to override any number of .gin config entries. Separate multiple entries with spaces.
Expand All @@ -229,7 +231,8 @@ python -m infinigen.datagen.manage_jobs --output_folder outputs/my_videos --num_
python -m infinigen.datagen.manage_jobs --output_folder outputs/my_videos --num_scenes 500 \
--pipeline_config slurm monocular_video cuda_terrain opengl_gt \
--cleanup big_files --warmup_sec 30000 --config trailer_video high_quality_terrain \
--pipeline_overrides iterate_scene_tasks.frame_range=[1,25]
--pipeline_overrides iterate_scene_tasks.frame_range=[1,25] \
-p fine_terrain.mesher_backend="OcMesher"
```

:bulb: This command uses `--pipeline_overrides` rather than `--overrides` since it is providing a gin override to the `manage_jobs.py` process, not some part of the main `infinigen_examples/generate_nature.py` driver.
2 changes: 1 addition & 1 deletion infinigen/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import logging
from pathlib import Path

__version__ = "1.8.1"
__version__ = "1.8.2"


def repo_root():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def make_part(self, params) -> Part:
displace_vertices(obj, lambda x, y, z: (0, 0, height_scale(x / x_length)))
self.add_head(obj, params)

line = new_line(x_length)
line = new_line(1, x_length)
line.location[0] -= x_length
butil.apply_transform(line, loc=True)

Expand Down
3 changes: 2 additions & 1 deletion infinigen/assets/objects/tableware/fruit_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __init__(self, factory_seed=0):
def apply(self, obj, selection=None):
for obj in obj if isinstance(obj, Iterable) else [obj]:
scale = uniform(0.06, 0.08) / self.shrink_rate
scatter_instances(
scattered = scatter_instances(
base_obj=obj,
collection=self.col,
density=1e3,
Expand All @@ -53,6 +53,7 @@ def apply(self, obj, selection=None):
apply_geo=True,
realize=True,
)
scattered.parent = obj


class FruitContainerFactory(AssetFactory):
Expand Down
8 changes: 7 additions & 1 deletion infinigen/assets/scatters/ivy.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,14 @@ def apply(self, obj, selection=None):
)

def end_index(nw):
if len(scatter_obj.data.vertices) == 0:
i = 0
else:
i = np.random.randint(len(scatter_obj.data.vertices))
return nw.compare(
"EQUAL",
nw.new_node(Nodes.Index),
np.random.randint(len(scatter_obj.data.vertices)),
i,
)

def weight(nw):
Expand Down Expand Up @@ -135,7 +139,9 @@ def weight(nw):
input_args=[end_index, weight, uniform(0.1, 0.15), uniform(0.1, 0.15)],
)
fix_tree(scatter_obj)

surface.add_geomod(scatter_obj, geo_radius, apply=True, input_args=[0.005, 12])

assign_material(scatter_obj, shaderfunc_to_material(shader_simple_brown))
surface.add_geomod(scatter_obj, geo_leaf, apply=True, input_args=[self.col])

Expand Down
11 changes: 8 additions & 3 deletions infinigen/assets/weather/particles.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ def spawn_emitter(follow_cam, mesh_type, size, offset, name=None):
emitter.name = f"emitter({name=}, {mesh_type=})"

emitter.hide_viewport = True
emitter.hide_render = True
emitter.hide_render = True # will be undone if any particle systems are added

butil.put_in_collection(emitter, butil.get_collection("particles"))

return emitter

Expand Down Expand Up @@ -156,9 +158,12 @@ def generate(
emitter, col, self.params, collision
)

system.name = repr(self)
system.settings.name = repr(self) + ".settings"
emitter.hide_render = False

logger.info(f"{self} baking particles")
particles.bake(emitter, system)

butil.put_in_collection(emitter, butil.get_collection("particles"))
particles.bake(emitter, system)

return emitter
4 changes: 2 additions & 2 deletions infinigen/core/constraints/example_solver/annealing.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def __init__(
self.last_eval_result = None

self.eval_memo = {}
self.stats = []

def save_stats(self, path):
if len(self.stats) == 0:
Expand All @@ -76,7 +77,7 @@ def save_stats(self, path):
fig, ax1 = plt.subplots()
ax1.set_xlabel("Iteration")
ax1.set_ylabel("Score", color="C0")
ax1.plot(df["curr_iteration"], df["loss"], color="C0")
ax1.plot(np.arange(len(df)), df["loss"], color="C0")

# ax2 = ax1.twinx()
# ax2.set_ylabel('Move Time', color='C1')
Expand All @@ -91,7 +92,6 @@ def save_stats(self, path):

def reset(self, max_iters):
self.curr_iteration = 0
self.stats = []
self.curr_result = None
self.best_loss = None
self.eval_memo = {}
Expand Down
31 changes: 23 additions & 8 deletions infinigen/core/constraints/example_solver/room/decorate.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,15 +276,30 @@ def room_walls(walls: list[bpy.types.Object], constants: RoomConstants, n_walls=
i = np.argmax(
read_edge_length(w) - 100 * (np.abs(co[u, -1] - co[v, -1]) > 0.1)
)
center = read_center(w)[:, :2]
u_ = co[np.newaxis, u[i], :2]
v_ = co[np.newaxis, v[i], :2]
alternative = (
np.linalg.norm(center - u_, axis=-1)
+ np.linalg.norm(center - v_, axis=-1)
- np.linalg.norm(u_ - v_, axis=-1)
< 0.1
u_ = co[u[i]]
v_ = co[v[i]]
non_vertical = np.linalg.norm((co[u] - co[v])[:, :2], axis=-1) > 1e-2
directional = (
np.abs(np.cross((co[u] - co[v])[:, :2], (u_ - v_)[np.newaxis, :2]))
< 1e-4
)
collinear = (
np.abs(np.cross((co[u] - v_)[:, :2], (u_ - v_)[np.newaxis, :2]))
< 1e-4
)
collinear_ = (
np.abs(np.cross((co[u] - u_)[:, :2], (u_ - v_)[np.newaxis, :2]))
< 1e-4
)
aligned = non_vertical & directional & collinear & collinear_
with butil.ViewportMode(w, "EDIT"):
bm = bmesh.from_edit_mesh(w.data)
bm.faces.ensure_lookup_table()
alternative = np.zeros(len(bm.faces), dtype=int)
for f in bm.faces:
for e in f.edges:
if aligned[e.index]:
alternative[f.index] = 1
write_attr_data(
w, "alternative", alternative, type="INT", domain="FACE"
)
Expand Down
1 change: 0 additions & 1 deletion infinigen/core/constraints/example_solver/solve.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ def solve_objects(
for j in ra:
move_gen = self.choose_move_type(moves, j, n_steps)
self.optim.step(consgraph, self.state, move_gen, filter_domain)
self.optim.save_stats(self.output_folder / f"optim_{desc}.csv")

logger.info(
f"Finished solving {desc_full}, added {len(self.state.objs) - n_start} "
Expand Down
2 changes: 1 addition & 1 deletion infinigen/core/execute_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ def execute_tasks(
col.hide_viewport = False

if need_terrain_processing and (
Task.Render in task or Task.GroundTruth in task or Task.MeshSave in task
Task.Render in task or Task.GroundTruth in task or Task.MeshSave in task or Task.Export in task
):
terrain = Terrain(
scene_seed,
Expand Down
9 changes: 6 additions & 3 deletions infinigen/core/placement/particles.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
def bake(emitter, system):
logger.info(f"Baking particles for {emitter.name=}")

hide_orig = emitter.hide_viewport
emitter.hide_viewport = False

with butil.SelectObjects(emitter):
override = {
"scene": bpy.context.scene,
Expand All @@ -33,6 +36,8 @@ def bake(emitter, system):
bpy.ops.ptcache.bake(override, bake=True)
bpy.context.scene.frame_end -= 1

emitter.hide_viewport = hide_orig


def configure_boids(system_config, settings):
boids = system_config.boids
Expand Down Expand Up @@ -92,10 +97,8 @@ def particle_system(
if isinstance(subject, bpy.types.Collection):
subject = as_particle_collection(subject)

emitter.name = f"particles:emitter({subject.name.split(':')[-1]})"

mod = emitter.modifiers.new(name="PARTICLE", type="PARTICLE_SYSTEM")
system = emitter.particle_systems[mod.name]
system = mod.particle_system

emitter.show_instancer_for_viewport = False
emitter.show_instancer_for_render = False
Expand Down
1 change: 1 addition & 0 deletions infinigen/core/util/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def _should_run_stage(self, name, use_chance, prereq):
if not e["ran"]:
logger.info(f"Skipping run_stage({name}...) due to unmet {prereq=}")
return

with FixedSeed(int_hash((self.scene_seed, name, 0))):
if not self.params.get(f"{name}_enabled", True):
logger.debug(f"Not running {name} due to manually set not enabled")
Expand Down
13 changes: 3 additions & 10 deletions infinigen/datagen/customgt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,16 @@ endif()

add_definitions(-D GLM_ENABLE_EXPERIMENTAL)
add_definitions(-D PROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR})
include_directories(include/)
include_directories(/usr/include/) # on linux
include_directories(dependencies) # for cnpy
include_directories(dependencies/indicators/include)
include_directories(dependencies/argparse/include)
include_directories(dependencies/eigen)
include_directories(dependencies/tinycolormap/include)
include_directories(dependencies/glm)
include_directories(dependencies/json/single_include)
include_directories(dependencies/glad/include)
include_directories(dependencies/scharstein_flow_viz)

add_subdirectory(dependencies/cnpy)
add_subdirectory(dependencies/fast_obj)
add_subdirectory(dependencies/tinycolormap)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Expand All @@ -39,17 +35,14 @@ elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
find_package(OpenGL REQUIRED COMPONENTS OpenGL EGL GLX)
endif()

file(GLOB ADJACENT_SRC_FILES
"*.hpp"
"*.cpp"
)
file(GLOB ADJACENT_SRC_FILES "src/*.cpp")

# This line was taken from https://stackoverflow.com/a/52137618/5057543
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
link_libraries(stdc++fs)
endif()

add_executable(customgt ${ADJACENT_SRC_FILES} dependencies/scharstein_flow_viz/colorcode.cpp dependencies/fast_obj/fast_obj.h dependencies/fast_obj/fast_obj.c dependencies/glad/src/glad.c dependencies/glad/src/glad_egl.c)
add_executable(customgt main.cpp ${ADJACENT_SRC_FILES} dependencies/glad/src/glad.c dependencies/glad/src/glad_egl.c)

set_property(TARGET customgt PROPERTY CXX_STANDARD 17)

Expand Down
Loading

0 comments on commit a231df3

Please sign in to comment.