mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-01-11 02:15:17 +00:00
Merge branch 'master' into hooks_part2
This commit is contained in:
commit
bf21be066f
@ -10,4 +10,4 @@ class FileService:
|
|||||||
if directory_key not in self.allowed_directories:
|
if directory_key not in self.allowed_directories:
|
||||||
raise ValueError("Invalid directory key")
|
raise ValueError("Invalid directory key")
|
||||||
directory_path: str = self.allowed_directories[directory_key]
|
directory_path: str = self.allowed_directories[directory_key]
|
||||||
return self.file_system_ops.walk_directory(directory_path)
|
return self.file_system_ops.walk_directory(directory_path)
|
||||||
|
@ -39,4 +39,4 @@ class FileSystemOperations:
|
|||||||
"path": relative_path,
|
"path": relative_path,
|
||||||
"type": "directory"
|
"type": "directory"
|
||||||
})
|
})
|
||||||
return file_list
|
return file_list
|
||||||
|
@ -51,4 +51,4 @@ class AppSettings():
|
|||||||
settings = self.get_settings(request)
|
settings = self.get_settings(request)
|
||||||
settings[setting_id] = await request.json()
|
settings[setting_id] = await request.json()
|
||||||
self.save_settings(request, settings)
|
self.save_settings(request, settings)
|
||||||
return web.Response(status=200)
|
return web.Response(status=200)
|
||||||
|
@ -194,4 +194,4 @@ class AdamWwithEMAandWings(optim.Optimizer):
|
|||||||
for param, ema_param in zip(params_with_grad, ema_params_with_grad):
|
for param, ema_param in zip(params_with_grad, ema_params_with_grad):
|
||||||
ema_param.mul_(cur_ema_decay).add_(param.float(), alpha=1 - cur_ema_decay)
|
ema_param.mul_(cur_ema_decay).add_(param.float(), alpha=1 - cur_ema_decay)
|
||||||
|
|
||||||
return loss
|
return loss
|
||||||
|
@ -467,6 +467,13 @@ def linear_quadratic_schedule(model_sampling, steps, threshold_noise=0.025, line
|
|||||||
sigma_schedule = [1.0 - x for x in sigma_schedule]
|
sigma_schedule = [1.0 - x for x in sigma_schedule]
|
||||||
return torch.FloatTensor(sigma_schedule) * model_sampling.sigma_max.cpu()
|
return torch.FloatTensor(sigma_schedule) * model_sampling.sigma_max.cpu()
|
||||||
|
|
||||||
|
# Referenced from https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/15608
|
||||||
|
def kl_optimal_scheduler(n: int, sigma_min: float, sigma_max: float) -> torch.Tensor:
|
||||||
|
adj_idxs = torch.arange(n, dtype=torch.float).div_(n - 1)
|
||||||
|
sigmas = adj_idxs.new_zeros(n + 1)
|
||||||
|
sigmas[:-1] = (adj_idxs * math.atan(sigma_min) + (1 - adj_idxs) * math.atan(sigma_max)).tan_()
|
||||||
|
return sigmas
|
||||||
|
|
||||||
def get_mask_aabb(masks):
|
def get_mask_aabb(masks):
|
||||||
if masks.numel() == 0:
|
if masks.numel() == 0:
|
||||||
return torch.zeros((0, 4), device=masks.device, dtype=torch.int)
|
return torch.zeros((0, 4), device=masks.device, dtype=torch.int)
|
||||||
@ -913,7 +920,7 @@ def sample(model, noise, positive, negative, cfg, device, sampler, sigmas, model
|
|||||||
return cfg_guider.sample(noise, latent_image, sampler, sigmas, denoise_mask, callback, disable_pbar, seed)
|
return cfg_guider.sample(noise, latent_image, sampler, sigmas, denoise_mask, callback, disable_pbar, seed)
|
||||||
|
|
||||||
|
|
||||||
SCHEDULER_NAMES = ["normal", "karras", "exponential", "sgm_uniform", "simple", "ddim_uniform", "beta", "linear_quadratic"]
|
SCHEDULER_NAMES = ["normal", "karras", "exponential", "sgm_uniform", "simple", "ddim_uniform", "beta", "linear_quadratic", "kl_optimal"]
|
||||||
SAMPLER_NAMES = KSAMPLER_NAMES + ["ddim", "uni_pc", "uni_pc_bh2"]
|
SAMPLER_NAMES = KSAMPLER_NAMES + ["ddim", "uni_pc", "uni_pc_bh2"]
|
||||||
|
|
||||||
def calculate_sigmas(model_sampling, scheduler_name, steps):
|
def calculate_sigmas(model_sampling, scheduler_name, steps):
|
||||||
@ -933,6 +940,8 @@ def calculate_sigmas(model_sampling, scheduler_name, steps):
|
|||||||
sigmas = beta_scheduler(model_sampling, steps)
|
sigmas = beta_scheduler(model_sampling, steps)
|
||||||
elif scheduler_name == "linear_quadratic":
|
elif scheduler_name == "linear_quadratic":
|
||||||
sigmas = linear_quadratic_schedule(model_sampling, steps)
|
sigmas = linear_quadratic_schedule(model_sampling, steps)
|
||||||
|
elif scheduler_name == "kl_optimal":
|
||||||
|
sigmas = kl_optimal_scheduler(n=steps, sigma_min=float(model_sampling.sigma_min), sigma_max=float(model_sampling.sigma_max))
|
||||||
else:
|
else:
|
||||||
logging.error("error invalid scheduler {}".format(scheduler_name))
|
logging.error("error invalid scheduler {}".format(scheduler_name))
|
||||||
return sigmas
|
return sigmas
|
||||||
|
@ -54,8 +54,8 @@ class DynamicPrompt:
|
|||||||
def get_original_prompt(self):
|
def get_original_prompt(self):
|
||||||
return self.original_prompt
|
return self.original_prompt
|
||||||
|
|
||||||
def get_input_info(class_def, input_name):
|
def get_input_info(class_def, input_name, valid_inputs=None):
|
||||||
valid_inputs = class_def.INPUT_TYPES()
|
valid_inputs = valid_inputs or class_def.INPUT_TYPES()
|
||||||
input_info = None
|
input_info = None
|
||||||
input_category = None
|
input_category = None
|
||||||
if "required" in valid_inputs and input_name in valid_inputs["required"]:
|
if "required" in valid_inputs and input_name in valid_inputs["required"]:
|
||||||
|
@ -121,4 +121,4 @@ NODE_DISPLAY_NAME_MAPPINGS = {
|
|||||||
"Load3D": "Load 3D",
|
"Load3D": "Load 3D",
|
||||||
"Load3DAnimation": "Load 3D - Animation",
|
"Load3DAnimation": "Load 3D - Animation",
|
||||||
"Preview3D": "Preview 3D"
|
"Preview3D": "Preview 3D"
|
||||||
}
|
}
|
||||||
|
@ -46,4 +46,4 @@ NODE_CLASS_MAPPINGS = {
|
|||||||
|
|
||||||
NODE_DISPLAY_NAME_MAPPINGS = {
|
NODE_DISPLAY_NAME_MAPPINGS = {
|
||||||
"Morphology": "ImageMorphology",
|
"Morphology": "ImageMorphology",
|
||||||
}
|
}
|
||||||
|
@ -30,4 +30,4 @@ NODE_CLASS_MAPPINGS = {
|
|||||||
|
|
||||||
NODE_DISPLAY_NAME_MAPPINGS = {
|
NODE_DISPLAY_NAME_MAPPINGS = {
|
||||||
"WebcamCapture": "Webcam Capture",
|
"WebcamCapture": "Webcam Capture",
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ def get_input_data(inputs, class_def, unique_id, outputs=None, dynprompt=None, e
|
|||||||
missing_keys = {}
|
missing_keys = {}
|
||||||
for x in inputs:
|
for x in inputs:
|
||||||
input_data = inputs[x]
|
input_data = inputs[x]
|
||||||
input_type, input_category, input_info = get_input_info(class_def, x)
|
input_type, input_category, input_info = get_input_info(class_def, x, valid_inputs)
|
||||||
def mark_missing():
|
def mark_missing():
|
||||||
missing_keys[x] = True
|
missing_keys[x] = True
|
||||||
input_data_all[x] = (None,)
|
input_data_all[x] = (None,)
|
||||||
@ -555,7 +555,7 @@ def validate_inputs(prompt, item, validated):
|
|||||||
received_types = {}
|
received_types = {}
|
||||||
|
|
||||||
for x in valid_inputs:
|
for x in valid_inputs:
|
||||||
type_input, input_category, extra_info = get_input_info(obj_class, x)
|
type_input, input_category, extra_info = get_input_info(obj_class, x, class_inputs)
|
||||||
assert extra_info is not None
|
assert extra_info is not None
|
||||||
if x not in inputs:
|
if x not in inputs:
|
||||||
if input_category == "required":
|
if input_category == "required":
|
||||||
|
@ -5,6 +5,7 @@ lint.ignore = ["ALL"]
|
|||||||
lint.select = [
|
lint.select = [
|
||||||
"S307", # suspicious-eval-usage
|
"S307", # suspicious-eval-usage
|
||||||
"T201", # print-usage
|
"T201", # print-usage
|
||||||
|
"W292",
|
||||||
"W293",
|
"W293",
|
||||||
# The "F" series in Ruff stands for "Pyflakes" rules, which catch various Python syntax errors and undefined names.
|
# The "F" series in Ruff stands for "Pyflakes" rules, which catch various Python syntax errors and undefined names.
|
||||||
# See all rules here: https://docs.astral.sh/ruff/rules/#pyflakes-f
|
# See all rules here: https://docs.astral.sh/ruff/rules/#pyflakes-f
|
||||||
|
@ -95,4 +95,4 @@ def test_get_save_image_path(temp_dir):
|
|||||||
assert filename == "test"
|
assert filename == "test"
|
||||||
assert counter == 1
|
assert counter == 1
|
||||||
assert subfolder == ""
|
assert subfolder == ""
|
||||||
assert filename_prefix == "test"
|
assert filename_prefix == "test"
|
||||||
|
@ -49,4 +49,4 @@ def test_handles_no_extension():
|
|||||||
|
|
||||||
def test_handles_no_files():
|
def test_handles_no_files():
|
||||||
files = []
|
files = []
|
||||||
assert filter_files_content_types(files, ["image", "audio", "video"]) == []
|
assert filter_files_content_types(files, ["image", "audio", "video"]) == []
|
||||||
|
Loading…
Reference in New Issue
Block a user