Skip to content
Open
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
236 changes: 235 additions & 1 deletion presets.json
Comment thread
Florian-Barthel marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -1 +1,235 @@
{"Default": {"edit_text": "gs._xyz = gs._xyz\ngs._rotation = gs._rotation\ngs._scaling = gs._scaling\ngs._opacity = gs._opacity\ngs._features_dc = gs._features_dc\ngs._features_rest = gs._features_rest\n", "slider": [{"key": "x", "value": 1, "min_value": 0, "max_value": 10, "_id": "a8f2a853-17ba-4f7f-9dd8-843d2f0756a1"}]}, "Point Cloud": {"edit_text": "gs._scaling = gs._scaling * 0 - slider.scaling\ngs._opacity = gs._opacity * 0 + 10\n", "slider": [{"key": "scaling", "value": 8.0, "min_value": 1, "max_value": 10, "_id": "6dd9eb75-6bce-445b-9165-dc8dd498d253"}]}, "Only SH": {"edit_text": "gs._features_dc = gs._features_dc * slider.dc_scale\ngs._features_rest = gs._features_rest * slider.sh_scale\n", "slider": [{"key": "dc_scale", "value": 0.0, "min_value": -3, "max_value": 3, "_id": "3c0f6f8c-516b-4303-957e-65a3bebbd8bd"}, {"key": "sh_scale", "value": 1.0, "min_value": -3, "max_value": 3, "_id": "4ae54ccd-b28c-49d9-a514-fd7d6fdfb831"}]}, "Filter Opacity": {"edit_text": "mask = torch.linalg.norm(gs._opacity, dim=-1) < slider.opacity\n\ngs._xyz = gs._xyz[mask]\ngs._rotation = gs._rotation[mask]\ngs._scaling = gs._scaling[mask]\ngs._opacity = gs._opacity[mask]\ngs._features_dc = gs._features_dc[mask]\ngs._features_rest = gs._features_rest[mask]\n", "slider": [{"key": "opacity", "value": 10.0, "min_value": 0, "max_value": 20, "_id": "12364012634"}]}, "Highlight Large gs": {"edit_text": "mask = torch.linalg.norm(gs._scaling, dim=-1) < slider.scaling\n\ncolor = [slider.r, slider.g ,slider.b]\ngs._features_dc[mask] = gs._features_dc[mask] * 0 + torch.tensor(color, device=\"cuda\")\n\n", "slider": [{"key": "scaling", "value": 5.0, "min_value": -10, "max_value": 10, "_id": "bcb1fb24-fae7-4bde-b9f1-3368a3ccf6bd"}, {"key": "r", "value": 1.0, "min_value": -1, "max_value": 1, "_id": "610356120935721"}, {"key": "g", "value": 0.0, "min_value": -1, "max_value": 1, "_id": "19161646843249846"}, {"key": "b", "value": 0.0, "min_value": -1, "max_value": 1, "_id": "12+92+17+174+9174+5"}]}, "Sin(xyz)": {"edit_text": "gs._xyz = torch.sin(gs._xyz/3+slider.x) + gs._xyz\n", "slider": [{"key": "x", "value": 0.0, "min_value": -10, "max_value": 10, "_id": "28971294217951247"}]}, "Random Colors": {"edit_text": "torch.manual_seed(0)\ngs._features_dc = torch.rand_like(gs._features_dc) * slider.intensity - slider.intensity / 2\ngs._features_rest = gs._features_rest * 0\n\n", "slider": [{"key": "intensity", "value": 5.0, "min_value": 0, "max_value": 10, "_id": "9f3fd0c1-67a5-4b38-9ec4-36d27aceddda"}]}, "Recoloring": {"edit_text": "selected_color = torch.tensor([slider.r, slider.g, slider.b], device=\"cuda\")\n\ngs._xyz = gs._xyz\ngs._rotation = gs._rotation\ngs._scaling = gs._scaling\ngs._opacity = gs._opacity\ngs._features_dc = gs._features_dc + selected_color\ngs._features_rest = gs._features_rest\n", "slider": [{"key": "r", "value": 0.0, "min_value": -10, "max_value": 10, "_id": "9419751979747546"}, {"key": "g", "value": 0.0, "min_value": -10, "max_value": 10, "_id": "52795+7+5+4959597"}, {"key": "b", "value": 0.0, "min_value": -10, "max_value": 10, "_id": "47954795627648945"}]}, "Filter Small gs": {"edit_text": "mask = torch.linalg.norm(gs._scaling, dim=-1) < slider.scaling\n\ngs._xyz = gs._xyz[mask]\ngs._rotation = gs._rotation[mask]\ngs._scaling = gs._scaling[mask]\ngs._opacity = gs._opacity[mask]\ngs._features_dc = gs._features_dc[mask]\ngs._features_rest = gs._features_rest[mask]\n", "slider": [{"key": "scaling", "value": 10.0, "min_value": 0, "max_value": 20, "_id": "8769fe63-c073-4b0f-b83d-dc519024a0bb"}]}, "Wobbel": {"edit_text": "gs._xyz[:,2] = torch.sin(gs._xyz[:,2]+slider.x)/5 + gs._xyz[:,2]\ngs._xyz[:,0] = torch.sin(gs._xyz[:,0]+slider.x)/5 + gs._xyz[:,0]", "slider": [{"key": "x", "value": -10.0, "min_value": -10.0, "max_value": 10.0, "_id": "28971294217951247"}]}, "Slice Scene": {"edit_text": "mask_x = gs._xyz[:, 0] < slider.x\nmask_y =gs._xyz[:, 1] < slider.y\nmask_z =gs._xyz[:, 2] < slider.z\n\nmask = mask_x & mask_y & mask_z\n\ngs._xyz = gs._xyz[mask]\ngs._rotation = gs._rotation[mask]\ngs._scaling = gs._scaling[mask]\ngs._opacity = gs._opacity[mask]\ngs._features_dc = gs._features_dc[mask]\ngs._features_rest = gs._features_rest[mask]\n", "slider": [{"key": "x", "value": -0.0010000000474974513, "min_value": -5.0, "max_value": 5.0, "_id": "12364012634"}, {"key": "y", "value": 0.0, "min_value": -5.0, "max_value": 5.0, "_id": "197e4266-82ba-417d-b276-536e465f4fc0"}, {"key": "z", "value": -0.0, "min_value": -5.0, "max_value": 5.0, "_id": "636299d8-5d63-4e7c-8ce4-d192aa019d95"}]}}
{
"Default": {
"edit_text": "gs._xyz = gs._xyz\ngs._rotation = gs._rotation\ngs._scaling = gs._scaling\ngs._opacity = gs._opacity\ngs._features_dc = gs._features_dc\ngs._features_rest = gs._features_rest\n",
"slider": [
{
"key": "x",
"value": 1,
"min_value": 0,
"max_value": 10,
"_id": "a8f2a853-17ba-4f7f-9dd8-843d2f0756a1"
}
]
},
"Point Cloud": {
"edit_text": "gs._scaling = gs._scaling * 0 - slider.scaling\ngs._opacity = gs._opacity * 0 + 10\n",
"slider": [
{
"key": "scaling",
"value": 8.0,
"min_value": 1,
"max_value": 10,
"_id": "6dd9eb75-6bce-445b-9165-dc8dd498d253"
}
]
},
"Only SH": {
"edit_text": "gs._features_dc = gs._features_dc * slider.dc_scale\ngs._features_rest = gs._features_rest * slider.sh_scale\n",
"slider": [
{
"key": "dc_scale",
"value": 0.0,
"min_value": -3,
"max_value": 3,
"_id": "3c0f6f8c-516b-4303-957e-65a3bebbd8bd"
},
{
"key": "sh_scale",
"value": 1.0,
"min_value": -3,
"max_value": 3,
"_id": "4ae54ccd-b28c-49d9-a514-fd7d6fdfb831"
}
]
},
"Filter Opacity": {
"edit_text": "mask = torch.linalg.norm(gs._opacity, dim=-1) < slider.opacity\n\ngs._xyz = gs._xyz[mask]\ngs._rotation = gs._rotation[mask]\ngs._scaling = gs._scaling[mask]\ngs._opacity = gs._opacity[mask]\ngs._features_dc = gs._features_dc[mask]\ngs._features_rest = gs._features_rest[mask]\n",
"slider": [
{
"key": "opacity",
"value": 10.0,
"min_value": 0,
"max_value": 20,
"_id": "12364012634"
}
]
},
"Highlight Large gs": {
"edit_text": "mask = torch.linalg.norm(gs._scaling, dim=-1) < slider.scaling\n\ncolor = [slider.r, slider.g ,slider.b]\ngs._features_dc[mask] = gs._features_dc[mask] * 0 + torch.tensor(color, device=\"cuda\")\n\n",
"slider": [
{
"key": "scaling",
"value": 5.0,
"min_value": -10,
"max_value": 10,
"_id": "bcb1fb24-fae7-4bde-b9f1-3368a3ccf6bd"
},
{
"key": "r",
"value": 1.0,
"min_value": -1,
"max_value": 1,
"_id": "610356120935721"
},
{
"key": "g",
"value": 0.0,
"min_value": -1,
"max_value": 1,
"_id": "19161646843249846"
},
{
"key": "b",
"value": 0.0,
"min_value": -1,
"max_value": 1,
"_id": "12+92+17+174+9174+5"
}
]
},
"Sin(xyz)": {
"edit_text": "gs._xyz = torch.sin(gs._xyz/3+slider.x) + gs._xyz\n",
"slider": [
{
"key": "x",
"value": 0.0,
"min_value": -10,
"max_value": 10,
"_id": "28971294217951247"
}
]
},
"Random Colors": {
"edit_text": "torch.manual_seed(0)\ngs._features_dc = torch.rand_like(gs._features_dc) * slider.intensity - slider.intensity / 2\ngs._features_rest = gs._features_rest * 0\n\n",
"slider": [
{
"key": "intensity",
"value": 5.0,
"min_value": 0,
"max_value": 10,
"_id": "9f3fd0c1-67a5-4b38-9ec4-36d27aceddda"
}
]
},
"Recoloring": {
"edit_text": "selected_color = torch.tensor([slider.r, slider.g, slider.b], device=\"cuda\")\n\ngs._xyz = gs._xyz\ngs._rotation = gs._rotation\ngs._scaling = gs._scaling\ngs._opacity = gs._opacity\ngs._features_dc = gs._features_dc + selected_color\ngs._features_rest = gs._features_rest\n",
"slider": [
{
"key": "r",
"value": 0.0,
"min_value": -10,
"max_value": 10,
"_id": "9419751979747546"
},
{
"key": "g",
"value": 0.0,
"min_value": -10,
"max_value": 10,
"_id": "52795+7+5+4959597"
},
{
"key": "b",
"value": 0.0,
"min_value": -10,
"max_value": 10,
"_id": "47954795627648945"
}
]
},
"Filter Small gs": {
"edit_text": "mask = torch.linalg.norm(gs._scaling, dim=-1) < slider.scaling\n\ngs._xyz = gs._xyz[mask]\ngs._rotation = gs._rotation[mask]\ngs._scaling = gs._scaling[mask]\ngs._opacity = gs._opacity[mask]\ngs._features_dc = gs._features_dc[mask]\ngs._features_rest = gs._features_rest[mask]\n",
"slider": [
{
"key": "scaling",
"value": 10.0,
"min_value": 0,
"max_value": 20,
"_id": "8769fe63-c073-4b0f-b83d-dc519024a0bb"
}
]
},
"Wobbel": {
"edit_text": "gs._xyz[:,2] = torch.sin(gs._xyz[:,2]+slider.x)/5 + gs._xyz[:,2]\ngs._xyz[:,0] = torch.sin(gs._xyz[:,0]+slider.x)/5 + gs._xyz[:,0]",
"slider": [
{
"key": "x",
"value": -10.0,
"min_value": -10.0,
"max_value": 10.0,
"_id": "28971294217951247"
}
]
},
"Slice Scene": {
"edit_text": "mask_x = gs._xyz[:, 0] < slider.x\nmask_y =gs._xyz[:, 1] < slider.y\nmask_z =gs._xyz[:, 2] < slider.z\n\nmask = mask_x & mask_y & mask_z\n\ngs._xyz = gs._xyz[mask]\ngs._rotation = gs._rotation[mask]\ngs._scaling = gs._scaling[mask]\ngs._opacity = gs._opacity[mask]\ngs._features_dc = gs._features_dc[mask]\ngs._features_rest = gs._features_rest[mask]\n",
"slider": [
{
"key": "x",
"value": -0.0010000000474974513,
"min_value": -5.0,
"max_value": 5.0,
"_id": "12364012634"
},
{
"key": "y",
"value": 0.0,
"min_value": -5.0,
"max_value": 5.0,
"_id": "197e4266-82ba-417d-b276-536e465f4fc0"
},
{
"key": "z",
"value": -0.0,
"min_value": -5.0,
"max_value": 5.0,
"_id": "636299d8-5d63-4e7c-8ce4-d192aa019d95"
}
]
},
"Deconstructing Self-Organizing Gaussians": {
"edit_text": "num_gaussians = gs._xyz.shape[0]\ngrid_sidelen = int(np.sqrt(num_gaussians))\ngrid_ids = torch.arange(num_gaussians, device=gs._xyz.device)\n\ngrid_us = (grid_ids % grid_sidelen) / grid_sidelen - 0.5\ngrid_vs = grid_ids // grid_sidelen / grid_sidelen - 0.5\n\ngrid_xyz = torch.zeros((num_gaussians, 3), device=gs._xyz.device)\n\ngrid_xyz[:, 1] = grid_us * slider.size\ngrid_xyz[:, 2] = grid_vs.flip(dims=(0,)) * slider.size\n\ngs.grid_ids = grid_ids\ngs._xyz = (1.0 - slider.phase) * gs._xyz + slider.phase * grid_xyz\ngs._rotation = gs._rotation\ngs._scaling = (1.0 - slider.phase) * gs._scaling + slider.phase * slider.grid_scale\ngs._opacity = (1.0 - slider.phase) * gs._opacity + slider.phase * slider.grid_opacity\ngs._features_dc = gs._features_dc\ngs._features_rest = gs._features_rest\n",
"slider": [
{
"key": "phase",
"value": 1.0,
"min_value": 0.0,
"max_value": 1.0,
"animating": false,
"loop_animation": true,
"animation_duration_sec": 5,
"_id": "a8f2a853-17ba-4f7f-9dd8-843d2f0756a1"
},
{
"key": "size",
"value": 1.5,
"min_value": 0.5,
"max_value": 4.0,
"animating": false,
"loop_animation": true,
"animation_duration_sec": 5,
"_id": "f6d7db6e-d8a2-4513-9317-e73f7fe3328b"
},
{
"key": "grid_scale",
"value": -8.0,
"min_value": -8.0,
"max_value": -4.0,
"animating": false,
"loop_animation": true,
"animation_duration_sec": 5,
"_id": "38cc51e9-7018-45a6-968e-075ae68f9bfe"
},
{
"key": "grid_opacity",
"value": 0,
"min_value": -4.0,
"max_value": 1.0,
"animating": false,
"loop_animation": true,
"animation_duration_sec": 5,
"_id": "7c80d17e-c081-4743-90b6-3058afbba4b7"
}
]
}
}
42 changes: 40 additions & 2 deletions widgets/edit_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from renderer.gaussian_renderer import GaussianRenderer
from scene.gaussian_model import GaussianModel
from widgets.widget import Widget
import math

default_preset = """gaussian._xyz = gaussian._xyz
gaussian._rotation = gaussian._rotation
Expand All @@ -34,13 +35,18 @@ def get_description(obj):


class Slider(object):
def __init__(self, key, value, min_value, max_value, _id=None):
def __init__(self, key, value, min_value, max_value, animating=False, loop_animation=True, animation_duration_sec=5,_id=None):
if _id is None:
_id = str(uuid.uuid4())
self.key = key
self.value = value
self.min_value = min_value
self.max_value = max_value

self.animating = animating
self.loop_animation = loop_animation
self.animation_duration_sec = animation_duration_sec

self._id = _id

def render(self, viz):
Expand All @@ -52,15 +58,47 @@ def render(self, viz):
)
with imgui_utils.item_width(viz.font_size * 4):
imgui.same_line()
min_changed, self.min_value = imgui.input_float(f"##min-{self._id}", self.min_value, )
min_changed, self.min_value = imgui.input_float(f"##min-{self._id}", self.min_value)
imgui.same_line()
max_changed, self.max_value = imgui.input_float(f"##max-{self._id}", self.max_value)
imgui.same_line()
text_changed, self.key = imgui.input_text(f"##text-{self._id}", self.key)
imgui.same_line()
_, self.loop_animation = imgui.checkbox(f"Loop##{self._id}", self.loop_animation)
imgui.same_line()
if self.animating:
stop_animation = imgui_utils.button(f"Stop##{self._id}")
if stop_animation:
self.animating = False
else:
if imgui_utils.button(f"Animate##{self._id}"):

self._animation_start_time = time.time()

# start animation from currently selected value (don't jump to min value)
self._phase_offset = math.asin(2 * (self.value - self.min_value) / (self.max_value - self.min_value) - 1)

self.animating = True

if self.animating:
self.animate()

if min_changed or max_changed:
self.value = min(self.value, self.max_value)
self.value = max(self.value, self.min_value)

def animate(self):
elapsed_time = time.time() - self._animation_start_time
phase = (elapsed_time / self.animation_duration_sec) * (2 * math.pi)
if phase > 2 * math.pi and not self.loop_animation:
self.animating = False

phase += self._phase_offset

# Compute the next value using a sine wave for easing
self.value = self.min_value + (self.max_value - self.min_value) * (0.5 * (1 + math.sin(phase)))



class EditWidget(Widget):
def __init__(self, viz):
Expand Down