Config-Presets icon indicating copy to clipboard operation
Config-Presets copied to clipboard

question: how to proper add custom config in not-persisted environment?

Open tresorama opened this issue 1 year ago • 8 comments

When using this extension in environment that are not persisted, like Google Colab, the user install by

git clone this-repo

then launching a1111, so that the extension create default config files at

/stable-diffusion-webui/extensions/Config-Presets/config-*.json

From this point I usually edit manually the config file (.json) adding my presets.

Which is the reccomended way to do the same in automated fashion ?

tresorama avatar Jan 01 '25 14:01 tresorama

I never use non-persistent environments like colab, but you should be able to save your config .json files from a previous session and copy them to the new environment.

Zyin055 avatar Jan 01 '25 16:01 Zyin055

Which path the extension look for config files ? Can we use multiple files for the same context (img2img,txt2img,...) ?

tresorama avatar Jan 01 '25 16:01 tresorama

extensions/config-presets

I don't understand the question. There are different files for txt2img and img2img.

Zyin055 avatar Jan 01 '25 16:01 Zyin055

Sorry, i rephrase.

When i git clone the repo inside a1111 extensions dir, the directory of the extension doesn't contains hardcoded files that contains presets.

I need to run a1111 at least once so that the extension create the default config files.

Said so...

  1. The extensions code "where" it looks in the file tree for config files before deciding if it's necessary to create config files with default presets or skip the creation and load them directly?
  2. Can the extension load multiple files for the same context (let's say img2img) and merge them at runtime? For example:
    • the extension create the default config files for img2img at Config-Presets/config-img2img.json
    • the extension looks for a user defined json file for img2img, let's say at Config-Preset/config-omg2img.user.json
    • at runtime the extension merge these two json files and populate the dropdoqn in the UI

tresorama avatar Jan 02 '25 16:01 tresorama

No, it cannot load and merge multiple configs for the same context. It can only use one file for each context.

Zyin055 avatar Jan 02 '25 17:01 Zyin055

Thanks, I don't know if i'm able to do it because I'm not so good at python, but do you accept PR for new features?

tresorama avatar Jan 02 '25 17:01 tresorama

I do accept PRs, however this is such a niche case and it'll introduce a decent amount of complexity to the code so it's not something that I'd likely merge in.

Zyin055 avatar Jan 02 '25 21:01 Zyin055

Ok! Thanks for being fair about it!

What if as a middle-ground... You add to the repo, as version controlled files, a copy of the default presets files (config-img2img.json,...) with a ".example" suffix.

This way:

  • the code you already have can be refactored changing only that the default files are created by reading these "example" files and creating new files. This means removing file content from python code variables (string) and moving the file contents to real files (config-img2img.json.example,...)
  • if user want to customize preset without launching the extension once it can copy the "example" file (config-img2img.json.example) to a new file "config-img2img.json" and then add new priprties to the json file
  • if the extension , at runtime , find that "config-img2img.json" is present, the extension skips the creation phase of file. I think this is the current behavior.

tresorama avatar Jan 02 '25 23:01 tresorama