AlUlkesh / stable-diffusion-webui-images-browser

an images browse for stable-diffusion-webui
609 stars 110 forks source link

Send to ControlNet #67

Closed MrKuenning closed 1 year ago

MrKuenning commented 1 year ago

Can we have an option to send to ControlNet?

It could be a useful way to browse openpose images and send them to ControlNet.

AlUlkesh commented 1 year ago

@MrKuenning How exactly would you expect this to work?

You can have multiple ControlNets in txt2img and again in img2img. How should be determined where to send the image?

MrKuenning commented 1 year ago

One way would be like how the open pose editor extension does it.

Screenshot_20230311-025826.png

There is a button for controlnet in t2i and i2i and a drop down to select which controlnet layer.

Personally I don't really use layers and would be happy if it was only sent to the first layer.

AlUlkesh commented 1 year ago

Here it is. Let me know, if it works, as you expect.

image

MrKuenning commented 1 year ago

That works great. Thanks!

I am sure this will help a lot of people. There are many workflows that involve generating an image and then inserting it into the controlnet. Something that was annoying on PC and impossible on mobile before. Now I can just send it right back from the image browser.

Additionally, I have a set of directories of OpenPoses with pose previews, I can now browse through those from the image browser and insert whatever pose I need.

2023-03-11 10_34_58-NVIDIA GeForce Overlay DT

EllangoK commented 1 year ago

Yeah this for sure a great feature thanks AlUlkesh, I've also been using control net a lot recently so this really helpful.

@MrKuenning just to lyk in case you don't, but you can add your own folders as a separate tab next to txt2img, img2img and the rest on the bar up there in settings. So it might be a bit better instead of accessing it from others.

MrKuenning commented 1 year ago

Funny you mention that, I just found that setting and was coming back to say so.

2023-03-11 11_59_23-NVIDIA GeForce Overlay DT

MrKuenning commented 1 year ago

I do have one question. My buttons have an odd blank space and button wrap.

2023-03-11 12_01_47-NVIDIA GeForce Overlay DT

It doesn't break functionality, just wanted to point it out as your image shows them all on one line.

EllangoK commented 1 year ago

Yeah I created that feature, but one thing in general which AlUlkesh prob noticed as well, its hard to tell people like what is new in an update.

And also in regards to the spaces issues, its the same for me, and it is because of these lines https://github.com/AlUlkesh/stable-diffusion-webui-images-browser/blob/7dbd508461af2b533d931ee3f03118b13b9f05d5/scripts/image_browser.py#L952-L953 deleting it fixes that but @AlUlkesh you also might want it at the end so idk

At the end

image

No breaks

image

There is a difference but imo I think no breaks is better and probably scales properly when resized for other people.

AlUlkesh commented 1 year ago

Always good to hear something you develop is actually used. Thanks.

Those spaces are there to keep the ControlNet elements together. But apparently only with my window size.

That whole column right of the image gallery has been extremely finicky. It doesn't group like I'd expect it to do from what I read on the gradio site. So it's mostly trial and error, to make the grouping make somewhat sense.

EllangoK commented 1 year ago

Yeah you are right, I was thinking initiallly shouldn't it just easy to put it into two rows?

But yeah no,

with gr.Row():
    if tab.name != favorite_tab_name:
        favorites_btn = gr.Button(f'{copy_move[opts.image_browser_copy_image]} to favorites', elem_id=f"{tab.base_tag}_image_browser_favorites_btn")
    try:
        send_to_buttons = modules.generation_parameters_copypaste.create_buttons(["txt2img", "img2img", "inpaint", "extras"])
    except:
        pass
    sendto_openoutpaint = gr.Button("Send to openOutpaint", elem_id=f"{tab.base_tag}_image_browser_openoutpaint_btn", visible=openoutpaint)
with gr.Row():
    sendto_controlnet_txt2img = gr.Button("Send to txt2img ControlNet", visible=controlnet)
    sendto_controlnet_img2img = gr.Button("Send to img2img ControlNet", visible=controlnet)
    controlnet_max = opts.data.get("control_net_max_models_num", 1)
    sendto_controlnet_num = gr.Dropdown(list(range(controlnet_max)), label="ControlNet number", value="0", interactive=True, visible=(controlnet and controlnet_max > 1))

for some reason gives this image but still two columns gives two columns.

But yeah very weird, did not realise.

EllangoK commented 1 year ago

Alright this should work

with gr.Column():
    with gr.Row():
        if tab.name != favorite_tab_name:
            favorites_btn = gr.Button(f'{copy_move[opts.image_browser_copy_image]} to favorites', elem_id=f"{tab.base_tag}_image_browser_favorites_btn")
        try:
            send_to_buttons = modules.generation_parameters_copypaste.create_buttons(["txt2img", "img2img", "inpaint", "extras"])
        except:
            pass
        sendto_openoutpaint = gr.Button("Send to openOutpaint", elem_id=f"{tab.base_tag}_image_browser_openoutpaint_btn", visible=openoutpaint)
    with gr.Row():
        sendto_controlnet_txt2img = gr.Button("Send to txt2img ControlNet", visible=controlnet)
        sendto_controlnet_img2img = gr.Button("Send to img2img ControlNet", visible=controlnet)
        controlnet_max = opts.data.get("control_net_max_models_num", 1)
        sendto_controlnet_num = gr.Dropdown(list(range(controlnet_max)), label="ControlNet number", value="0", interactive=True, visible=(controlnet and controlnet_max > 1))

image

I'll drop a PR