kijai / ComfyUI-IC-Light

Using IC-LIght models in ComfyUI
Apache License 2.0
792 stars 38 forks source link

Normal map extraction error #36

Open attashe opened 6 months ago

attashe commented 6 months ago

I caught mismatch dimension error during normal map extraction

            normal = (normal - normal.min()) / ((normal.max() - normal.min()))  # normal = 1, 1, H, W, C
            normal_list.append(normal)
            ...
            divided = torch.max(divided, dim=3, keepdim=True)[0].repeat(1, 1, 1, 3)  # divided= 4, H, W, C
            divided_list.append(divided)

        normal_out = torch.cat(normal_list, dim=0)   # normal_out = 1, 1, H, W, C
        divided_out = torch.cat(divided_list, dim=0)

For able to save and preview results I suggest:

            normal = (normal - normal.min()) / ((normal.max() - normal.min()))
            normal_list.append(normal.squeeze())  # squeeze all extra dimensions
            ...
            divided = torch.max(divided, dim=3, keepdim=True)[0].repeat(1, 1, 1, 3)
            divided_list.append(divided)

        normal_out = torch.stack(normal_list, dim=0)  # replace cat to stack
        divided_out = torch.cat(divided_list, dim=0)

Workflow attached

iclight_normals_example_01

kijai commented 6 months ago

You may have an old version of the ComfyUI-Video-Matting -nodes, there was a bug in the BRIAAI node giving wrong mask shape, which would also add extra dimension to the normal map.