Commit Graph

266 Commits

Author SHA1 Message Date
Damian Stewart
45e51bac9a
Fix #1599 by relaxing the match_trigger regex (#1601)
* Fix #1599 by relaxing the `match_trigger` regex

Also simplify logic and reduce duplication.

* restrict trigger regex again (but not so far)
2022-11-28 17:58:52 -05:00
Lincoln Stein
a514f9b236
add a --no-patchmatch option to disable patchmatch loading (#1598)
This feature was added to prevent the CI Macintosh tests from erroring
out when patchmatch is unable to retrieve its shared library from
github assets.
2022-11-28 16:29:52 -05:00
Damian Stewart
bc44ab786c
Bug Fix: Model import fixes (#1566)
These bug fixes address issues #1546 and #1547 .
2022-11-28 21:46:27 +01:00
Lincoln Stein
84cd96decf set readline root to ROOTDIR for model import 2022-11-28 18:34:42 +00:00
Lincoln Stein
a3121b8137 !model_import autocompletes in ROOTDIR 2022-11-28 17:44:32 +00:00
Lincoln Stein
81cb7fd1b7
Merge branch 'development' into model-import-fixes 2022-11-28 09:28:14 -05:00
devops117
7c658c6d76
model_cache.py: fix list_models
Signed-off-by: devops117 <55235206+devops117@users.noreply.github.com>
2022-11-28 19:20:38 +05:30
DevOps117
495104e941
Merge branch 'invoke-ai:development' into development 2022-11-28 19:14:31 +05:30
Lincoln Stein
1e1f871ee1
Embedding merging (#1526)
* add whole <style token> to vocab for concept library embeddings

* add ability to load multiple concept .bin files

* make --log_tokenization respect custom tokens

* start working on concept downloading system

* preliminary support for dynamic loading and merging of multiple embedded models

- The embedding_manager is now enhanced with ldm.invoke.concepts_lib,
  which handles dynamic downloading and caching of embedded models from
  the Hugging Face concepts library (https://huggingface.co/sd-concepts-library)

- Downloading of a embedded model is triggered by the presence of one or more
  <concept> tags in the prompt.

- Once the embedded model is downloaded, its trigger phrase will be loaded
  into the embedding manager and the prompt's <concept> tag will be replaced
  with the <trigger_phrase>

- The downloaded model stays on disk for fast loading later.

- The CLI autocomplete will complete partial <concept> tags for you. Type a
  '<' and hit tab to get all ~700 concepts.

BUGS AND LIMITATIONS:

- MODEL NAME VS TRIGGER PHRASE

  You must use the name of the concept embed model from the SD
  library, and not the trigger phrase itself. Usually these are the
  same, but not always. For example, the model named "hoi4-leaders"
  corresponds to the trigger "<HOI4-Leader>"

  One reason for this design choice is that there is no apparent
  constraint on the uniqueness of the trigger phrases and one trigger
  phrase may map onto multiple models. So we use the model name
  instead.

  The second reason is that there is no way I know of to search
  Hugging Face for models with certain trigger phrases. So we'd have
  to download all 700 models to index the phrases.

  The problem this presents is that this may confuse users, who will
  want to reuse prompts from distributions that use the trigger phrase
  directly. Usually this will work, but not always.

- WON'T WORK ON A FIREWALLED SYSTEM

  If the host running IAI has no internet connection, it can't
  download the concept libraries. I will add a script that allows
  users to preload a list of concept models.

- BUG IN PROMPT REPLACEMENT WHEN MODEL NOT FOUND

  There's a small bug that occurs when the user provides an invalid
  model name. The <concept> gets replaced with <None> in the prompt.

* fix loading .pt embeddings; allow multi-vector embeddings; warn on dupes

* simplify replacement logic and remove cuda assumption

* download list of concepts from hugging face

* remove misleading customization of '*' placeholder

the existing code as-is did not do anything; unclear what it was supposed to do.

the obvious alternative -- setting using 'placeholder_strings' instead of
'placeholder_tokens' to match model.params.personalization_config.params.placeholder_strings --
caused a crash. i think this is because the passed string also needed to be handed over
on init of the PersonalizedBase as the 'placeholder_token' argument.
this is weird config dict magic and i don't want to touch it. put a
breakpoint in personalzied.py line 116 (top of PersonalizedBase.__init__) if
you want to have a crack at it yourself.

* address all the issues raised by damian0815 in review of PR #1526

* actually resize the token_embeddings

* multiple improvements to the concept loader based on code reviews

1. Activated the --embedding_directory option (alias --embedding_path)
   to load a single embedding or an entire directory of embeddings at
   startup time.

2. Can turn off automatic loading of embeddings using --no-embeddings.

3. Embedding checkpoints are scanned with the pickle scanner.

4. More informative error messages when a concept can't be loaded due
   either to a 404 not found error or a network error.

* autocomplete terms end with ">" now

* fix startup error and network unreachable

1. If the .invokeai file does not contain the --root and --outdir options,
  invoke.py will now fix it.

2. Catch and handle network problems when downloading hugging face textual
   inversion concepts.

* fix misformatted error string

Co-authored-by: Damian Stewart <d@damianstewart.com>
2022-11-28 02:40:24 -05:00
Kyle Schouviller
9f02595ef2 Fixes outpainting with resized inpaint size 2022-11-27 22:24:15 +13:00
Lincoln Stein
74487a95a9
Merge branch 'development' into model-import-fixes 2022-11-26 16:54:21 -05:00
Lincoln Stein
7f3ba16cd2 Revert "make the docstring more readable and improve the list_models logic"
This reverts commit 248068fe5d.
2022-11-26 13:38:20 -05:00
Lincoln Stein
7a0438586c
Merge branch 'development' into model-import-fixes 2022-11-26 10:18:49 -05:00
Lincoln Stein
9adaf8f8ad prevent "!switch state gets confused if model switching fails"
- If !switch were to fail on a particular model, then generate got
  confused and wouldn't try again until you switch to a different working
  model and back again.

- This commit fixes and closes #1547
2022-11-26 15:15:10 +00:00
Lincoln Stein
a341297b0c stop crash on !import_models call on model inside rootdir
- addresses bug report #1546
2022-11-26 14:58:22 +00:00
psychedelicious
b93336dbf9 Bug fix for inpaint size 2022-11-27 03:35:49 +13:00
psychedelicious
9fe9301762 Add inpaint size options to inpaint at a larger size than the actual inpaint image, then scale back down for recombination 2022-11-27 03:35:49 +13:00
javl
87439feeb2 Add arguments to use SSL to webserver 2022-11-27 03:35:49 +13:00
Kyle Schouviller
98e3bbb3bd Add patchmatch and infill_method parameter to prompt2image (options are 'patchmatch' or 'tile'). 2022-11-27 03:35:49 +13:00
Kyle Schouviller
b049bbc64e Fix iterative outpainting by restoring original images 2022-11-27 03:35:49 +13:00
Kyle Schouviller
34395ff490 Fixes crashes during iterative outpaint. Still doesn't work correctly though. 2022-11-27 03:35:49 +13:00
psychedelicious
6c7191712f Rebases against development 2022-11-27 03:35:49 +13:00
devops117
248068fe5d make the docstring more readable and improve the list_models logic
Signed-off-by: devops117 <55235206+devops117@users.noreply.github.com>
2022-11-26 08:49:41 -05:00
devops117
c76badfb08
make the docstring more readable and improve the list_models logic
Signed-off-by: devops117 <55235206+devops117@users.noreply.github.com>
2022-11-23 10:40:27 +05:30
Lincoln Stein
90cb7a6442 fix behavior when models.yaml missing entirely 2022-11-22 16:56:38 +00:00
Lincoln Stein
8f5cded86e fix regression in ldm.invoke.model_cache.list_models()
- this was introduced in PR #1525 and not caught during my
  code review
2022-11-22 16:46:26 +00:00
Lincoln Stein
02d02a86b1 gracefully handle broken or missing models at initial load time
- If initial model fails to load, invoke.py will inform the user that
  something is wrong with models.yaml or the models themselves and
  drop user into configure_invokeai.py to repair the problem.

- The model caching system will longer try to reload the current model
  if there is none.
2022-11-22 16:36:11 +00:00
Lincoln Stein
ba9c695463 Merge branch 'development' into fix-model-load-error-reporting 2022-11-22 16:24:00 +00:00
Lincoln Stein
8202f34f38 Merge remote-tracking branch 'origin' into fix-model-load-error-reporting 2022-11-22 16:22:29 +00:00
Lincoln Stein
40a7f47d22 change typehint "a|b" operation to Union[a,b] to run on Python < 3.10
- this incompatibility was introduced by #1525 and missed during
  code review
2022-11-22 11:21:04 -05:00
Damian Stewart
1260e28d94 fix typo 2022-11-22 14:21:15 +01:00
devops117
229f782e3b check the function signatures and add some easy annotations
Signed-off-by: devops117 <55235206+devops117@users.noreply.github.com>
2022-11-22 08:14:58 -05:00
devops117
c15b839dd4 remove additional newline from the textwrap.dedent string
Signed-off-by: devops117 <55235206+devops117@users.noreply.github.com>
2022-11-22 08:14:58 -05:00
devops117
a095214e52 cleanup ldm/invoke/model_cache.py
remove duplicate import: os
ldm.util.ask_user is imported only once now
introduce textwrap and contextlib packages to clean up the code
return, returns None implicitly so it is omitted
a function returns None by default so it is omitted
dict.get returns None by default if the value is not found so it is omitted
type of True is a bool and if the module only returns True then it should not return anything in the first place
added some indentations and line breaks to further improve readability

Signed-off-by: devops117 <55235206+devops117@users.noreply.github.com>
2022-11-22 08:14:58 -05:00
Lincoln Stein
8e81425e89 fix outcropping crash when png has no InvokeAI metadata
- Closes #1461
2022-11-21 16:35:00 -05:00
Damian Stewart
c5cbe8f87d
When doing -t/--log_tokenization, also log prompt parser output (#1529)
The log was deleted at some point, this brings it back when user does
`--log_tokenization`/`-t`
2022-11-21 19:37:55 +01:00
Damian Stewart
e0581a2c37 when doing --log_tokenization/-t also log parsed prompt 2022-11-21 19:27:44 +01:00
Lincoln Stein
32f538bf3a fix another place where rename() should be replace() 2022-11-21 08:44:26 -05:00
Lincoln Stein
0661256b61 Merge branch 'interactive-configuration' into development 2022-11-20 23:32:28 +00:00
David Burnett
602e35db65 Fix issues with '.' not being consisent when run using web gui. 2022-11-20 18:22:13 -05:00
Lincoln Stein
38bdb440d0 remove several debugging messages
- dangling debug messages in several files, introduced during
  testing of the external root directory
- these need to be removed before they are interpreted as errors by users
2022-11-20 18:20:40 -05:00
Kevin Turner
150c4a5d2d
fix(args): fix INITFILE spelling 2022-11-19 12:01:02 -08:00
Lincoln Stein
0381a853b5 add interactive configuration to the model loader
- Loader is renamed `configure_invokeai.py`, but `preload_models.py` is retained
  (as a shell) for backward compatibility

- At startup, if no runtime root directory exists and no `.invokeai` startup file is
  present, user will be prompted to select the runtime and outputs directories.

- Also expanded the number of initial models offered to the user to include the
  most "liked" ones from HuggingFace, including the two trinart models, the
  PaperCut model, and the VoxelArt model.

- Created a configuration file for initial models to be offered to the user, at
  configs/INITIAL_MODELS.yaml
2022-11-19 19:20:28 +00:00
JPPhoto
8d3b1582a5 Fixed default to None 2022-11-19 11:50:26 +00:00
Lincoln Stein
5fd7d71a7a remove several debugging messages
- dangling debug messages in several files, introduced during
  testing of the external root directory
- these need to be removed before they are interpreted as errors by users
2022-11-18 21:14:28 +00:00
Lincoln Stein
aa95510444
Merge branch 'development' into create-invokeai-run-directory 2022-11-18 15:27:51 -05:00
Lincoln Stein
f33df25830 address all review comments; needs testing 2022-11-18 15:25:23 -05:00
Lincoln Stein
a1e5f17d1e realesrgan and facexlib now download models to correct directory
- fix issue in which both realesrgan and facexlib were downloading
  weight files to source directory

- cleaned up status reporting in load_models.py
2022-11-18 19:35:13 +00:00
Lincoln Stein
303431be89 move CLI into its own module 2022-11-18 19:35:10 +00:00
Lincoln Stein
3ad598761c support for wheel building; webserver broken 2022-11-18 19:34:28 +00:00