Fooocus-API icon indicating copy to clipboard operation
Fooocus-API copied to clipboard

"path_outputs" in config.txt is ignored

Open thiner opened this issue 1 year ago • 4 comments

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

thiner avatar Jul 29 '24 05:07 thiner

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

mrhan1993 avatar Aug 02 '24 17:08 mrhan1993

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.

daedon avatar Aug 24 '24 07:08 daedon

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.

thiner avatar Aug 27 '24 02:08 thiner

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.

antonkoenig avatar Aug 28 '24 19:08 antonkoenig