Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems using PNG with the API #282

Open
im-kent opened this issue Nov 13, 2023 · 1 comment
Open

Problems using PNG with the API #282

im-kent opened this issue Nov 13, 2023 · 1 comment

Comments

@im-kent
Copy link

im-kent commented Nov 13, 2023

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

With PNGs fed into API:
image

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
}

@xxyyboy
Copy link

xxyyboy commented Mar 22, 2024

same problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants