mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-11-23 01:57:00 +08:00
Merge branch 'comfyanonymous:master' into tgate-hook
This commit is contained in:
commit
0b56c97717
10
comfy/sd.py
10
comfy/sd.py
@ -214,12 +214,18 @@ class VAE:
|
|||||||
#default SD1.x/SD2.x VAE parameters
|
#default SD1.x/SD2.x VAE parameters
|
||||||
ddconfig = {'double_z': True, 'z_channels': 4, 'resolution': 256, 'in_channels': 3, 'out_ch': 3, 'ch': 128, 'ch_mult': [1, 2, 4, 4], 'num_res_blocks': 2, 'attn_resolutions': [], 'dropout': 0.0}
|
ddconfig = {'double_z': True, 'z_channels': 4, 'resolution': 256, 'in_channels': 3, 'out_ch': 3, 'ch': 128, 'ch_mult': [1, 2, 4, 4], 'num_res_blocks': 2, 'attn_resolutions': [], 'dropout': 0.0}
|
||||||
|
|
||||||
if 'encoder.down.2.downsample.conv.weight' not in sd: #Stable diffusion x4 upscaler VAE
|
if 'encoder.down.2.downsample.conv.weight' not in sd and 'decoder.up.3.upsample.conv.weight' not in sd: #Stable diffusion x4 upscaler VAE
|
||||||
ddconfig['ch_mult'] = [1, 2, 4]
|
ddconfig['ch_mult'] = [1, 2, 4]
|
||||||
self.downscale_ratio = 4
|
self.downscale_ratio = 4
|
||||||
self.upscale_ratio = 4
|
self.upscale_ratio = 4
|
||||||
|
|
||||||
self.first_stage_model = AutoencoderKL(ddconfig=ddconfig, embed_dim=4)
|
self.latent_channels = ddconfig['z_channels'] = sd["decoder.conv_in.weight"].shape[1]
|
||||||
|
if 'quant_conv.weight' in sd:
|
||||||
|
self.first_stage_model = AutoencoderKL(ddconfig=ddconfig, embed_dim=4)
|
||||||
|
else:
|
||||||
|
self.first_stage_model = AutoencodingEngine(regularizer_config={'target': "comfy.ldm.models.autoencoder.DiagonalGaussianRegularizer"},
|
||||||
|
encoder_config={'target': "comfy.ldm.modules.diffusionmodules.model.Encoder", 'params': ddconfig},
|
||||||
|
decoder_config={'target': "comfy.ldm.modules.diffusionmodules.model.Decoder", 'params': ddconfig})
|
||||||
else:
|
else:
|
||||||
self.first_stage_model = AutoencoderKL(**(config['params']))
|
self.first_stage_model = AutoencoderKL(**(config['params']))
|
||||||
self.first_stage_model = self.first_stage_model.eval()
|
self.first_stage_model = self.first_stage_model.eval()
|
||||||
|
|||||||
@ -5,6 +5,7 @@ from PIL import Image
|
|||||||
import math
|
import math
|
||||||
|
|
||||||
import comfy.utils
|
import comfy.utils
|
||||||
|
import comfy.model_management
|
||||||
|
|
||||||
|
|
||||||
class Blend:
|
class Blend:
|
||||||
@ -102,6 +103,7 @@ class Blur:
|
|||||||
if blur_radius == 0:
|
if blur_radius == 0:
|
||||||
return (image,)
|
return (image,)
|
||||||
|
|
||||||
|
image = image.to(comfy.model_management.get_torch_device())
|
||||||
batch_size, height, width, channels = image.shape
|
batch_size, height, width, channels = image.shape
|
||||||
|
|
||||||
kernel_size = blur_radius * 2 + 1
|
kernel_size = blur_radius * 2 + 1
|
||||||
@ -112,7 +114,7 @@ class Blur:
|
|||||||
blurred = F.conv2d(padded_image, kernel, padding=kernel_size // 2, groups=channels)[:,:,blur_radius:-blur_radius, blur_radius:-blur_radius]
|
blurred = F.conv2d(padded_image, kernel, padding=kernel_size // 2, groups=channels)[:,:,blur_radius:-blur_radius, blur_radius:-blur_radius]
|
||||||
blurred = blurred.permute(0, 2, 3, 1)
|
blurred = blurred.permute(0, 2, 3, 1)
|
||||||
|
|
||||||
return (blurred,)
|
return (blurred.to(comfy.model_management.intermediate_device()),)
|
||||||
|
|
||||||
class Quantize:
|
class Quantize:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|||||||
@ -176,7 +176,7 @@ def recursive_execute(server, prompt, outputs, current_item, extra_data, execute
|
|||||||
for node_id, node_outputs in outputs.items():
|
for node_id, node_outputs in outputs.items():
|
||||||
output_data_formatted[node_id] = [[format_value(x) for x in l] for l in node_outputs]
|
output_data_formatted[node_id] = [[format_value(x) for x in l] for l in node_outputs]
|
||||||
|
|
||||||
logging.error("!!! Exception during processing !!!")
|
logging.error(f"!!! Exception during processing!!! {ex}")
|
||||||
logging.error(traceback.format_exc())
|
logging.error(traceback.format_exc())
|
||||||
|
|
||||||
error_details = {
|
error_details = {
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import os
|
|||||||
import time
|
import time
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
supported_pt_extensions = set(['.ckpt', '.pt', '.bin', '.pth', '.safetensors'])
|
supported_pt_extensions = set(['.ckpt', '.pt', '.bin', '.pth', '.safetensors', '.pkl'])
|
||||||
|
|
||||||
folder_names_and_paths = {}
|
folder_names_and_paths = {}
|
||||||
|
|
||||||
|
|||||||
@ -204,7 +204,7 @@ export class EzWidget {
|
|||||||
convertToWidget() {
|
convertToWidget() {
|
||||||
if (!this.isConvertedToInput)
|
if (!this.isConvertedToInput)
|
||||||
throw new Error(`Widget ${this.widget.name} cannot be converted as it is already a widget.`);
|
throw new Error(`Widget ${this.widget.name} cannot be converted as it is already a widget.`);
|
||||||
var menu = this.node.menu["Convert 🔘 to widget.."].item.submenu.options;
|
var menu = this.node.menu["Convert Input to Widget"].item.submenu.options;
|
||||||
var index = menu.findIndex(a => a.content == `Convert ${this.widget.name} to widget`);
|
var index = menu.findIndex(a => a.content == `Convert ${this.widget.name} to widget`);
|
||||||
menu[index].callback.call();
|
menu[index].callback.call();
|
||||||
}
|
}
|
||||||
@ -212,7 +212,7 @@ export class EzWidget {
|
|||||||
convertToInput() {
|
convertToInput() {
|
||||||
if (this.isConvertedToInput)
|
if (this.isConvertedToInput)
|
||||||
throw new Error(`Widget ${this.widget.name} cannot be converted as it is already an input.`);
|
throw new Error(`Widget ${this.widget.name} cannot be converted as it is already an input.`);
|
||||||
var menu = this.node.menu["Convert input to 🔘.."].item.submenu.options;
|
var menu = this.node.menu["Convert Widget to Input"].item.submenu.options;
|
||||||
var index = menu.findIndex(a => a.content == `Convert ${this.widget.name} to input`);
|
var index = menu.findIndex(a => a.content == `Convert ${this.widget.name} to input`);
|
||||||
menu[index].callback.call();
|
menu[index].callback.call();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -256,8 +256,18 @@ export function mergeIfValid(output, config2, forceUpdate, recreateWidget, confi
|
|||||||
return { customConfig };
|
return { customConfig };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let useConversionSubmenusSetting;
|
||||||
app.registerExtension({
|
app.registerExtension({
|
||||||
name: "Comfy.WidgetInputs",
|
name: "Comfy.WidgetInputs",
|
||||||
|
init() {
|
||||||
|
useConversionSubmenusSetting = app.ui.settings.addSetting({
|
||||||
|
id: "Comfy.NodeInputConversionSubmenus",
|
||||||
|
name: "Node widget/input conversion sub-menus",
|
||||||
|
tooltip: "In the node context menu, place the entries that convert between input/widget in sub-menus.",
|
||||||
|
type: "boolean",
|
||||||
|
defaultValue: true,
|
||||||
|
});
|
||||||
|
},
|
||||||
async beforeRegisterNodeDef(nodeType, nodeData, app) {
|
async beforeRegisterNodeDef(nodeType, nodeData, app) {
|
||||||
// Add menu options to conver to/from widgets
|
// Add menu options to conver to/from widgets
|
||||||
const origGetExtraMenuOptions = nodeType.prototype.getExtraMenuOptions;
|
const origGetExtraMenuOptions = nodeType.prototype.getExtraMenuOptions;
|
||||||
@ -295,20 +305,28 @@ app.registerExtension({
|
|||||||
|
|
||||||
//Convert.. main menu
|
//Convert.. main menu
|
||||||
if (toInput.length) {
|
if (toInput.length) {
|
||||||
options.push({
|
if (useConversionSubmenusSetting.value) {
|
||||||
content: `Convert input to 🔘..`,
|
options.push({
|
||||||
submenu: {
|
content: "Convert Widget to Input",
|
||||||
options: toInput,
|
submenu: {
|
||||||
},
|
options: toInput,
|
||||||
});
|
},
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
options.push(...toInput, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (toWidget.length) {
|
if (toWidget.length) {
|
||||||
options.push({
|
if (useConversionSubmenusSetting.value) {
|
||||||
content: `Convert 🔘 to widget..`,
|
options.push({
|
||||||
submenu: {
|
content: "Convert Input to Widget",
|
||||||
options: toWidget,
|
submenu: {
|
||||||
},
|
options: toWidget,
|
||||||
});
|
},
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
options.push(...toWidget, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user