mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-03-13 21:27:41 +08:00
Update Radiance nodes to ensure latents/images are on the intermediate device
This commit is contained in:
parent
d15a96e146
commit
1b0b2b728f
@ -24,6 +24,9 @@ class EmptyChromaRadianceLatentImage:
|
|||||||
|
|
||||||
|
|
||||||
class ChromaRadianceLatentToImage:
|
class ChromaRadianceLatentToImage:
|
||||||
|
def __init__(self):
|
||||||
|
self.device = comfy.model_management.intermediate_device()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def INPUT_TYPES(s):
|
def INPUT_TYPES(s):
|
||||||
return {"required": {"latent": ("LATENT",)}}
|
return {"required": {"latent": ("LATENT",)}}
|
||||||
@ -33,13 +36,17 @@ class ChromaRadianceLatentToImage:
|
|||||||
|
|
||||||
CATEGORY = "latent/chroma_radiance"
|
CATEGORY = "latent/chroma_radiance"
|
||||||
|
|
||||||
@classmethod
|
def go(self, *, latent):
|
||||||
def go(cls, *, latent):
|
img = latent["samples"].to(device=self.device, dtype=torch.float32, copy=True)
|
||||||
img = latent["samples"].movedim(1, -1).clamp(-1, 1).contiguous()
|
img = img.clamp_(-1, 1).movedim(1, -1).contiguous()
|
||||||
img = (img + 1.0) * 0.5
|
img += 1.0
|
||||||
return (img,)
|
img *= 0.5
|
||||||
|
return (img.clamp_(0, 1),)
|
||||||
|
|
||||||
class ChromaRadianceImageToLatent:
|
class ChromaRadianceImageToLatent:
|
||||||
|
def __init__(self):
|
||||||
|
self.device = comfy.model_management.intermediate_device()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def INPUT_TYPES(s):
|
def INPUT_TYPES(s):
|
||||||
return {"required": {"image": ("IMAGE",)}}
|
return {"required": {"image": ("IMAGE",)}}
|
||||||
@ -49,11 +56,12 @@ class ChromaRadianceImageToLatent:
|
|||||||
|
|
||||||
CATEGORY = "latent/chroma_radiance"
|
CATEGORY = "latent/chroma_radiance"
|
||||||
|
|
||||||
@classmethod
|
def go(self, *, image):
|
||||||
def go(cls, *, image):
|
latent = image.to(device=self.device, dtype=torch.float32, copy=True)
|
||||||
image = (image.clone().clamp(0, 1) - 0.5) * 2
|
latent = latent.clamp_(0, 1).movedim(-1, 1).contiguous()
|
||||||
image = image.movedim(-1, 1).contiguous()
|
latent -= 0.5
|
||||||
return ({"samples": image},)
|
latent *= 2
|
||||||
|
return ({"samples": latent.clamp_(-1, 1)},)
|
||||||
|
|
||||||
NODE_CLASS_MAPPINGS = {
|
NODE_CLASS_MAPPINGS = {
|
||||||
"EmptyChromaRadianceLatentImage": EmptyChromaRadianceLatentImage,
|
"EmptyChromaRadianceLatentImage": EmptyChromaRadianceLatentImage,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user