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

Input Image is set globally? Other connected clients can see them #716

Closed
666spawn999 opened this issue Oct 17, 2023 · 8 comments
Closed
Labels
bug Something isn't working

Comments

@666spawn999
Copy link

666spawn999 commented Oct 17, 2023

Hi,
I'm trying to setup a Fooocus intance for me and my colleagues. But Input Images are shared and kept in cache somehow...

Error

  • Client A adds an Input Image into "Upscale" or "Inpaint" Tab
  • Client B open the "Inpaint" Tab -> The Image of Client A appears
  • Image stays in Cache and is showed even after reloads, browser changes etc...

Short Video of this error with 2 browsers side by side
Fooocus_InputImage_Sharing

Steps to Reproduce

  • Open 2 Browser windows (same/different Browsers or incognito, doesn't matter)
  • Client A adds an image to the "Upscale" InputImage
  • Client B opens the "Inpaint" Tab --> Image of Client A is shown
  • Open a completely different Browser -> Image will be loaded in "Inpaint" Tab

Some thoughts

  • I think this may be a problem of the global/"shared" Variables in the code? The Input Image seems to be cached globally instead of being bound to a session.

A fix or ony tips how remove this behaviour would be highly appreciated!
For people who are working alone with Fooocus, this may be not a problem. But for Privacy reasons in multi-user scenarios, this is a critical issue ...

(I really love Fooocus and love all the features and the simplicity of it. Thanks for all your work!
But sadly, bugs like this prevent me from using it in production or teams :( )

@lllyasviel lllyasviel added the bug Something isn't working label Oct 17, 2023
@tarik23
Copy link

tarik23 commented Oct 20, 2023

+1
More of that next user pressing button "Generate" receives images of previous user...
Could be it fixed any way? Maybe clear cache.....

@666spawn999
Copy link
Author

@tarik23 That is the other problem, that I have reported:
#713

@mashb1t
Copy link
Collaborator

mashb1t commented Oct 29, 2023

The following code solves the image issue, but there might be a dynamic solution for calling the methods select_uov_tab etc. as fn can not handle static input strings and lambda can't handle non-global state inputs.

@lllyasviel Maybe you find a better solution or we can merge it as is. See commit mashb1t@ac153e5

            current_tab = gr.Textbox(value='uov', visible=False)

            default_image = gr.State(value=None)

            def update_default_image(x):
                if isinstance(x, dict):
                    default_image = x['image']
                else:
                    default_image = x
                return default_image

            def clear_default_image():
                return None

            uov_input_image.upload(update_default_image, inputs=uov_input_image, outputs=default_image, queue=False)
            inpaint_input_image.upload(update_default_image, inputs=inpaint_input_image, outputs=default_image, queue=False)

            uov_input_image.clear(clear_default_image, outputs=default_image, queue=False)
            inpaint_input_image.clear(clear_default_image, outputs=default_image, queue=False)

            def select_uov_tab(image):
                return 'uov', image

            def select_inpaint_tab(image):
                return 'inpaint', image

            def select_ip_tab(image):
                return 'ip', image

            uov_tab.select(fn=select_uov_tab, inputs=[default_image], outputs=[current_tab, uov_input_image], queue=False, _js=down_js)
            inpaint_tab.select(fn=select_inpaint_tab, inputs=[default_image], outputs=[current_tab, inpaint_input_image], queue=False, _js=down_js)
            ip_tab.select(fn=select_ip_tab, inputs=[default_image], outputs=[current_tab], queue=False, _js=down_js)

mashb1t added a commit to mashb1t/Fooocus that referenced this issue Oct 29, 2023
@lllyasviel
Copy link
Owner

@mashb1t thanks for this!
if you make a commit i will merge yours
if not then i will copy this

@mashb1t
Copy link
Collaborator

mashb1t commented Oct 29, 2023

will create a PR during the day 👍

mashb1t added a commit to mashb1t/Fooocus that referenced this issue Oct 29, 2023
@666spawn999
Copy link
Author

thanks for looking into this!

I tried it and it seems that this does the trick!

I myself looked into Gradio States etc. but I didn't got it right. Thanks for this and I think this can be closed when the PR is accepted.

Thanks again! :D

lllyasviel added a commit that referenced this issue Oct 29, 2023
* use state instead of global for default_image

solves issue #716

* fix

---------

Co-authored-by: lllyasviel <[email protected]>
@lllyasviel
Copy link
Owner

fixed in 2.1.758

@mashb1t
Copy link
Collaborator

mashb1t commented Oct 31, 2023

@666spawn999 issue can be closed

@mashb1t mashb1t closed this as completed Jan 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants