fix:convertAnything issue #71

This commit is contained in:
yolain
2024-03-05 01:40:06 +08:00
parent 9f9396ae13
commit 722e9f4299
3 changed files with 35 additions and 10 deletions
+14
View File
@@ -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 = {}
+5 -4
View File
@@ -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):
+16 -6
View File
@@ -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)
}
}