Skip to content

Commit

Permalink
feat: 💄 GEOMETRY is now a dict
Browse files Browse the repository at this point in the history
- For now only "mesh" and "material" keys are interopable from py <-> js
- Small fixes from merge (wip)
  • Loading branch information
melMass committed Dec 25, 2023
1 parent 241c1a5 commit 1921d55
Show file tree
Hide file tree
Showing 6 changed files with 240 additions and 62 deletions.
42 changes: 30 additions & 12 deletions nodes/debug.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import base64
import io
import base64, io
from pathlib import Path
from typing import Optional

import folder_paths
import torch
import folder_paths, torch

from ..log import log
from ..utils import tensor2pil
Expand Down Expand Up @@ -43,18 +41,29 @@ def process_list(anything):
)

elif isinstance(first_element, torch.Tensor):
text.append(f"List of Tensors: {first_element.shape} (x{len(anything)})")
text.append(
f"List of Tensors: {first_element.shape} (x{len(anything)})"
)

return {"text": text}


def process_dict(anything):
text = []
if "mesh" in anything:
m = {"geometry": {}}
m["geometry"]["mesh"] = mesh_to_json(anything["mesh"])
if "material" in anything:
m["geometry"]["material"] = anything["material"]
return m

res = []
if "samples" in anything:
is_empty = "(empty)" if torch.count_nonzero(anything["samples"]) == 0 else ""
text.append(f"Latent Samples: {anything['samples'].shape} {is_empty}")
is_empty = (
"(empty)" if torch.count_nonzero(anything["samples"]) == 0 else ""
)
res.append(f"Latent Samples: {anything['samples'].shape} {is_empty}")

return {"text": text}
return {"text": res}


def process_bool(anything):
Expand All @@ -65,6 +74,7 @@ def process_text(anything):
return {"text": [str(anything)]}


# NOT USED ANYMORE
def process_geometry(anything):
return {"geometry": [mesh_to_json(anything)]}

Expand Down Expand Up @@ -102,8 +112,6 @@ def do_debug(self, output_to_console, **kwargs):
bool: process_bool,
o3d.geometry.Geometry: process_geometry,
}
if output_to_console:
print("bouh!")

for anything in kwargs.values():
processor = processors.get(type(anything))
Expand All @@ -118,11 +126,21 @@ def do_debug(self, output_to_console, **kwargs):
processed_data = processor(anything)

for ui_key, ui_value in processed_data.items():
output["ui"][ui_key].extend(ui_value)
if isinstance(ui_value, list):
output["ui"][ui_key].extend(ui_value)
else:
output["ui"][ui_key].append(ui_value)
# log.debug(
# f"Processed input {k}, found {len(processed_data.get('b64_images', []))} images and {len(processed_data.get('text', []))} text items."
# )

if output_to_console:
from rich.console import Console

cons = Console()
cons.print("OUTPUT:")
cons.print(output)

return output


Expand Down
Loading

0 comments on commit 1921d55

Please sign in to comment.