fkunn1326 / openpose-editor

Openpose Editor for AUTOMATIC1111's stable-diffusion-webui
MIT License
1.73k stars 207 forks source link

FIX - ADD BACKGROUND IMAGE #132

Closed code-boxx closed 1 year ago

code-boxx commented 1 year ago

main.py

# bg_input = gr.UploadButton(label="Add Background Image", file_types=["image"], elem_id="openpose_bg_button")
bg_input = gr.Button(value="Add Background Image")

#bg_input.upload(None, [bg_input], [width, height], _js="addBackground")
bg_input.click(None, [], None, _js="addBackground")

main.js

async function addBackground () {
    const input = document.createElement("input");
    input.type = "file"
    input.accept = "image/*"
    input.onchange = e => {
        const file = e.target.files[0];
        var fileReader = new FileReader();
        fileReader.onload = async function () {
            var url = this.result;
            openpose_editor_canvas.setBackgroundImage(url, openpose_editor_canvas.renderAll.bind(openpose_editor_canvas), {
                opacity: 0.5
            });
            const img = new Image();
            await (img.src = url);
            resizeCanvas(img.width, img.height);
        };
        fileReader.readAsDataURL(file);
    };
    input.click();
}

Quick and dirty fix. Time to switch UploadButton to Button...

fulleclip commented 1 year ago

I have made the indicated modification in both files, now the loading of background images works, but the rest of the options do not, when I try to load a json model it does nothing and when I want it to recognize the pose from an image it is as if I placed it background, but the canvas cannot be moved

Twitcherlung commented 1 year ago

i updated to latest version and cant to add background image anyway

fkunn1326 commented 1 year ago

I have pushed an update (https://github.com/fkunn1326/openpose-editor/commit/db07b9c69c224d1d64f9f70713b2908f2da29912), so please update this extension.

fulleclip commented 1 year ago

The version "db07b9c6" continues to appear after updating.

I have also modified the code as indicated and the same problems continue to appear, at least with version 1.6

fkunn1326 commented 1 year ago

The version "db07b9c6" continues to appear after updating.

I have also modified the code as indicated and the same problems continue to appear, at least with version 1.6

Please show me the screenshot of the browser's dev console.

fulleclip commented 1 year ago

Are you referring to this?

Sin título Sin título1