mrhan1993 / FooocusAPI

Fooocus with fastapi
https://mrhan1993.github.io/docs
GNU General Public License v3.0
21 stars 6 forks source link

[Feature Request]: date_string in filename optional #29

Closed kickin6 closed 3 months ago

kickin6 commented 4 months ago

Is there an existing issue for this?

What would your feature do?

Make the date_string in the filename optional.

https://github.com/mrhan1993/FooocusAPI/blob/2c19778064a36848cd5309894fcd4076c6c7b249/apis/utils/file_utils.py#L76-L69

My use case: I need to group output files by customer api-key /outputs/images/{api-key}/files... which makes it easier to put a front-end to list their files without having to scan all /outputs/date_string/{api-key}/ directories.

In my frontend app, after api-key validation, I set the save_name parameter to the api_key:

data["save_name"] = f"images/{api_key}"

Proposed workflow

I propose a new environment variable os.environ["FILENAME_WITH_DATE"] or similar.

date_string = current_time.strftime("%Y-%m-%d") if os.environ["FILENAME_WITH_DATE"] else ""
filename = os.path.join(date_string, f"{image_name}.{extension}")

Additional information

No response

mrhan1993 commented 4 months ago

I know what you need, but function save_output_file is useless. save output is here, and function is here. I do not want modify the code of Fooocus, so i change file name after generate finish here, I can meet your needs, but I'm still designing a more reasonable way.

mrhan1993 commented 4 months ago

I pushed a commit in v2.5 branch, you can set save_name='../{api-key}/filename', it will return http://127.0.0.1:7866/outputs/{api-key}/filename-{seq}.{output_format}, seq is used for multi image in one generate, from 0.

kickin6 commented 3 months ago

Thanks!