preview
This commit is contained in:
@@ -24,6 +24,7 @@ const Txt23DHandler: RequestHandler<Txt2ImgRequest, any> = async (ctx) => {
|
||||
url: ctx.body = baseUrl + '/view?filename=' + await new Promise((resolve, reject) => {
|
||||
const taskID = Math.random().toFixed(10);
|
||||
const ws = new WebSocket(`${baseWsUrl}/ws?clientId=${taskID}`);
|
||||
ws.binaryType = "arraybuffer";
|
||||
ws.onopen = () => {
|
||||
try {
|
||||
axios.post("/prompt", {
|
||||
|
@@ -21,6 +21,7 @@ const Txt2ImgHandler: RequestHandler<Txt2ImgRequest, any> = async (ctx, next) =>
|
||||
const { prompt, loraDetail, loraModel } = requestBody;
|
||||
const inputNode = selectNodeFromApiJSONbyID(txt2imgAPIformatJSON, "33");
|
||||
let temp = "";
|
||||
let preViewBlobs:any = [];
|
||||
inputNode.inputs.string = prompt;
|
||||
ctx.body = {
|
||||
data: await new Promise((resolve, reject) => {
|
||||
@@ -33,6 +34,7 @@ const Txt2ImgHandler: RequestHandler<Txt2ImgRequest, any> = async (ctx, next) =>
|
||||
prompt: txt2imgAPIformatJSON,
|
||||
// extra_data: txt2imgAPIformatExtraData
|
||||
});
|
||||
console.log(`ok`);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
@@ -50,11 +52,13 @@ const Txt2ImgHandler: RequestHandler<Txt2ImgRequest, any> = async (ctx, next) =>
|
||||
temp = data.output.text[0];
|
||||
}
|
||||
if (data.node === '94') {
|
||||
resolve({ prompt: temp, url: baseUrl + '/view?filename=' + data.output.images[0].filename })
|
||||
resolve({ prompt: temp, url: baseUrl + '/view?filename=' + data.output.images[0].filename, preViewBlobs: preViewBlobs });
|
||||
}
|
||||
}else if (type === "executing") {
|
||||
}
|
||||
} else {
|
||||
|
||||
} else if (event.data instanceof Buffer) {
|
||||
console.log(`event.data`, event.data);
|
||||
preViewBlobs.push(event.data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -44,8 +44,11 @@ const UpscaleHandler: RequestHandler<any ,any> = async (ctx) => {
|
||||
resolve(data.output.images[0].filename)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
} else if(event.data instanceof ArrayBuffer) {
|
||||
const blob = new Blob([event.data])// arraybuffer to blob
|
||||
let a = new FileReader();
|
||||
a.onload = function (e) { console.log('image/png;base64,'+ e.target!.result) }
|
||||
a.readAsDataURL(blob);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user