Fooocus icon indicating copy to clipboard operation
Fooocus copied to clipboard

Image save filename consistency

Open flashthepublic opened this issue 1 year ago • 6 comments

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

flashthepublic avatar Dec 15 '23 08:12 flashthepublic

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 avatar Dec 29 '23 00:12 mashb1t

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

mJastrzebski6 avatar Dec 30 '23 21:12 mJastrzebski6

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

mashb1t avatar Dec 30 '23 22:12 mashb1t

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

flashthepublic avatar Jan 01 '24 10:01 flashthepublic

@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?

mashb1t avatar Jan 01 '24 10:01 mashb1t

@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

flashthepublic avatar Jan 01 '24 10:01 flashthepublic

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

mashb1t avatar Jan 02 '24 22:01 mashb1t

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 https://github.com/lllyasviel/Fooocus/issues/1425)

mashb1t avatar Jan 02 '24 22:01 mashb1t

@flashthepublic @mJastrzebski6 bump

mashb1t avatar Jan 08 '24 22:01 mashb1t

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

flashthepublic avatar Jan 08 '24 22:01 flashthepublic

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?

mashb1t avatar Jan 08 '24 22:01 mashb1t

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".

machineminded avatar Jan 10 '24 18:01 machineminded

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

mJastrzebski6 avatar Jan 11 '24 23:01 mJastrzebski6

Still not able to reproduce this behavior... Also see https://github.com/lllyasviel/Fooocus/discussions/1798. Any help would be appreciated!

mashb1t avatar Jan 14 '24 11:01 mashb1t

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 avatar Jan 14 '24 12:01 mashb1t

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

eddyizm avatar Jan 14 '24 17:01 eddyizm

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 avatar Jan 14 '24 18:01 machineminded

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?

machineminded avatar Jan 14 '24 18:01 machineminded

@machineminded https://github.com/lllyasviel/Fooocus/blob/main/modules/private_logger.py#L27

I'm working on the implementation.

mashb1t avatar Jan 14 '24 18:01 mashb1t

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.

eddyizm avatar Jan 14 '24 18:01 eddyizm

You can find the implementation in https://github.com/lllyasviel/Fooocus/pull/1932#issue-2080864810. ~~It's not yet perfect and might be optimized (if even possible), see PR description.~~

mashb1t avatar Jan 14 '24 19:01 mashb1t