I am having some issues using the Roop API with Automatic1111. I suspect I am reading in and/or sending the base64 image to the API incorrectly. When using the Roop API using my code, I seem to get results that are faces with black discoloring on them when a PNG file is used. When a JPG file is used, the images generated look good. When using the WebUI Gradio user interface, PNG and JPGs both work well. This leads me to believe I have poorly implemented the reading in of image files to send as base64 to the API. Any help would be appreciated!
With JPGs fed into API:
With PNGs fed into API:
The area of my code I suspect most is imageToBase64. I suspect that this is working fine for JPGs, but perhaps I am not handling it correctly for PNGs:
function imageToBase64(path) {
// read binary data
const bitmap = fs.readFileSync(path);
// convert binary data to base64 encoded string
return Buffer.from(bitmap).toString('base64');
}
roop = async function(locationOfSourceImage, prompt, neg){
var modelLocation = '/home/ubuntu/SD/stable-diffusion-webui/models/roop/inswapper_128.onnx'
var img_base64 = imageToBase64(locationOfSourceImage)
var args=[img_base64,true,'0',modelLocation,'CodeFormer',1,null,1,'None',false,true]
var payload = {
"prompt": prompt,
"negative_prompt": neg,
"seed": -1,
"sampler_name": "DPM++ 2M Karras",
"steps": 20,
"cfg_scale": 4.5,
"width": 512,
"height": 768,
"restore_faces": true,
//Begin HighResFix
"enable_hr": true,
"denoising_strength": 0.2,
"hr_upscaler": "ESRGAN_4x",
"hr_scale": 1.5,
//End HighResFix
"alwayson_scripts": {"roop":{"args":args}},
"override_settings": {"CLIP_stop_at_last_layers": 2 }
}
//some other code not included here
}
Hello,
I am having some issues using the Roop API with Automatic1111. I suspect I am reading in and/or sending the base64 image to the API incorrectly. When using the Roop API using my code, I seem to get results that are faces with black discoloring on them when a PNG file is used. When a JPG file is used, the images generated look good. When using the WebUI Gradio user interface, PNG and JPGs both work well. This leads me to believe I have poorly implemented the reading in of image files to send as base64 to the API. Any help would be appreciated!
With JPGs fed into API:![image](https://github.com/s0md3v/sd-webui-roop/assets/116394058/d44cdaed-f947-47a2-a3e3-03ddee84bdb3)
With PNGs fed into API:![image](https://github.com/s0md3v/sd-webui-roop/assets/116394058/14bc8dab-db17-4e4e-9f3e-50591bd1db9c)
The area of my code I suspect most is imageToBase64. I suspect that this is working fine for JPGs, but perhaps I am not handling it correctly for PNGs: