Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into dom-widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
pythongosssss committed Nov 20, 2023
2 parents 18b657a + dba4f3b commit c6a7a27
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 8 deletions.
6 changes: 3 additions & 3 deletions comfy/model_sampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ def sigma(self, timestep):

def percent_to_sigma(self, percent):
if percent <= 0.0:
return torch.tensor(999999999.9)
return 999999999.9
if percent >= 1.0:
return torch.tensor(0.0)
return 0.0
percent = 1.0 - percent
return self.sigma(torch.tensor(percent * 999.0))
return self.sigma(torch.tensor(percent * 999.0)).item()

44 changes: 44 additions & 0 deletions comfy_extras/nodes_images.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import nodes
MAX_RESOLUTION = nodes.MAX_RESOLUTION

class ImageCrop:
@classmethod
def INPUT_TYPES(s):
return {"required": { "image": ("IMAGE",),
"width": ("INT", {"default": 512, "min": 1, "max": MAX_RESOLUTION, "step": 1}),
"height": ("INT", {"default": 512, "min": 1, "max": MAX_RESOLUTION, "step": 1}),
"x": ("INT", {"default": 0, "min": 0, "max": MAX_RESOLUTION, "step": 1}),
"y": ("INT", {"default": 0, "min": 0, "max": MAX_RESOLUTION, "step": 1}),
}}
RETURN_TYPES = ("IMAGE",)
FUNCTION = "crop"

CATEGORY = "image/transform"

def crop(self, image, width, height, x, y):
x = min(x, image.shape[2] - 1)
y = min(y, image.shape[1] - 1)
to_x = width + x
to_y = height + y
img = image[:,y:to_y, x:to_x, :]
return (img,)

class RepeatImageBatch:
@classmethod
def INPUT_TYPES(s):
return {"required": { "image": ("IMAGE",),
"amount": ("INT", {"default": 1, "min": 1, "max": 64}),
}}
RETURN_TYPES = ("IMAGE",)
FUNCTION = "repeat"

CATEGORY = "image/batch"

def repeat(self, image, amount):
s = image.repeat((amount, 1,1,1))
return (s,)

NODE_CLASS_MAPPINGS = {
"ImageCrop": ImageCrop,
"RepeatImageBatch": RepeatImageBatch,
}
6 changes: 3 additions & 3 deletions comfy_extras/nodes_model_advanced.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ def sigma(self, timestep):

def percent_to_sigma(self, percent):
if percent <= 0.0:
return torch.tensor(999999999.9)
return 999999999.9
if percent >= 1.0:
return torch.tensor(0.0)
return 0.0
percent = 1.0 - percent
return self.sigma(torch.tensor(percent * 999.0))
return self.sigma(torch.tensor(percent * 999.0)).item()


def rescale_zero_terminal_snr_sigmas(sigmas):
Expand Down
4 changes: 2 additions & 2 deletions comfy_extras/nodes_model_downscale.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ def INPUT_TYPES(s):
CATEGORY = "_for_testing"

def patch(self, model, block_number, downscale_factor, start_percent, end_percent, downscale_after_skip):
sigma_start = model.model.model_sampling.percent_to_sigma(start_percent).item()
sigma_end = model.model.model_sampling.percent_to_sigma(end_percent).item()
sigma_start = model.model.model_sampling.percent_to_sigma(start_percent)
sigma_end = model.model.model_sampling.percent_to_sigma(end_percent)

def input_block_patch(h, transformer_options):
if transformer_options["block"][1] == block_number:
Expand Down
1 change: 1 addition & 0 deletions nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1800,6 +1800,7 @@ def init_custom_nodes():
"nodes_hypertile.py",
"nodes_model_advanced.py",
"nodes_model_downscale.py",
"nodes_images.py",
]

for node_file in extras_files:
Expand Down

0 comments on commit c6a7a27

Please sign in to comment.