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

clean up gradio temp files #1924

Closed
hswlab opened this issue Jan 14, 2024 · 4 comments
Closed

clean up gradio temp files #1924

hswlab opened this issue Jan 14, 2024 · 4 comments
Labels
enhancement New feature or request question Further information is requested

Comments

@hswlab
Copy link
Contributor

hswlab commented Jan 14, 2024

Is your feature request related to a problem? Please describe.
I have noticed that the user interface also stores images in the ...\AppData\Local\Temp\gradio folder in addition to the Output folder. A lot of junk data accumulates there over time.

Describe the idea you'd like
Is it possible that the temporary data is emptied after the image is created or that you can at least specify a custom path in the settings file that is easier to access for a manual clean up?

@eddyizm
Copy link
Contributor

eddyizm commented Jan 14, 2024

@hswlab I think this is a OS thing, there's a ton of stuff that gets stored in temp if you use your computer a lot. checking mine it doesn't see like there is much but I tend to do weekly clean ups on my os. The outputs folder you can change that to your preferred location by updating the path in the config.txt file.

 [09:43]  eddyizm  ~
$ du -h AppData/Local/Temp/gradio/
0       AppData/Local/Temp/gradio/5d4d4a73540b9f44cc942466c44aa28b825242c1
0       AppData/Local/Temp/gradio/61e63f6acb5143c0ac1a2a630da880adc13b9fa9
0       AppData/Local/Temp/gradio/6368ac7336fbd1f2c5ad9bf589ff081bfed5f6af
0       AppData/Local/Temp/gradio/81447c3416325f610a8c5ebc35d1024f7a746c89
0       AppData/Local/Temp/gradio/bb01d9e06ab06e74c4befd031db121db2dc1c98e
0       AppData/Local/Temp/gradio/cbe968f3778826e2eabed6b81f27c0701121f1df
0       AppData/Local/Temp/gradio/e34df7a49b5584b871e07f7a889c39dbec868ee9
4.0K    AppData/Local/Temp/gradio/

@mashb1t
Copy link
Collaborator

mashb1t commented Jan 14, 2024

This heavily depends on the OS.

  • Windows: Start > Settings > System > Storage >Toggle on Storage sense
  • Linux: directory is cleared by default at every boot
  • MacOS: 30 days cleanup period by default for untouched files (depending on last accessed)

FYI there is an arg called --temp-path, which currently (or rather until #1932 is merged) does nothing as far as i can tell.

=> Fooocus should not mess with temp files of gradio, especially as also other gradio projects might be used on target system. There currently is no way of cleaning up or even accessing the paths of images yielded to gradio.

I'd propose to close this issue and reopen it as soon as Gradio supports setting a temp path, which Fooocus can then exclusively configure and use in its config. Is this fine for you?

@mashb1t mashb1t added enhancement New feature or request question Further information is requested labels Jan 14, 2024
@hswlab
Copy link
Contributor Author

hswlab commented Jan 15, 2024

Ok, this issue can be closed. Thanks for your answers :)

@hswlab hswlab closed this as completed Jan 15, 2024
@midareashi
Copy link
Contributor

midareashi commented Jan 18, 2024

This can be done quite easily. First you set the GRADIO_TEMP_DIR to another directory so you know it's only used for Fooocus. Then you run a cleanup to get rid of all the images in that folder. I added this in launch.py.

import shutil

os.environ['GRADIO_TEMP_DIR'] = "g:/temp"

def cleanup_temp(folder_path):
    try:
        shutil.rmtree(folder_path)

        print("All subfolders deleted successfully.")

    except Exception as e:
        print(f"Error: {e}")

cleanup_temp(os.environ['GRADIO_TEMP_DIR'])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants