get image

This commit is contained in:
zjt 2024-05-25 22:31:49 +08:00
parent 6f43190f9d
commit a32007c8fd
3 changed files with 62 additions and 47 deletions

View File

@ -20,6 +20,7 @@ const Txt23DHandler: RequestHandler<any, any> = async (ctx) => {
const { prompt, url } = requestBody;
const inputNode = selectNodeFromApiJSONbyID(txt23dApiFormatJSON, "33");
inputNode.inputs.string = prompt;
try {
ctx.body = {
url: ctx.body = baseUrl + '/view?filename=' + await new Promise((resolve, reject) => {
const taskID = Math.random().toFixed(10);
@ -52,5 +53,9 @@ const Txt23DHandler: RequestHandler<any, any> = async (ctx) => {
}
})
}
} catch (error) {
console.log(error);
}
}
export default Txt23DHandler;

View File

@ -22,8 +22,9 @@ const Txt2ImgHandler: RequestHandler<Txt2ImgRequest, any> = async (ctx, next) =>
const { prompt, loraDetail, loraModel } = requestBody;
const inputNode = selectNodeFromApiJSONbyID(txt2imgAPIformatJSON, "33");
let temp = "";
let preViewBlobs:any = [];
let preViewBlobs: any = [];
inputNode.inputs.string = prompt;
try {
ctx.body = {
data: await new Promise((resolve, reject) => {
const taskID = Math.random().toFixed(10);
@ -66,7 +67,7 @@ const Txt2ImgHandler: RequestHandler<Txt2ImgRequest, any> = async (ctx, next) =>
})
resolve({ prompt: temp, url: baseUrl + '/view?filename=' + data.output.images[0].filename });
}
}else if (type === "executing") {
} else if (type === "executing") {
}
} else if (event.data instanceof Buffer) {
@ -75,5 +76,9 @@ const Txt2ImgHandler: RequestHandler<Txt2ImgRequest, any> = async (ctx, next) =>
}
})
}
} catch (error) {
console.log(error);
}
}
export default Txt2ImgHandler;

View File

@ -21,6 +21,7 @@ const UpscaleHandler: RequestHandler<any ,any> = async (ctx) => {
const { prompt, url } = requestBody;
const inputNode = selectNodeFromApiJSONbyID(upScaleAPIFormatJSON, "12");
inputNode.inputs.image = url;
try {
ctx.body = {
url: baseUrl + '/view?filename=' + await new Promise((resolve, reject) => {
const taskID = Math.random().toFixed(10);
@ -52,5 +53,9 @@ const UpscaleHandler: RequestHandler<any ,any> = async (ctx) => {
}
})
}
}catch (error) {
console.log(error);
}
}
export default UpscaleHandler;