Commit Graph

483 Commits

Author SHA1 Message Date
Lincoln Stein
3ae8daedaa
Merge branch 'main' into i18n-build-mode 2023-03-29 22:26:17 -04:00
Lincoln Stein
e11c1d66ab handle multiple tokens and embeddings in single file 2023-03-29 22:05:06 -04:00
Lincoln Stein
3c4b6d5735
Merge branch 'main' into enhance/heuristic-import-improvements 2023-03-29 16:54:43 -04:00
Mary Hipp Rogers
e6123eac19
Merge branch 'main' into i18n-build-mode 2023-03-29 05:33:14 -07:00
Lincoln Stein
9a7580dedd fix bugs in online ckpt conversion of 2.0 models
This commit fixes bugs related to the on-the-fly conversion and loading of
legacy checkpoint models built on SD-2.0 base.

- When legacy checkpoints built on SD-2.0 models were converted
  on-the-fly using --ckpt_convert, generation would crash with a
  precision incompatibility error.
2023-03-28 00:17:20 -04:00
Lincoln Stein
019a9f0329 address change requests in PR
1. Prompt has changed to "invoke> ".
2. Function to initialize the autocompleter has been renamed "set_autocompleter()"
2023-03-27 12:20:24 -04:00
Lincoln Stein
fe5d9ad171 improve importation and conversion of legacy checkpoint files
A long-standing issue with importing legacy checkpoints (both ckpt and
safetensors) is that the user has to identify the correct config file,
either by providing its path or by selecting which type of model the
checkpoint is (e.g. "v1 inpainting"). In addition, some users wish to
provide custom VAEs for use with the model. Currently this is done in
the WebUI by importing the model, editing it, and then typing in the
path to the VAE.

To improve the user experience, the model manager's
`heuristic_import()` method has been enhanced as follows:

1. When initially called, the caller can pass a config file path, in
which case it will be used.

2. If no config file provided, the method looks for a .yaml file in the
same directory as the model which bears the same basename. e.g.
```
   my-new-model.safetensors
   my-new-model.yaml
```
   The yaml file is then used as the configuration file for
   importation and conversion.

3. If no such file is found, then the method opens up the checkpoint
   and probes it to determine whether it is V1, V1-inpaint or V2.
   If it is a V1 format, then the appropriate v1-inference.yaml config
   file is used. Unfortunately there are two V2 variants that cannot be
   distinguished by introspection.

4. If the probe algorithm is unable to determine the model type, then its
   last-ditch effort is to execute an optional callback function that can
   be provided by the caller. This callback, named `config_file_callback`
   receives the path to the legacy checkpoint and returns the path to the
   config file to use. The CLI uses to put up a multiple choice prompt to
   the user. The WebUI **could** use this to prompt the user to choose
   from a radio-button selection.

5. If the config file cannot be determined, then the import is abandoned.

The user can attach a custom VAE to the imported and converted model
by copying the desired VAE into the same directory as the file to be
imported, and giving it the same basename. E.g.:

```
    my-new-model.safetensors
    my-new-model.vae.pt
```

For this to work, the VAE must end with ".vae.pt", ".vae.ckpt", or
".vae.safetensors". The indicated VAE will be converted into diffusers
format and stored with the converted models file, so the ".pt" file
can be deleted after conversion.

No facility is currently provided to swap a diffusers VAE at import
time, but this can be done after the fact using the WebUI and CLI's
model editing functions.
2023-03-27 11:27:45 -04:00
Mary Hipp
dbc0093b31 Merge remote-tracking branch 'origin' into i18n-build-mode 2023-03-27 10:57:41 -04:00
Mary Hipp
92e512b8b6 add package mode option for i18next 2023-03-27 10:49:52 -04:00
Lincoln Stein
abe4dc8ac1 Add support for yet another textual inversion embedding format
- This PR adds support for embedding files that contain a single key
  "emb_params". The only example I know of this format is the
  "EasyNegative" embedding on HuggingFace, but there are certainly
  others.

- This PR also adds support for loading embedding files that have been
  saved in safetensors format.

- It also cleans up the code so that the logic of probing for and
  selecting the right format parser is clear.
2023-03-27 09:39:03 -04:00
Lincoln Stein
dc14701d20
Merge branch 'main' into feat/node-cli-autocompleter 2023-03-26 23:46:10 -04:00
blessedcoolant
3ba7e966b5
Merge branch 'main' into fix/ui/viewer-localisation 2023-03-26 20:35:12 +13:00
psychedelicious
a724038dc6 fix(ui): fix viewer tooltip localisation strings
fixes #2923
2023-03-26 17:43:00 +11:00
psychedelicious
4221cf7731 fix(nodes): fix schema generation for output classes
All output classes need to have their properties flagged as `required` for the schema generation to work as needed.
2023-03-26 17:20:10 +11:00
psychedelicious
c34ac91ff0 fix(nodes): fix cancel; fix callback for img2img, inpaint 2023-03-26 17:07:40 +11:00
psychedelicious
5fe38f7c88 fix(backend): simple typing fixes 2023-03-26 17:07:03 +11:00
Kyle Schouviller
bd7e515290 [nodes] Add cancelation to the API 2023-03-26 15:47:32 +11:00
Lincoln Stein
9348161600 add basic autocomplete functionality to node cli
- Commands, invocations and their parameters will now autocomplete
  using introspection.
- Two types of parameter *arguments* will also autocomplete:
  - --sampler_name  will autocomplete the scheduler name
  - --model will autocomplete the model name
- There don't seem to be commands for reading/writing image files yet, so
  path autocompletion is not implemented
2023-03-26 00:24:27 -04:00
Lincoln Stein
dac3c158a5 Merge branch 'main' into feat/preview_predicted_x0
- resolve conflicts with generate.py invocation
- remove unused symbols that pyflakes complains about
- add **untested** code for passing intermediate latent image to the
  step callback in the format expected.
2023-03-25 16:07:18 -04:00
Lincoln Stein
501924bc60 do not reexport PipelineIntermediateState 2023-03-25 13:57:09 -04:00
Lincoln Stein
d117251747 make step_callback work again in generate() call
This PR fixes #2951 and restores the step_callback argument in the
refactored generate() method. Note that this issue states that
"something is still wrong because steps and step are zero." However,
I think this is confusion over the call signature of the callback, which
since the diffusers merge has been `callback(state:PipelineIntermediateState)`

This is the test script that I used to determine that `step` is being passed
correctly:

```

from pathlib import Path
from invokeai.backend import ModelManager, PipelineIntermediateState
from invokeai.backend.globals import global_config_dir
from invokeai.backend.generator import Txt2Img

def my_callback(state:PipelineIntermediateState, total_steps:int):
    print(f'callback(step={state.step}/{total_steps})')

def main():
    manager = ModelManager(Path(global_config_dir()) / "models.yaml")
    model = manager.get_model('stable-diffusion-1.5')
    print ('=== TXT2IMG TEST ===')
    steps=30
    output = next(Txt2Img(model).generate(prompt='banana sushi',
                                          iterations=None,
                                          steps=steps,
                                          step_callback=lambda x: my_callback(x,steps)
                                          )
                  )
    print(f'image={output.image}, seed={output.seed}, steps={output.params.steps}')

if __name__=='__main__':
    main()
```
2023-03-25 13:57:09 -04:00
Lincoln Stein
5ac0316c62 fix issue with embeddings being loaded twice
- as noted by JPPhoto
2023-03-25 10:45:03 -04:00
Lincoln Stein
9ceec40b76
Merge branch 'main' into feat/use-custom-vaes 2023-03-24 17:45:02 -04:00
Lincoln Stein
85b2822f5e
Merge branch 'main' into security/scan-ckpt-files-main 2023-03-24 08:39:59 -04:00
Tom
2b127b73ac
translationBot(ui): update translation (French)
Currently translated at 82.7% (417 of 504 strings)

Co-authored-by: Tom <tom.fouthier@gmail.com>
Translate-URL: https://hosted.weblate.org/projects/invokeai/web-ui/fr/
Translation: InvokeAI/Web UI
2023-03-24 04:49:27 +01:00
gallegonovato
8855902cfe
translationBot(ui): update translation (Spanish)
Currently translated at 100.0% (504 of 504 strings)

translationBot(ui): update translation (Spanish)

Currently translated at 100.0% (501 of 501 strings)

Co-authored-by: gallegonovato <fran-carro@hotmail.es>
Translate-URL: https://hosted.weblate.org/projects/invokeai/web-ui/es/
Translation: InvokeAI/Web UI
2023-03-24 04:49:27 +01:00
Hosted Weblate
9d8ddc6a08
translationBot(ui): update translation files
Updated by "Cleanup translation files" hook in Weblate.

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Translate-URL: https://hosted.weblate.org/projects/invokeai/web-ui/
Translation: InvokeAI/Web UI
2023-03-24 04:49:27 +01:00
Riccardo Giovanetti
4ca5189e73
translationBot(ui): update translation (Italian)
Currently translated at 100.0% (504 of 504 strings)

translationBot(ui): update translation (Italian)

Currently translated at 100.0% (501 of 501 strings)

translationBot(ui): update translation (Italian)

Currently translated at 100.0% (500 of 500 strings)

Co-authored-by: Riccardo Giovanetti <riccardo.giovanetti@gmail.com>
Translate-URL: https://hosted.weblate.org/projects/invokeai/web-ui/it/
Translation: InvokeAI/Web UI
2023-03-24 04:49:27 +01:00
Lincoln Stein
6e7dbf99f3
Merge branch 'main' into bugfix/dreambooth_ema 2023-03-23 23:24:15 -04:00
Lincoln Stein
deeff36e16
Merge branch 'main' into security/scan-ckpt-files-main 2023-03-23 23:20:52 -04:00
Lincoln Stein
92721a1d45 do not reexport PipelineIntermediateState 2023-03-24 09:32:47 +11:00
Lincoln Stein
f329fddab9 make step_callback work again in generate() call
This PR fixes #2951 and restores the step_callback argument in the
refactored generate() method. Note that this issue states that
"something is still wrong because steps and step are zero." However,
I think this is confusion over the call signature of the callback, which
since the diffusers merge has been `callback(state:PipelineIntermediateState)`

This is the test script that I used to determine that `step` is being passed
correctly:

```

from pathlib import Path
from invokeai.backend import ModelManager, PipelineIntermediateState
from invokeai.backend.globals import global_config_dir
from invokeai.backend.generator import Txt2Img

def my_callback(state:PipelineIntermediateState, total_steps:int):
    print(f'callback(step={state.step}/{total_steps})')

def main():
    manager = ModelManager(Path(global_config_dir()) / "models.yaml")
    model = manager.get_model('stable-diffusion-1.5')
    print ('=== TXT2IMG TEST ===')
    steps=30
    output = next(Txt2Img(model).generate(prompt='banana sushi',
                                          iterations=None,
                                          steps=steps,
                                          step_callback=lambda x: my_callback(x,steps)
                                          )
                  )
    print(f'image={output.image}, seed={output.seed}, steps={output.params.steps}')

if __name__=='__main__':
    main()
```
2023-03-24 09:32:47 +11:00
Lincoln Stein
f751dcd245 load embeddings after a ckpt legacy model is converted to diffusers
- Fixes #2954
- Also improves diagnostic reporting during embedding loading.
2023-03-23 15:21:58 -04:00
Lincoln Stein
a97107bd90 handle VAEs that do not have a "state_dict" key 2023-03-23 15:11:29 -04:00
Lincoln Stein
b2ce45a417 re-implement model scanning when loading legacy checkpoint files
- This PR turns on pickle scanning before a legacy checkpoint file
  is loaded from disk within the checkpoint_to_diffusers module.

- Also miscellaneous diagnostic message cleanup.
2023-03-23 15:03:30 -04:00
Lincoln Stein
4e0b5d85ba convert custom VAEs into diffusers
- When a legacy checkpoint model is loaded via --convert_ckpt and its
  models.yaml stanza refers to a custom VAE path (using the 'vae:'
  key), the custom VAE will be converted and used within the diffusers
  model. Otherwise the VAE contained within the legacy model will be
  used.

- Note that the heuristic_import() method, which imports arbitrary
  legacy files on disk and URLs, will continue to default to the
  the standard stabilityai/sd-vae-ft-mse VAE. This can be fixed after
  the fact by editing the models.yaml stanza using the Web or CLI
  UIs.

- Fixes issue #2917
2023-03-23 13:14:19 -04:00
Lincoln Stein
a958ae5e29 Merge branch 'main' into feat/use-custom-vaes 2023-03-23 10:32:56 -04:00
Mary Hipp Rogers
1b215059e7
Merge branch 'main' into export-more-for-header 2023-03-21 16:29:53 -04:00
Mary Hipp
db079a2733 remove unneeded build:package code 2023-03-21 10:29:27 -04:00
Mary Hipp
26f71d3536 change back 2023-03-21 10:28:29 -04:00
Mary Hipp
eb7ae2588c unused var 2023-03-21 10:21:58 -04:00
Mary Hipp
278c14ba2e try jsx.element 2023-03-21 10:18:38 -04:00
Mary Hipp
74e83dda54 update type 2023-03-21 10:10:48 -04:00
psychedelicious
1f0324102a chore(ui): build 2023-03-19 23:16:29 +11:00
psychedelicious
a782ad092d feat(ui): localise iaialertdialog defaults 2023-03-19 23:16:29 +11:00
psychedelicious
eae4eb419a fix(ui): popovers trigger on click (accessibility) 2023-03-19 23:16:29 +11:00
psychedelicious
fb7f38f46e fix(ui): make alertdialogs centered 2023-03-19 23:16:29 +11:00
psychedelicious
93d0cae455 fix(ui): fix alertdialogs closing immediately 2023-03-19 23:16:29 +11:00
psychedelicious
35f6b5d562 fix(ui): make invoketabs not lazy 2023-03-19 23:16:29 +11:00
blessedcoolant
2aefa06ef1 fix(ui): Clean up manual add forms 2023-03-19 23:16:29 +11:00
psychedelicious
5906888477 feat(ui): add current image loading fallback 2023-03-19 23:16:29 +11:00
psychedelicious
f22c7d0da6 feat(ui): add more w/h options 2023-03-19 23:16:29 +11:00
psychedelicious
93b38707b2 feat(ui): tidy up model manager styling
fixes #2970
2023-03-19 23:16:29 +11:00
blessedcoolant
6ecf53078f fix(ui): Misalignment of model search entries 2023-03-19 23:16:29 +11:00
psychedelicious
67f8f222d9 fix(nodes): fix step_callback + fast latents generation
this depends on the small change in #2957
2023-03-16 20:03:08 +11:00
psychedelicious
5347c12fed fix(nodes): fix schema gen for GraphExecutionState 2023-03-16 20:03:08 +11:00
psychedelicious
b194180f76 feat(backend): make fast latents method static 2023-03-16 20:03:08 +11:00
psychedelicious
fb30b7d17a feat(backend): add image_to_dataURL util 2023-03-16 20:03:08 +11:00
Mary Hipp
c2922d5991 add settingsmodal 2023-03-15 16:12:51 -04:00
Mary Hipp
85888030c3 more things needed for header 2023-03-15 14:38:22 -04:00
Kyle Schouviller
3021c78390 [nodes] Add Edge data type 2023-03-14 23:09:30 -07:00
Mary Hipp
fa9afec0c2 fix npm deps 2023-03-14 14:15:03 -04:00
Mary Hipp
d6862bf8c1 fix npm deps 2023-03-14 14:14:16 -04:00
Mary Hipp
de01c38bbe fresh build 2023-03-14 14:11:42 -04:00
Mary Hipp
7e811908e0 remove 2023-03-14 14:09:16 -04:00
Mary Hipp
5f59f24f92 cleanup 2023-03-14 14:08:42 -04:00
Mary Hipp
e414fcf3fb bump version 2023-03-14 13:26:49 -04:00
Mary Hipp
079ad8f35a fix props 2023-03-14 13:22:57 -04:00
Mary Hipp
a4d7e0c78e export other components 2023-03-14 12:37:28 -04:00
Jonathan
44f489d581
Merge branch 'main' into fix-seampaint 2023-03-14 06:19:25 -05:00
blessedcoolant
0a761d7c43 fix(inpaint): Seam painting being broken 2023-03-15 00:00:08 +13:00
Damian Stewart
a0f47aa72e
Merge branch 'main' into main 2023-03-14 11:41:29 +01:00
Lincoln Stein
d840c597b5 fix --png_compression command line argument
- The value of png_compression was always 6, despite the value provided to the
  --png_compression argument. This fixes the bug.
- It also fixes an inconsistency between the maximum range of png_compression
  and the help text.

- Closes #2945
2023-03-14 00:24:05 -04:00
Lincoln Stein
3ca654d256 speculative fix for alternative vaes 2023-03-13 23:27:29 -04:00
jeremy
e0e01f6c50 Reduced Pickle ACE attack surface
Prior to this commit, all models would be loaded with the extremely unsafe `torch.load` method, except those with the exact extension `.safetensors`. Even a change in casing (eg. `saFetensors`, `Safetensors`, etc) would cause the file to be loaded with torch.load instead of the much safer `safetensors.toch.load_file`.
If a malicious actor renamed an infected `.ckpt` to something like `.SafeTensors` or `.SAFETENSORS` an unsuspecting user would think they are loading a safe .safetensor, but would in fact be parsing an unsafe pickle file, and executing an attacker's payload. This commit fixes this vulnerability by reversing the loading-method decision logic to only use the unsafe `torch.load` when the file extension is exactly `.ckpt`.
2023-03-13 16:16:30 -04:00
blessedcoolant
1b01161ea4 Merge branch 'main' into pr/2904 2023-03-14 03:14:35 +13:00
Mary Hipp Rogers
9e0c7c46a2
Merge branch 'main' into add-a-build-config 2023-03-13 09:58:17 -04:00
Mary Hipp
be305588d3 merged and rebuilt 2023-03-13 09:55:56 -04:00
blessedcoolant
9f994df814
Merge branch 'main' into chore/UI_more-accessibility-items 2023-03-14 02:49:47 +13:00
JPPhoto
596ba754b1 Removed seed from get_make_image. 2023-03-13 08:15:46 -05:00
JPPhoto
b980e563b9 Fix bug #2931 2023-03-13 08:11:09 -05:00
Kyle Schouviller
0c3b1fe3c4 [nodes] Fixes calls into image to image and inpaint from nodes 2023-03-12 22:12:42 -07:00
ElrikUnderlake
c9ee2e351c
yarn build 2023-03-12 23:29:29 -05:00
ElrikUnderlake
e3aef20f42
chore(UI, accessibility): more items
- radio icon buttons
- links should be parent of icon
styled links to still line up with sibling components
2023-03-12 23:27:47 -05:00
Kevin Turner
288cee9611 Merge remote-tracking branch 'origin/main' into feat/preview_predicted_x0
# Conflicts:
#	invokeai/app/invocations/generate.py
2023-03-12 20:56:02 -07:00
Kyle Schouviller
24aca37538 Just set output value in node schemas. Don't use additionalProperties, which would impact the schema. 2023-03-12 20:40:29 -07:00
Kyle Schouviller
b853ceea65 [nodes-api] Fix API generation to correctly reference outputs 2023-03-12 20:03:26 -07:00
Kyle Schouviller
3ee2798ede [fix] Get the model again if current model is empty 2023-03-12 22:26:11 -04:00
Fabio 'MrWHO' Torchetti
5c5106c14a Add keys when non EMA 2023-03-12 16:22:22 -05:00
Fabio 'MrWHO' Torchetti
c367b21c71 Fix issue #2932 2023-03-12 15:40:33 -05:00
psychedelicious
300aa8d86c chore(ui): build 2023-03-12 20:13:58 +11:00
psychedelicious
727f1638d7 chore(ui): lint 2023-03-12 20:13:58 +11:00
psychedelicious
ee6df5852a fix(ui): fix lightbox 2023-03-12 20:13:38 +11:00
psychedelicious
90525b1c43 fix(ui): fix scrollable shadow 2023-03-12 20:13:38 +11:00
psychedelicious
bbb95dbc5b fix(ui): add color mode watcher 2023-03-12 20:13:38 +11:00
psychedelicious
f4b7f80d59 fix(ui): remove key prop 2023-03-12 20:13:38 +11:00
blessedcoolant
220f7373c8 feat(ui): Basic IAIOption Component & Fix Select Dropdown 2023-03-12 20:13:38 +11:00
blessedcoolant
4bb5785f29 fix(ui): Move Form Components to the correct folder 2023-03-12 20:13:38 +11:00
psychedelicious
f9a7a7d161 fix(ui): set colorMode to fix native selects 2023-03-12 20:13:38 +11:00
psychedelicious
de94c780d9 fix(ui): fix canvas status text bg 2023-03-12 20:13:38 +11:00