mrhan1993 / Fooocus-API

FastAPI powered API for Fooocus
GNU General Public License v3.0
567 stars 152 forks source link

"path_outputs" in config.txt is ignored #386

Open thiner opened 2 months ago

thiner commented 2 months ago

path_outputs is introduced in config.txt for storing generated images. But Fooocus-API ignores the setting, outputs images to a hard-coded folder output_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '../..', 'outputs', 'files')) in file_utils.py. I think it's important to expose the configuration of path_outputs to users, especially for API running in Docker container. My workaround to solve the problem:

output_dir_var = os.environ.get('OUTPUT_DIR', "/tmp")
output_dir = os.path.abspath(os.path.join(output_dir_var, 'files'))

Developer can customize the output path by set an environment variable, e.g. export OUTPUT_DIR=/tmp/fooocus-imgs

mrhan1993 commented 2 months ago

Okay, this is a headache inducing question. I will try to improve this.

daedon commented 1 month ago

In config.py:

 if not os.path.exists('user_path_config.txt'):
        return

This should always return since "user_path_config.txt" doesn't exist. Saving "config.txt" to "user_path_config.txt" results in:

Processing deprecated config failed

Oddly, one day logs and images were written to path_outputs.

thiner commented 1 month ago

In config.py:

 if not os.path.exists('user_path_config.txt'):
        return

This should always return since "user_path_config.txt" doesn't exist. Saving "config.txt" to "user_path_config.txt" results in:

Processing deprecated config failed

Oddly, one day logs and images were written to path_outputs.

config.py actually is cloned from Fooocus project. If you just want to run Fooocus, the user_path configuration is working fine. The problem here is that Fooocus-API is not aware the setting of config.py in Fooocus. I think the easiest way would be setup a new environment variable to do so.

antonkoenig commented 1 month ago

The settings from config.txt still work. It still generates the file in the path_outputs directory, but then the file will be moved. You can copy the file instead of moving the file. Then both, the API and the log work without confusion. Files from the API directory can be cleared later. I want to keep the files in the log.