-
-
Save unitycoder/f24872f57f868eb37af99713d88f4abb to your computer and use it in GitHub Desktop.
This is a simplified version of whats needed to connect to InvokeAI websocket api, submit requests, upload init_images and recieve results
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const io = require("socket.io-client") | |
const socket = io("http://127.0.0.1:9090",{reconnect: true}) | |
const log = console.log.bind(console) | |
socket.on("connect", (socket) => { | |
log(socket) // Connected to api | |
}) | |
socket.on("progressUpdate", (data) => { | |
log(data) // Returns current steps, status etc | |
} | |
socket.on("generationResult", (data) => { | |
log(data) // data contains all the image data needed (params, filename etc) | |
}) | |
var imageOptions={ | |
prompt: 'anon goes to space', | |
iterations: 1, | |
steps: 50, | |
cfg_scale: 7.5, | |
threshold: 0, | |
perlin: 0, | |
sampler_name: 'k_lms', | |
width: 512, | |
height: 512, | |
seed: 2977597109, | |
progress_images: false, | |
variation_amount: 0, | |
strength: 0.75, | |
fit: true | |
} | |
var upscale=false // or an object like {level:2,strength:0.5} | |
var facefix=false // or an object like {type:'codeformer',strength:1,codeformer_fidelity:1}} | |
socket.emit('generateImage',imageOptions,upscale,facefix) // Send request, result comes via a "generationResult" reply | |
// if you need to send an init image | |
// "initimg" should contain a buffered file // Buffer.from(res.data) | |
// socket.emit('uploadInitialImage', initimg, 'filename.png') // I pass an id via the filename to associate the returned result later | |
socket.on("initialImageUploaded", (data) => { | |
log(data) // Contains uploaded images new filename | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment