Repository: stable-diffusion-webui
Issue: [Feature Request]: Config files for training
Labels: enhancement

### Is there an existing issue for this?

- [X] I have searched the existing issues and checked the recent builds/commits

### What would your feature do ?

The preparation _before_ training starts can be a big headache. There are a ton of variables involved in the process from the number of images, the content of each, their descriptions, the learning rate, the save rate, total steps, prompt template, sampling method, and a few more things I've never dared to touch. And sometimes after I finish a training session I might want to start over but with slightly different inputs.

The "settings.json" files that get saved before a run are definitely helpful, but they don't capture ALL the fine details about the training session. It has `data_root` but it's a folder path. So now I can never alter that path or the contents of that folder if I want to know exactly what the inputs were (I'm up to like 14 training folders trying to get one subject to a satisfactory level). It lists `template_file` but again I can't ever move that file or alter it or I won't be able to reproduce that result again. On top of all of this, I can't simply point to one of the "settings.json" files and say "Run with these same settings". I need to go in and reset all the things in the UI.

I think the settings files should be expanded in a few ways to make them re-usable and more useful as snapshots.

1. Replace `data_root` with `training_data` (or make a new attribute for backwards compatibility) and make it a complex object similar to this:
```
"training_data": [
  { "path": "C:\data\img_001.png", "SHA1": "d97eca4ae353021f656e4f285f41f4dd2427662e" },
  { "path": "C:\data\img_006.png", "SHA1": "93187a7ccbee73a68545e4e9092237da45c584cd" }
]
```
3. Replace `template_file` with `template_prompts` (or make a new attribute) and make it a list of strings as such:
```
"template_prompts": [
  "a photo of [name]",
  "a rendering of [name]"
]
```
4. If the old attributes are kept, replace their values with `null` to indicate that input should come from the new attributes instead of a file/folder.

I included the SHA1 for the images so there could be a pre-training check that the files haven't been altered (users could replace the SHA1 value with an empty string to skip the check for that file).

If these changes are made then users would be able to share their "settings.json" files to assist others with their training strategies, users could tweak `template_prompts` instead of making one more template text file or editing the existing template file and losing the historical context, and users could tweak the `training_data` list in settings instead of making another folder with mostly duplicate images.

### Proposed workflow

1. Do normal preparation of training data/images and creation of the embedding or hypernetwork.
2. Open a template `training_settings.json` file, download an example from the web, or make a copy of a "settings.json" snapshot file from a previous run.
3. Edit the "settings.json" file as-needed for your new training session and give it some unique name.
4. Load AUTOMATIC1111 and go to the "Train" tab.
5. Select the embedding or hypernetwork you want to train.
6. Provide the path to your new, unique "settings.json" file.
    - Optionally, perform a pre-validation of the input file before the user starts training
    - Optionally, display a text summary of what the settings will be for this session (essentially what's going to go into the snapshot JSON file)
7. Click "Train Embedding"/"Train Hypernetwork" to start.

### Additional information

Example of what the training settings JSON file could look like in its entirety:
```json
{
    "datetime": "2023-01-23 22:30:37",
    "model_name": "v1-5-pruned",
    "model_hash": "e1441589a6",
    "num_of_dataset_images": null,
    "num_vectors_per_token": 2,
    "embedding_name": "teapot_01",
    "learn_rate": "0.001",
    "batch_size": 1,
    "gradient_step": 1,
    "data_root": null,
    "training_data": [
        {
            "path": "C:\\Users\\John\\Documents\\training_data\\subject_001\\teapot_001.png",
            "SHA1": "353fd1e2521b9fe2a456cd3ebb1c2177abfa79fe"
        },
        {
            "path": "C:\\Users\\John\\Documents\\training_data\\subject_001\\teapot_003.png",
            "SHA1": "e7c44bc6e01f391826d668889eb580de979732de"
        },
        {
            "path": "C:\\Users\\John\\Documents\\training_data\\subject_001\\teapot_004.png",
            "SHA1": "eae1e872f84655c086326bea279a7dcc2aa731e8"
        }
    ],
    "log_directory": "textual_inversion",
    "training_width": 512,
    "training_height": 512,
    "steps": 5000,
    "clip_grad_mode": "disabled",
    "clip_grad_value": "0.1",
    "latent_sampling_method": "deterministic",
    "create_image_every": 50,
    "save_embedding_every": 50,
    "save_image_with_stored_embedding": true,
    "template_file": null,
    "template_prompts": [
        "a photo of a [name]",
        "a rendering of a [name]",
        "a cropped photo of the [name]",
        "the photo of a [name]",
        "a photo of a clean [name]",
        "a photo of a dirty [name]",
        "a dark photo of the [name]"
    ],
    "initial_step": 0
}
```
`datetime` would effectively be ignored since it serves no purpose as a "setting".

`num_of_dataset_images` could be removed entirely, use `null` to say ignore this attribute, or a fixed value (e.g. 5) that will cause an error if the list of files does not match.

`data_root` could be removed entirely, set to `null` to say ignore this and use the file list, or it could be a path (as usual) _instead_ of listing each file under `training_data`. I would still like to see the snapshot list each individual file like above.

`log_directory` could be tricky since the auto folder creation is good and requiring the user to enter it every time seems like a step backwards. Maybe add one more boolean attribute (`log_directory_append_metadata`) to add the date and embedding name after whatever is already provided?

Same rules with `template_file` as for `data_root`. Use file or prompt list but not both.

Not sure if it's necessary but I set `initial_step` as zero to denote that this should be a fresh run. Generate an error if the embedding has already been through some runs (probably preferably to accidentally clobbering an embedding).