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

Image save filename consistency #1421

Closed
flashthepublic opened this issue Dec 15, 2023 · 21 comments · Fixed by #1932 or #1863
Closed

Image save filename consistency #1421

flashthepublic opened this issue Dec 15, 2023 · 21 comments · Fixed by #1932 or #1863
Labels
enhancement New feature or request
Milestone

Comments

@flashthepublic
Copy link

Is your feature request related to a problem? Please describe.
When you save an image sometime the filename used by the browser is just "image.png" which leads to issue when you save multiple images
Sometimes its a more usable "image - timestamp" (ex: "image - 2023-12-15T093912.142")

Describe the idea you'd like
Could it be consistently the name with the timestamp? it's easier to save when you organize multiple generation in different folders

@mashb1t
Copy link
Collaborator

mashb1t commented Dec 29, 2023

Fooocus should always use generate_temp_filename from https://github.com/lllyasviel/Fooocus/blob/main/modules/util.py#L141 (tested locally and in Colab).
Please provide some examples and steps to reproduce when the filename is image.png.

@mashb1t mashb1t added bug Something isn't working question Further information is requested labels Dec 29, 2023
@mJastrzebski6
Copy link

(On Windows) Using this button the photo will be saved in the downloads folder with the name "image".
Screenshot_1

@mashb1t
Copy link
Collaborator

mashb1t commented Dec 30, 2023

@mJastrzebski6 just to make sure, are you certain you're using the latest version of Fooocus (2.1.857)?

@flashthepublic
Copy link
Author

Fooocus should always use generate_temp_filename from https://github.com/lllyasviel/Fooocus/blob/main/modules/util.py#L141 (tested locally and in Colab). Please provide some examples and steps to reproduce when the filename is image.png.

I opened the webpage clicked generate
then clicked on one of the image and then on the icon to download.

image

@mashb1t
Copy link
Collaborator

mashb1t commented Jan 1, 2024

@mJastrzebski6 just to make sure, are you certain you're using the latest version of Fooocus (2.1.857)?

@flashthepublic can you please also check?

@flashthepublic
Copy link
Author

@mJastrzebski6 just to make sure, are you certain you're using the latest version of Fooocus (2.1.857)?

@flashthepublic can you please also check?

Tried on 857
image
and 859
image

For information in the History log filename seems correct
C:/Tools/Fooocus/Fooocus/outputs/2024-01-01/2024-01-01_11-32-00_3667.png
but when saving it points to temp file:
C:\Users\ftp\AppData\Local\Temp\gradio\21248590d5ee99f983ee2d975c82f03fc87a1472\image.png

so this might be the issue

@mashb1t mashb1t removed the question Further information is requested label Jan 1, 2024
@mashb1t
Copy link
Collaborator

mashb1t commented Jan 2, 2024

Can't reproduce, maybe somebody else is able to help. It also works on Colab for me 😐

@mashb1t mashb1t added help wanted Extra attention is needed question Further information is requested and removed bug Something isn't working labels Jan 2, 2024
@mashb1t
Copy link
Collaborator

mashb1t commented Jan 2, 2024

One more thing: are you maybe using Firefox? (i tested it in Chrome, but there seem to be a few things not working in FF such as #1425)

@mashb1t
Copy link
Collaborator

mashb1t commented Jan 8, 2024

@flashthepublic @mJastrzebski6 bump

@flashthepublic
Copy link
Author

One more thing: are you maybe using Firefox? (i tested it in Chrome, but there seem to be a few things not working in FF such as #1425)

No, Tested in Brave and Chrome

@mashb1t
Copy link
Collaborator

mashb1t commented Jan 8, 2024

That's really weird. Can you please provide your console output and check maybe also in Colab, so we can rule out the environment and confirm it independently?

@machineminded
Copy link

I'm experiencing the same with the latest version of Fooocus. When I right click on an image from the gallery in both Chrome and Firefox, it always wants to save it as "image.png".

@mJastrzebski6
Copy link

I'm experiencing the same with the latest version of Fooocus. When I right click on an image from the gallery in both Chrome and Firefox, it always wants to save it as "image.png".

same here, both on firefox and chrome, both right click and download button - image.png
weird
but in the outputs folder the photos are saved correctly with the timestamp name

@mashb1t
Copy link
Collaborator

mashb1t commented Jan 14, 2024

Still not able to reproduce this behavior... Also see #1798.
Any help would be appreciated!

@mashb1t
Copy link
Collaborator

mashb1t commented Jan 14, 2024

Ok, i was able to reproduce the situation.

Quick background analysis:

  • Fooocus creates the image in async_worker.py
  • Fooocus yields the result in async_worker.py
  • Fooocus updates the gallery component in webui.py

In general, the output of the files has nothing to do with saving the images in the outputs folder.
Somehow Chrome adds timestamps etc. to the filename, but i can't tell why this happens as this logic is not implemented in Fooocus.

Fooocus can not influence the filename in the gallery component without adjustments as the images are temporarily created and stored by Gradio in the gradio temp folder after providing the image in a numpy array. Before you ask: the caption does not influence the filename, already tried to make it work with that.

Above reasons show that this issue should not be classified as a bug, but an enhancement.

A potential implementation would be to save each image from numpy to disk to gradio temp file directory, rename the file to the corresponding timestamp when it's been created and then return the filepath string to Gradio.

I hope the analysis has shed some light on the situation at hand.

@mashb1t mashb1t added enhancement New feature or request and removed help wanted Extra attention is needed question Further information is requested labels Jan 14, 2024
@eddyizm
Copy link
Contributor

eddyizm commented Jan 14, 2024

Definitely an issue with Firefox, both local and in colab.

@machineminded
Copy link

Probably tangentially related, but my Fooocus install, even when using latest from main, doesn't save anything to the outputs folder. They only end up in the default gradio directory in the user's appdata temp folder.

@machineminded
Copy link

I hope the analysis has shed some light on the situation at hand.

To me it seems like gradio is working as designed. How are images ending up in output though?

@mashb1t
Copy link
Collaborator

mashb1t commented Jan 14, 2024

@eddyizm
Copy link
Contributor

eddyizm commented Jan 14, 2024

Probably tangentially related, but my Fooocus install, even when using latest from main, doesn't save anything to the outputs folder. They only end up in the default gradio directory in the user's appdata temp folder.

Something else may be going on with that, saving to the outputs folder has been rock solid since day 1 on all my installs, local and colab without fail.

If you open a new issue and add your logs and details on your install we can look into it.

@mashb1t
Copy link
Collaborator

mashb1t commented Jan 14, 2024

You can find the implementation in #1932 (comment).
It's not yet perfect and might be optimized (if even possible), see PR description.

@mashb1t mashb1t linked a pull request Jan 14, 2024 that will close this issue
@mashb1t mashb1t added this to the 2.2.0 milestone Feb 25, 2024
@mashb1t mashb1t closed this as completed Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
5 participants