mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-06-09 04:52:07 +08:00
Node to add pixel space noise to an image. (#8182)
This commit is contained in:
parent
05eb10b43a
commit
62690eddec
@ -13,6 +13,7 @@ import os
|
|||||||
import re
|
import re
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from inspect import cleandoc
|
from inspect import cleandoc
|
||||||
|
import torch
|
||||||
|
|
||||||
from comfy.comfy_types import FileLocator
|
from comfy.comfy_types import FileLocator
|
||||||
|
|
||||||
@ -74,6 +75,24 @@ class ImageFromBatch:
|
|||||||
s = s_in[batch_index:batch_index + length].clone()
|
s = s_in[batch_index:batch_index + length].clone()
|
||||||
return (s,)
|
return (s,)
|
||||||
|
|
||||||
|
|
||||||
|
class ImageAddNoise:
|
||||||
|
@classmethod
|
||||||
|
def INPUT_TYPES(s):
|
||||||
|
return {"required": { "image": ("IMAGE",),
|
||||||
|
"seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff, "control_after_generate": True, "tooltip": "The random seed used for creating the noise."}),
|
||||||
|
"strength": ("FLOAT", {"default": 0.5, "min": 0.0, "max": 1.0, "step": 0.01}),
|
||||||
|
}}
|
||||||
|
RETURN_TYPES = ("IMAGE",)
|
||||||
|
FUNCTION = "repeat"
|
||||||
|
|
||||||
|
CATEGORY = "image"
|
||||||
|
|
||||||
|
def repeat(self, image, seed, strength):
|
||||||
|
generator = torch.manual_seed(seed)
|
||||||
|
s = torch.clip((image + strength * torch.randn(image.size(), generator=generator, device="cpu").to(image)), min=0.0, max=1.0)
|
||||||
|
return (s,)
|
||||||
|
|
||||||
class SaveAnimatedWEBP:
|
class SaveAnimatedWEBP:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.output_dir = folder_paths.get_output_directory()
|
self.output_dir = folder_paths.get_output_directory()
|
||||||
@ -295,6 +314,7 @@ NODE_CLASS_MAPPINGS = {
|
|||||||
"ImageCrop": ImageCrop,
|
"ImageCrop": ImageCrop,
|
||||||
"RepeatImageBatch": RepeatImageBatch,
|
"RepeatImageBatch": RepeatImageBatch,
|
||||||
"ImageFromBatch": ImageFromBatch,
|
"ImageFromBatch": ImageFromBatch,
|
||||||
|
"ImageAddNoise": ImageAddNoise,
|
||||||
"SaveAnimatedWEBP": SaveAnimatedWEBP,
|
"SaveAnimatedWEBP": SaveAnimatedWEBP,
|
||||||
"SaveAnimatedPNG": SaveAnimatedPNG,
|
"SaveAnimatedPNG": SaveAnimatedPNG,
|
||||||
"SaveSVGNode": SaveSVGNode,
|
"SaveSVGNode": SaveSVGNode,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user