InvokeAI icon indicating copy to clipboard operation
InvokeAI copied to clipboard

add an argument that lets user specify folders to scan for weights

Open lstein opened this issue 2 years ago • 7 comments

This PR adds a --weight_folders argument to invoke.py. Using argparse, it adds a "weight_folders" attribute to the Args object. It is intended to support @blessedcoolant 's weight file autoscan feature, and can be used like this:

'''test.py'''
from ldm.invoke.args import Args

args = Args().parse_args()
for folder in args.weight_folders:
    print(folder)

Example output:

python test.py --weight_folders /tmp/weights /home/fred/invokeai/weights "./my folder with spaces/weight files"
/tmp/weights
/home/fred/invokeai/weights
./my folder with spaces/weight files

lstein avatar Dec 13 '22 20:12 lstein

Would it be possible to have these stored in a config file along with models.yaml? Maybe call iit model_dirs.yaml or so .. and the ability to read and write to it. This way we can store the user directories and the user can avoid passing them each time.

Thanks for the updates so far.

blessedcoolant avatar Dec 13 '22 21:12 blessedcoolant

Great enhancement, thank you. We may also want to introduce an INVOKEAI_WEIGHTS_DIR env var to mirror the CLI flag, but that can be a separate feature.

Would it be possible to have these stored in a config file along with models.yaml

@blessedcoolant yes, i think this is once again bringing up the need to unify the config file instead of having several config files. We've briefly discussed this a few times both in Github and discord. Let me write that up in an issue.

ebr avatar Dec 13 '22 22:12 ebr

I approved the PR as-is, because it accomplishes the task, but can I suggest that we rename the flag to --weight_dirs instead of folders? 1) more precise cross-platform terminology, 2) we already have --root_dir, and 3) less characters to type.

ebr avatar Dec 13 '22 22:12 ebr

I approved the PR as-is, because it accomplishes the task, but can I suggest that we rename the flag to --weight_dirs instead of folders? 1) more precise cross-platform terminology, 2) we already have --root_dir, and 3) less characters to type.

You should not do this, we enabled auto-merge today. So if you approve a PR with auto merge enabled, it will obviously be too late to suggest/request changes ;)

mauwii avatar Dec 13 '22 22:12 mauwii

You should not do this, we enabled auto-merge today. So if you approve a PR with auto merge enabled, it will obviously be too late to suggest/request changes ;)

And that is exactly why auto-merge should not be the default setting. Sometimes more than one review is needed for consensus. We've discussed this in Discord.

ebr avatar Dec 13 '22 23:12 ebr

Would it be possible to have these stored in a config file along with models.yaml? Maybe call iit model_dirs.yaml or so .. and the ability to read and write to it. This way we can store the user directories and the user can avoid passing them each time.

Thanks for the updates so far.

This is what you can use the invokeai/invokeai.init file for. Just put the (renamed) argument in there as you would use it on the command line. Not sure if we want to have a new environment variable to mirror all the individual command-line arguments, but I think we could easily have a single INVOKEAI_ARGS environment variable that contains all the user's favorite command-line arguments.

I'll change the name of the argument now.

lstein avatar Dec 14 '22 21:12 lstein

I approved the PR as-is, because it accomplishes the task, but can I suggest that we rename the flag to --weight_dirs instead of folders? 1) more precise cross-platform terminology, 2) we already have --root_dir, and 3) less characters to type.

You should not do this, we enabled auto-merge today. So if you approve a PR with auto merge enabled, it will obviously be too late to suggest/request changes ;)

The requester should not enable auto-merge. It should be done by the last reviewer as something that happens after the CI checks complete. Let's discuss this some more on Discord.

lstein avatar Dec 14 '22 21:12 lstein