diff --git a/.gitignore b/.gitignore index 254321a68..c63bc14dc 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,8 @@ blender blender.tar.xz Blender.app +.nfs* + *.c .coverage diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 88d22ecbd..e03659896 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -120,4 +120,13 @@ v1.8.3 v1.9.0 - Add CoPlanar indoor constraint, fix backwards tvs/monitors/sinks - Fix empty scene / null objects selected during export -- Add full system visual check / integration script \ No newline at end of file +- Add full system visual check / integration script + +v1.9.1 +- Reduce excessive polycount in bottles and tableware objects +- Fix alignment of windows +- Fix wall materials not being deterministic w.r.t random seed +- Fix gin configs not correctly passed to slurm jobs in generate_individual_assets +- Fix integration test image titles +- Fix integration test asset image alignment +- Make multistory houses disabled by default \ No newline at end of file diff --git a/infinigen/__init__.py b/infinigen/__init__.py index 968900e72..0597c2d9f 100644 --- a/infinigen/__init__.py +++ b/infinigen/__init__.py @@ -6,7 +6,7 @@ import logging from pathlib import Path -__version__ = "1.9.0" +__version__ = "1.9.1" def repo_root(): diff --git a/infinigen/assets/objects/bathroom/toilet.py b/infinigen/assets/objects/bathroom/toilet.py index dc7ebee03..6e6d8701c 100644 --- a/infinigen/assets/objects/bathroom/toilet.py +++ b/infinigen/assets/objects/bathroom/toilet.py @@ -139,7 +139,7 @@ def make_tube(self, lower, upper): bpy.ops.mesh.select_mode(type="EDGE") bpy.ops.mesh.select_all(action="SELECT") bpy.ops.mesh.bridge_edge_loops( - number_cuts=np.random.randint(12, 16), + number_cuts=64, profile_shape_factor=uniform(0.1, 0.2), interpolation="SURFACE", ) @@ -242,7 +242,7 @@ def make_stand(self, obj, bottom): bpy.ops.mesh.select_mode(type="EDGE") bpy.ops.mesh.select_all(action="SELECT") bpy.ops.mesh.bridge_edge_loops( - number_cuts=np.random.randint(12, 16), + number_cuts=64, profile_shape_factor=uniform(0.0, 0.15), ) return stand diff --git a/infinigen/assets/objects/monocot/banana.py b/infinigen/assets/objects/monocot/banana.py index ef581102e..abc24856d 100644 --- a/infinigen/assets/objects/monocot/banana.py +++ b/infinigen/assets/objects/monocot/banana.py @@ -12,6 +12,7 @@ from infinigen.assets.utils.draw import bezier_curve, leaf from infinigen.assets.utils.nodegroup import geo_radius from infinigen.assets.utils.object import join_objects, origin2lowest +from infinigen.assets.utils.shapes import point_normal_up from infinigen.core import surface from infinigen.core.tagging import tag_object from infinigen.core.util import blender as butil @@ -134,6 +135,7 @@ def __init__(self, factory_seed, coarse=False): self.max_y_angle = uniform(-np.pi * 0.05, 0) def displace_veins(self, obj): + point_normal_up(obj) vg = obj.vertex_groups.new(name="distance") x, y, z = read_co(obj).T branch = np.cos( diff --git a/infinigen/assets/objects/monocot/veratrum.py b/infinigen/assets/objects/monocot/veratrum.py index 77f3d5394..64208baa8 100644 --- a/infinigen/assets/objects/monocot/veratrum.py +++ b/infinigen/assets/objects/monocot/veratrum.py @@ -163,7 +163,7 @@ def build_leaf(self, face_size): [0, 2, 4], dupli=True, loop=True, - resolution=np.random.randint(3, 5), + rotation_resolution=np.random.randint(3, 5), axis=(1, 0, 0), ) butil.modify_mesh(obj, "WELD", merge_threshold=face_size / 2) diff --git a/infinigen/assets/objects/mushroom/cap.py b/infinigen/assets/objects/mushroom/cap.py index 04dc8fd7c..b44e55d1c 100644 --- a/infinigen/assets/objects/mushroom/cap.py +++ b/infinigen/assets/objects/mushroom/cap.py @@ -313,7 +313,7 @@ def create_asset(self, face_size, **params) -> bpy.types.Object: gill_config["vector_locations"], dupli=True, loop=True, - resolution=np.random.randint(8, 20), + rotation_resolution=np.random.randint(8, 20), ) subsurface2face_size(gill, face_size) assign_material(gill, self.material) diff --git a/infinigen/assets/objects/seating/chairs/chair.py b/infinigen/assets/objects/seating/chairs/chair.py index ffce7f90f..80208e7b2 100644 --- a/infinigen/assets/objects/seating/chairs/chair.py +++ b/infinigen/assets/objects/seating/chairs/chair.py @@ -226,7 +226,7 @@ def make_seat(self): * self.thickness ) vector_locations = [1, 7] if self.is_seat_round else [1, 3, 5, 7] - obj = bezier_curve((x_anchors, y_anchors, z_anchors), vector_locations, 8) + obj = bezier_curve((x_anchors, y_anchors, z_anchors), vector_locations) with butil.ViewportMode(obj, "EDIT"): bpy.ops.mesh.select_all(action="SELECT") bpy.ops.mesh.fill_grid(use_interp_simple=True) @@ -260,9 +260,7 @@ def make_limb(self, leg_ends, leg_starts): case _: axes = None scale = None - limb = align_bezier( - np.stack([leg_start, leg_end], -1), axes, scale, resolution=64 - ) + limb = align_bezier(np.stack([leg_start, leg_end], -1), axes, scale) limb.location = ( np.array( [ @@ -335,7 +333,7 @@ def make_back_decors(self, backs, finalize=True): & (center[:, -1] <= z_max * self.back_height), ) bpy.ops.mesh.bridge_edge_loops( - number_cuts=32, + number_cuts=64, interpolation="LINEAR", smoothness=smoothness, profile_shape_factor=profile_shape_factor, diff --git a/infinigen/assets/objects/tableware/bottle.py b/infinigen/assets/objects/tableware/bottle.py index 8b32d70d0..67b9c82f9 100644 --- a/infinigen/assets/objects/tableware/bottle.py +++ b/infinigen/assets/objects/tableware/bottle.py @@ -198,7 +198,6 @@ def make_bottle(self): z_anchors = np.array(self.z_anchors) * self.z_length anchors = x_anchors, 0, z_anchors obj = spin(anchors, np.nonzero(self.is_vector)[0]) - subsurf(obj, 1, True) subsurf(obj, 1) if self.bottle_width > 0: butil.modify_mesh(obj, "SOLIDIFY", thickness=self.bottle_width) diff --git a/infinigen/assets/objects/tableware/bowl.py b/infinigen/assets/objects/tableware/bowl.py index d260eb912..6dcefe5f9 100644 --- a/infinigen/assets/objects/tableware/bowl.py +++ b/infinigen/assets/objects/tableware/bowl.py @@ -27,9 +27,9 @@ def __init__(self, factory_seed, coarse=False): self.x_bottom = uniform(0.2, 0.3) * self.x_end self.x_mid = uniform(0.8, 0.95) * self.x_end self.has_guard = False - self.thickness = uniform(0.01, 0.03) self.has_inside = uniform(0, 1) < 0.5 self.scale = log_uniform(0.15, 0.4) + self.thickness = uniform(0.01, 0.03) * self.scale self.edge_wear = None def create_placeholder(self, **kwargs) -> bpy.types.Object: @@ -46,15 +46,12 @@ def create_asset(self, **params) -> bpy.types.Object: self.x_end, ) z_anchors = 0, 0, 0, self.z_bottom, self.z_length / 2, self.z_length - anchors = x_anchors, np.zeros_like(x_anchors), z_anchors - obj = spin(anchors, [2, 3], 16, 64) - subsurf(obj, 1) + anchors = np.array(x_anchors) * self.scale, 0, np.array(z_anchors) * self.scale + obj = spin(anchors, [2, 3]) self.solidify_with_inside(obj, self.thickness) butil.modify_mesh( obj, "BEVEL", width=self.thickness / 2, segments=np.random.randint(2, 5) ) - obj.scale = [self.scale] * 3 - butil.apply_transform(obj) subsurf(obj, 1) set_shade_smooth(obj) return obj diff --git a/infinigen/assets/objects/tableware/cup.py b/infinigen/assets/objects/tableware/cup.py index ffaeed975..6f424cecf 100644 --- a/infinigen/assets/objects/tableware/cup.py +++ b/infinigen/assets/objects/tableware/cup.py @@ -79,9 +79,10 @@ def create_asset(self, **params) -> bpy.types.Object: self.x_end, ) z_anchors = 0, 0, self.depth * 0.5, self.depth - anchors = x_anchors, np.zeros_like(x_anchors), z_anchors - obj = spin(anchors, [1], 16) - subsurf(obj, 1) + anchors = np.array(x_anchors) * self.scale, 0, np.array(z_anchors) * self.scale + obj = spin(anchors, [1]) + obj.scale = [1 / self.scale] * 3 + butil.apply_transform(obj, True) butil.modify_mesh( obj, "BEVEL", @@ -95,6 +96,7 @@ def create_asset(self, **params) -> bpy.types.Object: else: wrap = None self.solidify_with_inside(obj, self.thickness) + subsurf(obj, 2) handle_location = ( x_anchors[-2] * (1 - self.handle_location) + x_anchors[-1] * self.handle_location, diff --git a/infinigen/assets/objects/tableware/jar.py b/infinigen/assets/objects/tableware/jar.py index 1f46f7d1a..f8ec32850 100644 --- a/infinigen/assets/objects/tableware/jar.py +++ b/infinigen/assets/objects/tableware/jar.py @@ -67,7 +67,7 @@ def create_asset(self, **params) -> bpy.types.Object: bpy.ops.mesh.extrude_edges_move( TRANSFORM_OT_translate={"value": (0, 0, self.z_cap * self.z_length)} ) - subsurf(obj, 1) + subsurf(obj, 2) butil.modify_mesh(obj, "SOLIDIFY", thickness=self.thickness) cap = new_cylinder(vertices=64) diff --git a/infinigen/assets/objects/tableware/knife.py b/infinigen/assets/objects/tableware/knife.py index c4515e23a..6be6cbdda 100644 --- a/infinigen/assets/objects/tableware/knife.py +++ b/infinigen/assets/objects/tableware/knife.py @@ -108,6 +108,7 @@ def selection(nw, x): selection = self.make_double_sided(selection) self.add_guard(obj, selection) subsurf(obj, 1) + subsurf(obj, 1, True) obj.scale = [self.scale] * 3 butil.apply_transform(obj) return obj diff --git a/infinigen/assets/objects/tableware/plate.py b/infinigen/assets/objects/tableware/plate.py index 461b78f46..048aadadf 100644 --- a/infinigen/assets/objects/tableware/plate.py +++ b/infinigen/assets/objects/tableware/plate.py @@ -26,21 +26,19 @@ def __init__(self, factory_seed, coarse=False): self.z_mid = uniform(0.3, 0.8) * self.z_length self.has_guard = False self.pre_level = 1 - self.thickness = uniform(0.01, 0.03) self.has_inside = uniform(0, 1) < 0.2 self.scale = log_uniform(0.2, 0.4) + self.thickness = uniform(0.01, 0.03) * self.scale self.scratch = self.edge_wear = None def create_asset(self, **params) -> bpy.types.Object: x_anchors = 0, self.x_mid, self.x_mid, self.x_end z_anchors = 0, 0, self.z_mid, self.z_length - anchors = x_anchors, np.zeros_like(x_anchors), z_anchors - obj = spin(anchors, [1, 2], 4, 16) + anchors = np.array(x_anchors) * self.scale, 0, np.array(z_anchors) * self.scale + obj = spin(anchors, [1, 2]) butil.modify_mesh( obj, "SUBSURF", render_levels=self.pre_level, levels=self.pre_level ) self.solidify_with_inside(obj, self.thickness) - subsurf(obj, 2) - obj.scale = [self.scale] * 3 - butil.apply_transform(obj) + subsurf(obj, 1) return obj diff --git a/infinigen/assets/objects/tableware/wineglass.py b/infinigen/assets/objects/tableware/wineglass.py index 07dd8890c..ea3ce4fc1 100644 --- a/infinigen/assets/objects/tableware/wineglass.py +++ b/infinigen/assets/objects/tableware/wineglass.py @@ -8,7 +8,6 @@ from infinigen.assets.materials import glass from infinigen.assets.objects.tableware.base import TablewareFactory -from infinigen.assets.utils.decorate import subsurf from infinigen.assets.utils.draw import spin from infinigen.core.util import blender as butil from infinigen.core.util.math import FixedSeed @@ -43,10 +42,8 @@ def create_asset(self, **params) -> bpy.types.Object: ) z_anchors = 0, z_bottom / 2, z_bottom, self.z_cup, self.z_mid, self.z_length anchors = x_anchors, np.zeros_like(x_anchors), z_anchors - obj = spin(anchors, [0, 1, 2, 3], 4, 16) - subsurf(obj, 2) + obj = spin(anchors, [0, 1, 2, 3]) butil.modify_mesh(obj, "SOLIDIFY", thickness=self.thickness) - subsurf(obj, 1) obj.scale = [self.scale] * 3 butil.apply_transform(obj) diff --git a/infinigen/assets/utils/draw.py b/infinigen/assets/utils/draw.py index fbfdab1f9..dd3a62567 100644 --- a/infinigen/assets/utils/draw.py +++ b/infinigen/assets/utils/draw.py @@ -74,7 +74,7 @@ def surface_from_func(fn, div_x=16, div_y=16, size_x=2, size_y=2): return mesh -def bezier_curve(anchors, vector_locations=(), resolution=64, to_mesh=True): +def bezier_curve(anchors, vector_locations=(), resolution=None, to_mesh=True): n = [len(r) for r in anchors if isinstance(r, Sized)][0] anchors = np.array( [ @@ -98,22 +98,37 @@ def bezier_curve(anchors, vector_locations=(), resolution=64, to_mesh=True): else: points[i].handle_left_type = "AUTO" points[i].handle_right_type = "AUTO" - obj.data.splines[0].resolution_u = resolution - if to_mesh: - return curve2mesh(obj) - return obj + obj.data.splines[0].resolution_u = resolution if resolution is not None else 12 + if not to_mesh: + return obj + return curve2mesh(obj) def curve2mesh(obj): + points = obj.data.splines[0].bezier_points + cos = np.array([p.co for p in points]) + length = np.linalg.norm(cos[:-1] - cos[1:], axis=-1) + min_length = 5e-3 + with butil.ViewportMode(obj, "EDIT"): + for i in reversed(range(len(points) - 1)): + points = list(obj.data.splines[0].bezier_points) + number_cuts = min(int(length[i] / min_length) - 1, 64) + if number_cuts < 0: + continue + bpy.ops.curve.select_all(action="DESELECT") + points[i].select_control_point = True + points[i + 1].select_control_point = True + bpy.ops.curve.subdivide(number_cuts=number_cuts) + obj.data.splines[0].resolution_u = 1 with butil.SelectObjects(obj): bpy.ops.object.convert(target="MESH") obj = bpy.context.active_object - butil.modify_mesh(obj, "WELD", merge_threshold=1e-4) + butil.modify_mesh(obj, "WELD", merge_threshold=1e-3) return obj def align_bezier( - anchors, axes=None, scale=None, vector_locations=(), resolution=64, to_mesh=True + anchors, axes=None, scale=None, vector_locations=(), resolution=None, to_mesh=True ): obj = bezier_curve(anchors, vector_locations, resolution, False) points = obj.data.splines[0].bezier_points @@ -145,9 +160,9 @@ def align_bezier( * np.linalg.norm(p.handle_right - p.co) * scale[2 * i + 1] ) - if to_mesh: - return curve2mesh(obj) - return obj + if not to_mesh: + return obj + return curve2mesh(obj) def remesh_fill(obj, resolution=0.005): @@ -168,22 +183,22 @@ def remesh_fill(obj, resolution=0.005): def spin( anchors, vector_locations=(), - subdivision=64, resolution=None, + rotation_resolution=None, axis=(0, 0, 1), loop=False, dupli=False, ): - obj = bezier_curve(anchors, vector_locations, subdivision) + obj = bezier_curve(anchors, vector_locations, resolution) co = read_co(obj) - max_radius = np.amax( + mean_radius = np.mean( np.linalg.norm( co - (co @ np.array(axis))[:, np.newaxis] * np.array(axis), axis=-1 ) ) - if resolution is None: - resolution = min(int(2 * np.pi * max_radius / 0.005), 128) - butil.modify_mesh(obj, "WELD", merge_threshold=1e-4) + if rotation_resolution is None: + rotation_resolution = min(int(2 * np.pi * mean_radius / 5e-3), 128) + butil.modify_mesh(obj, "WELD", merge_threshold=1e-3) if loop: with butil.ViewportMode(obj, "EDIT"), butil.Suppress(): bpy.ops.mesh.select_all(action="SELECT") @@ -191,9 +206,11 @@ def spin( remesh_fill(obj) with butil.ViewportMode(obj, "EDIT"), butil.Suppress(): bpy.ops.mesh.select_all(action="SELECT") - bpy.ops.mesh.spin(steps=resolution, angle=np.pi * 2, axis=axis, dupli=dupli) + bpy.ops.mesh.spin( + steps=rotation_resolution, angle=np.pi * 2, axis=axis, dupli=dupli + ) bpy.ops.mesh.select_all(action="SELECT") - bpy.ops.mesh.remove_doubles(threshold=1e-4) + bpy.ops.mesh.remove_doubles(threshold=1e-3) return obj diff --git a/infinigen/assets/utils/shapes.py b/infinigen/assets/utils/shapes.py index f9dc75751..82f35671f 100644 --- a/infinigen/assets/utils/shapes.py +++ b/infinigen/assets/utils/shapes.py @@ -121,7 +121,7 @@ def obj2polygon(obj): for p in obj.data.polygons ] ) - return shapely.make_valid(shapely.simplify(p, 1e-6)) + return shapely.ops.orient(shapely.make_valid(shapely.simplify(p, 1e-6))) def buffer(p, distance): diff --git a/infinigen/core/constraints/constraint_language/constants.py b/infinigen/core/constraints/constraint_language/constants.py index 5704f7098..c1178da51 100644 --- a/infinigen/core/constraints/constraint_language/constants.py +++ b/infinigen/core/constraints/constraint_language/constants.py @@ -150,7 +150,7 @@ def canonicalize(self, p): break if not is_valid_polygon(p): raise NotImplementedError("Invalid polygon") - return p + return orient(p) except AttributeError: raise NotImplementedError("Invalid multi polygon") diff --git a/infinigen/core/constraints/example_solver/room/contour.py b/infinigen/core/constraints/example_solver/room/contour.py index 7d822ad2d..4a7277f14 100644 --- a/infinigen/core/constraints/example_solver/room/contour.py +++ b/infinigen/core/constraints/example_solver/room/contour.py @@ -142,12 +142,14 @@ def decorate(self, state): quad_segs = ( 1 if corner_func == "sharp" else np.random.randint(4, 7) ) - exterior_ = ( + exterior_ = self.constants.canonicalize( exterior.difference(cutter) .union(shapely.Point(q).buffer(length, quad_segs=quad_segs)) .buffer(0) ) - new = state[k].polygon.intersection(exterior_).buffer(0) + new = self.constants.canonicalize( + state[k].polygon.intersection(exterior_).buffer(0) + ) if all( new.buffer(-m + 1e-2).geom_type == "Polygon" for m in np.linspace(0, 0.75, 4) diff --git a/infinigen/core/constraints/example_solver/room/decorate.py b/infinigen/core/constraints/example_solver/room/decorate.py index 909c04a44..a567f575e 100644 --- a/infinigen/core/constraints/example_solver/room/decorate.py +++ b/infinigen/core/constraints/example_solver/room/decorate.py @@ -45,7 +45,7 @@ from infinigen.core.surface import write_attr_data from infinigen.core.util import blender as butil from infinigen.core.util.blender import deep_clone_obj -from infinigen.core.util.math import int_hash +from infinigen.core.util.math import FixedSeed, int_hash from infinigen.core.util.random import log_uniform from infinigen.core.util.random import random_general as rg @@ -93,7 +93,7 @@ def split_rooms(rooms_meshed: list[bpy.types.Object]): def import_material(factory_name): - with gin.unlock_config(): + with gin.unlock_config(), FixedSeed(0): try: return importlib.import_module(f"infinigen.assets.materials.{factory_name}") except ImportError: diff --git a/infinigen/core/constraints/example_solver/room/solidifier.py b/infinigen/core/constraints/example_solver/room/solidifier.py index 82215d7c0..0077cba3f 100644 --- a/infinigen/core/constraints/example_solver/room/solidifier.py +++ b/infinigen/core/constraints/example_solver/room/solidifier.py @@ -42,6 +42,7 @@ from infinigen.core.util.random import random_general as rg from .base import RoomGraph, room_type, valid_rooms +from .utils import mls_ccw logger = logging.getLogger(__name__) @@ -210,7 +211,8 @@ def solidify(self, state): } exterior = next(k for k in state.objs if room_type(k) == Semantics.Exterior) exterior_edges = { - r.target_name: canonicalize_mls(r.value) for r in state[exterior].relations + r.target_name: mls_ccw(canonicalize_mls(r.value), state, r.target_name) + for r in state[exterior].relations } exterior_buffer = shapely.simplify( state[exterior].polygon.buffer(-wt / 2 - _eps, join_style="mitre"), 1e-3 @@ -538,7 +540,7 @@ def make_door_cutter(self, mls, direction): wt = self.constants.wall_thickness cutter.scale = ( self.constants.door_width / 2, - self.constants.door_width / 2 + wt, + self.constants.door_width + wt / 2, self.constants.door_size / 2 - _snap / 2, ) cutter.location[-1] += _snap / 2 diff --git a/infinigen/core/constraints/example_solver/room/utils.py b/infinigen/core/constraints/example_solver/room/utils.py index 84da9855d..960d82188 100644 --- a/infinigen/core/constraints/example_solver/room/utils.py +++ b/infinigen/core/constraints/example_solver/room/utils.py @@ -50,6 +50,18 @@ def update_exterior(state: State, i: str): r.value = MultiLineString(v) +def mls_ccw(mls: MultiLineString, state: State, i: str): + exterior = state[i].polygon.exterior + coords = np.array(exterior.coords[:-1]) + mls_ = [] + for ls in mls.geoms: + u, v = ls.coords[:2] + x = np.argmin(np.linalg.norm(coords - np.array(u)[np.newaxis], axis=-1)) + y = np.argmin(np.linalg.norm(coords - np.array(v)[np.newaxis], axis=-1)) + mls_.append(ls if x < y else shapely.reverse(ls)) + return MultiLineString(mls_) + + def update_staircase(state: State, i: str): pholder = room_name(Semantics.Staircase, room_level(i)) r = next(r for r in state[pholder].relations if r.target_name == i) diff --git a/infinigen/core/constraints/example_solver/state_def.py b/infinigen/core/constraints/example_solver/state_def.py index 3ede7e610..3754b3113 100644 --- a/infinigen/core/constraints/example_solver/state_def.py +++ b/infinigen/core/constraints/example_solver/state_def.py @@ -74,7 +74,7 @@ def __repr__(self): obj = self.obj tags = self.tags relations = self.relations - return f"{self.__class__.__name__}(obj.name={obj.name if obj is not None else obj.name}, polygon={self.polygon}, {tags=}, {relations=})" + return f"{self.__class__.__name__}(obj.name={obj.name if obj is not None else None}, polygon={self.polygon}, {tags=}, {relations=})" @dataclass diff --git a/infinigen/datagen/manage_jobs.py b/infinigen/datagen/manage_jobs.py index 407ea0307..fcfc4e780 100644 --- a/infinigen/datagen/manage_jobs.py +++ b/infinigen/datagen/manage_jobs.py @@ -679,7 +679,7 @@ def manage_datagen_jobs(all_scenes, elapsed, num_concurrent, disk_sleep_threshol print(message) if wandb is not None: wandb.alert( - title=f"{args.output_folder} full", + title=f"{args.output_folder.name} sleeping for full disk", text=message, wait_duration=3 * 60 * 60, ) diff --git a/infinigen/datagen/util/show_gpu_table.py b/infinigen/datagen/util/show_gpu_table.py index e8aaf0a51..87bb92dd1 100644 --- a/infinigen/datagen/util/show_gpu_table.py +++ b/infinigen/datagen/util/show_gpu_table.py @@ -35,7 +35,7 @@ def get_gpu_nodes(): for line in sinfo_output.splitlines(): node, group, gres, totalmem = line.split() if group != "all": - if group in {"pvl", "cs*"}: + if group in {"pvl", "cs*", "pnlp"}: num_cpus = int(cpu_regex(gres).group(1)) shared_node_mem[node] = int((int(totalmem) / 1024) / num_cpus) if gres_regex(gres): diff --git a/infinigen_examples/configs_indoor/base_indoors.gin b/infinigen_examples/configs_indoor/base_indoors.gin index 019c593ed..90fd9ac0c 100644 --- a/infinigen_examples/configs_indoor/base_indoors.gin +++ b/infinigen_examples/configs_indoor/base_indoors.gin @@ -11,6 +11,8 @@ SimulatedAnnealingSolver.final_temp = 0.001 SimulatedAnnealingSolver.finetune_pct = 0.15 SimulatedAnnealingSolver.max_invalid_candidates = 5 +RoomConstants.n_stories = 1 + configure_render_cycles.num_samples = 16000 animate_cameras.follow_poi_chance=0.0 diff --git a/infinigen_examples/configs_indoor/common.gin b/infinigen_examples/configs_indoor/common.gin deleted file mode 100644 index c7e7ede55..000000000 --- a/infinigen_examples/configs_indoor/common.gin +++ /dev/null @@ -1,13 +0,0 @@ -RoomConstants.n_stories = 1 -execute_tasks.generate_resolution = (1024, 1024) -get_sensor_coords.H = 1024 -get_sensor_coords.W = 1024 - -compose_indoors.terrain_enabled=False -compose_indoors.solve_large_enabled=False -compose_indoors.solve_small_enabled=False -compose_indoors.solve_medium_enabled=False - -compose_scene.topview=True -nishita_lighting.strength = 0.02 -configure_render_cycles.num_samples = 256 diff --git a/infinigen_examples/configs_indoor/fast_solve.gin b/infinigen_examples/configs_indoor/fast_solve.gin index d712c7750..4b2c668ed 100644 --- a/infinigen_examples/configs_indoor/fast_solve.gin +++ b/infinigen_examples/configs_indoor/fast_solve.gin @@ -1,6 +1,5 @@ FloorPlanSolver.n_divide_trials = 25 FloorPlanSolver.iters_mult = 25 -RoomConstants.n_stories = 1 GraphMaker.fast=True home_room_constraints.fast = True diff --git a/infinigen_examples/configs_indoor/home.gin b/infinigen_examples/configs_indoor/home.gin deleted file mode 100644 index 344bd3dc2..000000000 --- a/infinigen_examples/configs_indoor/home.gin +++ /dev/null @@ -1 +0,0 @@ -include 'infinigen_examples/configs_indoor/common.gin' diff --git a/infinigen_examples/configs_indoor/office.gin b/infinigen_examples/configs_indoor/office.gin deleted file mode 100644 index 3b6a00a9c..000000000 --- a/infinigen_examples/configs_indoor/office.gin +++ /dev/null @@ -1,6 +0,0 @@ -include 'infinigen_examples/configs_indoor/common.gin' -compose_scene.type = 'office' -compose_scene.topview_rot_x=45 -compose_scene.topview_rot_z=-45 -restrict_solving.restrict_parent_rooms = ('OpenOffice', ) - diff --git a/infinigen_examples/configs_indoor/warehouse.gin b/infinigen_examples/configs_indoor/warehouse.gin deleted file mode 100644 index b9efbafe5..000000000 --- a/infinigen_examples/configs_indoor/warehouse.gin +++ /dev/null @@ -1,4 +0,0 @@ -include 'infinigen_examples/configs_indoor/common.gin' -compose_scene.type = 'warehouse' -RoomConstants.global_params.wall_height = ('uniform', 5.6, 6.4) -restrict_solving.restrict_parent_rooms = ('Warehouse', ) \ No newline at end of file diff --git a/infinigen_examples/generate_individual_assets.py b/infinigen_examples/generate_individual_assets.py index bcc7b810d..d21c7608a 100644 --- a/infinigen_examples/generate_individual_assets.py +++ b/infinigen_examples/generate_individual_assets.py @@ -236,6 +236,25 @@ def build_and_save_asset(payload: dict): output_folder.mkdir(exist_ok=True) + init.apply_gin_configs( + ["infinigen_examples/configs_indoor", "infinigen_examples/configs_nature"], + configs=args.configs, + overrides=args.overrides, + skip_unknown=True, + ) + + if args.debug is not None: + for name in logging.root.manager.loggerDict: + if not name.startswith("infinigen"): + continue + if len(args.debug) == 0 or any(name.endswith(x) for x in args.debug): + logging.getLogger(name).setLevel(logging.DEBUG) + + init.configure_blender() + + if args.gpu: + init.configure_render_cycles() + logger.info(f"Building scene for {factory_name} {idx}") if args.seed > 0: @@ -290,8 +309,9 @@ def build_and_save_asset(payload: dict): ) if args.cam_center > 0 and asset: - co = read_base_co(asset) + asset.location - center.location = (np.amin(co, 0) + np.amax(co, 0)) / 2 + co = read_base_co(asset) + location = (np.amin(co, 0) + np.amax(co, 0)) / 2 + center.location = (np.array(asset.matrix_world) @ np.array([*location, 1]))[:-1] center.location[-1] += args.cam_zoff if args.cam_dist <= 0 and asset: @@ -453,25 +473,6 @@ def mapfunc( def main(args): bpy.context.window.workspace = bpy.data.workspaces["Geometry Nodes"] - init.apply_gin_configs( - ["infinigen_examples/configs_indoor", "infinigen_examples/configs_nature"], - configs=args.configs, - overrides=args.overrides, - skip_unknown=True, - ) - - if args.debug is not None: - for name in logging.root.manager.loggerDict: - if not name.startswith("infinigen"): - continue - if len(args.debug) == 0 or any(name.endswith(x) for x in args.debug): - logging.getLogger(name).setLevel(logging.DEBUG) - - init.configure_blender() - - if args.gpu: - init.configure_render_cycles() - if args.output_folder is None: outputs = Path("outputs") assert outputs.exists(), outputs diff --git a/tests/integration/integration_test_parse_logs.py b/tests/integration/compare.py similarity index 88% rename from tests/integration/integration_test_parse_logs.py rename to tests/integration/compare.py index a3084216d..a2ea0bd42 100644 --- a/tests/integration/integration_test_parse_logs.py +++ b/tests/integration/compare.py @@ -53,15 +53,11 @@ def parse_scene_log( "blendergt": [], } - log_folder = scene_path/"logs" - coarse_folder = scene_path/"coarse" - fine_folder = scene_path/"fine" - - if not ( - log_folder.exists() - and coarse_folder.exists() - and fine_folder.exists() - ): + log_folder = scene_path / "logs" + coarse_folder = scene_path / "coarse" + fine_folder = scene_path / "fine" + + if not (log_folder.exists() and coarse_folder.exists() and fine_folder.exists()): return ret_dict for filepath in log_folder.glob("*.err"): @@ -72,8 +68,8 @@ def parse_scene_log( break else: continue - errFile = open(filepath) - text = errFile.read() + + text = filepath.read_text() if "[MAIN TOTAL] finished in" not in text: continue search = re.search( @@ -133,11 +129,12 @@ def parse_scene_log( "gt_time": gt_time, } - fine_poly = parse_poly_file(fine_folder/"polycounts.txt") + fine_poly = parse_poly_file(fine_folder / "polycounts.txt") ret_dict["gen_triangles"] = fine_poly.get("Triangles", "NAN") return ret_dict + def parse_poly_file(path): res = {} @@ -153,18 +150,20 @@ def parse_poly_file(path): return res -def parse_asset_log(asset_path): - poly = parse_poly_file(asset_path/"polycounts.txt") +def parse_asset_log(asset_path): + poly = parse_poly_file(asset_path / "polycounts.txt") return { "triangles": poly.get("Tris", "NAN"), "gen_mem": poly.get("Memory", "NAN"), } + def format_stats(d): return ", ".join(f"{k}: {v}" for k, v in d.items()) + def parse_run_df(run_path: Path): runs = { "_".join((x.name.split("_")[2:])): x for x in run_path.iterdir() if x.is_dir() @@ -255,16 +254,14 @@ def find_run(base_path: str, run: str) -> Path: def fuzzy_merge(dfA, dfB, keyA, keyB, threshold=1): - from rapidfuzz import fuzz, process matches_A = [] matches_B = [] - def preproc(x): - x = x.split('/')[-1] - x = re.sub(r'(?