diff --git a/py/api.py b/py/api.py index 5111b6e..c466b4f 100644 --- a/py/api.py +++ b/py/api.py @@ -6,6 +6,7 @@ import json from server import PromptServer from .config import RESOURCES_DIR, FOOOCUS_STYLES_DIR, FOOOCUS_STYLES_SAMPLES from .easyNodes import easyCache +from .logic import ConvertAnything try: import aiohttp @@ -85,6 +86,19 @@ async def getStylesImage(request): return web.Response(text=FOOOCUS_STYLES_SAMPLES + name + '.jpg') return web.Response(status=400) +@PromptServer.instance.routes.post("/easyuse/convert") +async def convertType(request): + post = await request.post() + type = post.get('type') + print(type) + if type: + ConvertAnything.RETURN_TYPES = (type.upper(),) + ConvertAnything.RETURN_NAMES = (type,) + print(ConvertAnything.RETURN_TYPES) + return web.Response(status=200) + else: + return web.Response(status=400) + NODE_CLASS_MAPPINGS = {} NODE_DISPLAY_NAME_MAPPINGS = {} \ No newline at end of file diff --git a/py/easyNodes.py b/py/easyNodes.py index ee8b81b..0f607af 100644 --- a/py/easyNodes.py +++ b/py/easyNodes.py @@ -2068,10 +2068,7 @@ class cascadeSettings: return {"ui": {"value": [seed_num]}, "result": (new_pipe,)} # layerDiffusion预采样参数 -try: - ModelPatcher.calculate_weight = calculate_weight_adjust_channel(ModelPatcher.calculate_weight) -except: - pass + class layerDiffusionSettings: def __init__(self): @@ -2442,6 +2439,10 @@ class samplerFull: method = self.get_layer_diffusion_method(pipe['loader_settings']['layer_diffusion_method'], samp_blend_samples is not None) weight = pipe['loader_settings']['layer_diffusion_weight'] if 'layer_diffusion_weight' in pipe['loader_settings'] else 1.0 + try: + ModelPatcher.calculate_weight = calculate_weight_adjust_channel(ModelPatcher.calculate_weight) + except: + pass samp_model, samp_positive, samp_negative = self.apply_layer_diffusion(samp_model, method, weight, samp_samples, samp_blend_samples, samp_positive, samp_negative) def downscale_model_unet(samp_model): diff --git a/web/js/easy/easyDynamicWidgets.js b/web/js/easy/easyDynamicWidgets.js index 82773cd..83fccec 100644 --- a/web/js/easy/easyDynamicWidgets.js +++ b/web/js/easy/easyDynamicWidgets.js @@ -855,14 +855,24 @@ app.registerExtension({ if(nodeData.name == 'easy convertAnything'){ const onNodeCreated = nodeType.prototype.onNodeCreated; + const changeType = async function (type) { + const body = new FormData(); + body.append("type", type); + const response = await api.fetchApi("/easyuse/convert", { method:'POST',body}); + } nodeType.prototype.onNodeCreated = async function () { onNodeCreated ? onNodeCreated.apply(this, []) : undefined; - const type_control = this.widgets[this.widgets.findIndex((w) => w.name === "output_type")] - let _this = this - type_control.callback = _ => { - _this.outputs[0].type = (type_control.value).toUpperCase() - _this.outputs[0].name = type_control.value - } + setTimeout(_=>{ + const type_control = this.widgets[this.widgets.findIndex((w) => w.name === "output_type")] + let _this = this + changeType(type_control.value) + type_control.callback = async() => { + _this.outputs[0].type = (type_control.value).toUpperCase() + _this.outputs[0].name = type_control.value + _this.outputs[0].label = type_control.value + changeType(type_control.value) + } + },300) } }