spacepxl / ComfyUI-HQ-Image-Save

Load/save images and latents as 32bit EXRs
MIT License
36 stars 5 forks source link

Multi-Channel EXR #1

Open Starzilla29 opened 8 months ago

Starzilla29 commented 8 months ago

Something super cool would be to make it so you could load in/save out different channels. I would refer specifically to the depth channel as this could allow for much more accurate controlnet controls with depth, especially if one could load a depth map exported from a 3d software.

bhowiebkr commented 8 months ago

This would be a very good thing to add. Currently depth has been the most difficult channel to get into ComfyUI. I'm not sure how depth controlnets will handle it but if it becomes an issue, a grade node to set the black and white points could probably be made till a better depth controlnet model is trained to handle it.

spacepxl commented 8 months ago

~If anyone wants to contribute, that would be welcome. I didn't intend to develop this much further, it was mainly just a proof of concept for some colleagues that I shared here in case anyone else found it interesting.~

spacepxl commented 7 months ago

I added Load EXR and reworked Save EXR to be (hopefully) much more robust and useful. No support for multi-layer beyond RGBA, because OpenCV's EXR support is extremely limited, but this should make it easier to load and save batches as long as you're ok with separate sequences for normals/depth/etc. Updating the TIFF and latent nodes is still on the todo list.

Side note: OpenCV only supports 1, 3, or 4 channels for EXR, and only with float32 and 16-line zip compression. Their documentation has flags for half float and different compression options, but as far as I can tell, they're just ignored completely. There is a python package with bindings for OpenEXR, but that would require installing OpenEXR on the system, which can't be handled through pip AFAIK, which is why I avoided it. Not like anyone is going to be running full CG multipass workflows through this, right?

bhowiebkr commented 7 months ago

Honestly it would be a good thing to get multichannel exr fully functional but I totally understand the limits of what you can do depending on OpenCV to do it. I’m thinking that once the whole echo system of comfyui solves more of the issues of generating image sequences/video with temporal stability of an arbitrary camera movement, It’ll gain much more popularity as a VFX tool and multichannel exr is the norm.

I haven’t checked what other alternatives there are on pip for working with opencv. There might not be an easy drop-in solution right now for working with them.

I tried compiling OpenEXR 10 or so years ago and that was hell. Doubtful it got any easier.