continue-revolution/sd-webui-segment-anything

[Bug]: failed to add dot in pics

MasterKenway opened this issue · 2 comments

Is there an existing issue for this?

  • I have searched the existing issues and checked the recent builds/commits of both this extension and the webui

Have you updated WebUI and this extension to the latest version?

  • I have updated WebUI and this extension to the latest version

Do you understand that you should read the 1st item of https://github.com/continue-revolution/sd-webui-segment-anything#faq if you cannot install GroundingDINO?

  • My problem is not about installing GroundingDINO

Do you understand that you should use the latest ControlNet extension and enable external control if you want SAM extension to control ControlNet?

  • I have updated ControlNet extension and enabled "Allow other script to control this extension"

Do you understand that you should read the 2nd item of https://github.com/continue-revolution/sd-webui-segment-anything#faq if you observe problems like AttributeError bool object has no attribute enabled and TypeError bool object is not subscriptable?

  • My problem is not about such issue, otherwise I have tried changing the extension directory name from sd-webui-segment-anything to a1111-sd-webui-segment-anything

What happened?

image
Under the tab here, this extension failed to add dot in the pics, and it turns out that there is a bug about class selector.
The source code in the repo is below:

function samTabPrefix() {
    const tabs = gradioApp().querySelector('#tabs');
    if (tabs) {
        const buttons = tabs.querySelectorAll('button');
        if (buttons) {
            if (buttons[0].className.includes("selected")) {
                return "txt2img_sam_"
            } else if (buttons[1].className.includes("selected")) {
                return "img2img_sam_"
            }
        }
    }
    return "_sam_"
}

And the fact is when top level tab is active, there is no selected class under the button, so the solution is change selected to bg-white

Steps to reproduce the problem

just install this extension

What should have happened?

show dot on the pics

Commit where the problem happens

a1111-sd-webui-segment-anything/javascript/sam.js

What browsers do you use to access the UI ?

No response

Command Line Arguments

nothing

Console logs

nothing

Additional information

No response

#32 similar bug found here but happened whether GroundingDINO is enable or not

Are you using a very old webui? If so, please update. The extension will not work if you use gradio 3.16 (there will be some other errors even if you manually change js to what you have described) and the change you describe will break for all users with later webui.

If you are using webui 1.4.0 (gradio 3.22), let me know and I’ll find a way to fix.