Commit Graph

315 Commits

Author SHA1 Message Date
Lincoln Stein
1450779146 update branch for installer to pull against 2022-11-08 12:56:36 +00:00
Lincoln Stein
8cd5d95b8a move all models into subdirectories of ./models
- this required an update to the invoke-ai fork of gfpgan
- simultaneously reverted consolidation of environment and
  requirements files, as their presence in a directory
  triggered setup.py to try to install a sub-package.
2022-11-08 05:31:02 +00:00
Lincoln Stein
0196571a12 remove merge markers from preload_models.py 2022-11-02 22:39:35 -04:00
Lincoln Stein
240e5486c8 Merge branch 'spezialspezial-patch-9' into development 2022-11-02 18:35:00 -04:00
Lincoln Stein
b8870d8290 more bug fixes to install scripts 2022-11-02 15:26:02 -04:00
Lincoln Stein
ef24d76adc fix library problems in preload_modules 2022-11-01 17:23:27 -04:00
Lincoln Stein
1379642fc6 fix library problems in preload_modules 2022-11-01 14:34:23 -04:00
Lincoln Stein
408cf5e092 candidate install scripts for testing 2022-11-01 13:54:42 -04:00
Lincoln Stein
ce298d32b5 attempt to make batch install more reliable
1. added nvidia channel to environment.yml
2. updated pytorch-cuda requirement
3. let conda figure out what version of pytorch to install
4. add conda install status checking to .bat and .sh install files
5. in preload_models.py catch and handle download/access token errors
2022-11-01 12:02:22 -04:00
Lincoln Stein
f26199d377 further improvements to preload_models.py
- Faster startup for command line switch processing
- Specify configuration file to modify using --config option:

  ./scripts/preload_models.ply --config models/my-models-file.yaml
2022-10-31 11:34:22 -04:00
Lincoln Stein
7159ec885f further improvements to preload_models.py
- Faster startup for command line switch processing
- Specify configuration file to modify using --config option:

  ./scripts/preload_models.ply --config models/my-models-file.yaml
2022-10-31 11:33:05 -04:00
Lincoln Stein
90cd791e76 improve behavior of preload_models.py
- NEVER overwrite user's existing models.yaml
- Instead, merge its contents into new config file,
  and rename original to models.yaml.orig (with
  message)
- models.yaml has been removed from repository and renamed
  models.yaml.example
2022-10-31 11:09:57 -04:00
Lincoln Stein
b5cf734ba9 improve behavior of preload_models.py
- NEVER overwrite user's existing models.yaml
- Instead, merge its contents into new config file,
  and rename original to models.yaml.orig (with
  message)
- models.yaml has been removed from repository and renamed
  models.yaml.example
2022-10-31 11:08:19 -04:00
Lincoln Stein
89da42ad79 Merge branch 'pin-options-panel' of https://github.com/psychedelicious/stable-diffusion into psychedelicious-pin-options-panel
- from PR #1301
2022-10-31 09:37:13 -04:00
Damian at mba
ced9c83e96 various prompting fixes 2022-10-31 09:34:56 -04:00
Lincoln Stein
dc556cb1a7 add max_load_models parameter for model cache control
- ldm.generate.Generator() now takes an argument named `max_load_models`.
  This is an integer that limits the model cache size. When the cache
  reaches the limit, it will start purging older models from cache.

- CLI takes an argument --max_load_models, default to 2. This will keep
  one model in GPU and the other in CPU and switch back and forth
  quickly.

- To not cache models at all, pass --max_load_models=1
2022-10-31 08:55:53 -04:00
Lincoln Stein
0c8f0e3386 add max_load_models parameter for model cache control
- ldm.generate.Generator() now takes an argument named `max_load_models`.
  This is an integer that limits the model cache size. When the cache
  reaches the limit, it will start purging older models from cache.

- CLI takes an argument --max_load_models, default to 2. This will keep
  one model in GPU and the other in CPU and switch back and forth
  quickly.

- To not cache models at all, pass --max_load_models=1
2022-10-31 08:53:16 -04:00
Lincoln Stein
61ff90d1fd added files needed for preflight checks 2022-10-30 18:30:22 -04:00
Lincoln Stein
303a2495c7 fix broken url fetch in preload_models.py 2022-10-30 17:43:48 -04:00
Lincoln Stein
fbfffe028f add --no-interactive mode 2022-10-30 00:33:48 -04:00
Lincoln Stein
19b6c671a6 further improvements to preload_models script
- User can choose to download just recommended models, customize list to download,
  or skip downloading altogether.
- Does direct download to models directory instead of to HuggingFace cache
- Able to resume interrupted downloads
2022-10-30 00:17:05 -04:00
Lincoln Stein
b532e6dd17 wording and formatting tweaks 2022-10-29 11:28:17 -04:00
Lincoln Stein
3caa95ced9 add more step-by-step documentation and links 2022-10-29 09:18:48 -04:00
Lincoln Stein
ef68a419f1 preload_models.py script downloads the weight files
- user can select which weight files to download using huggingface cache
- user must log in to huggingface, generate an access token, and accept
  license terms the very first time this is run. After that, everything
  works automatically.
- added placeholder for docs for installing models
- also got rid of unused config files. hopefully they weren't needed
  for textual inversion, but I don't think so.
2022-10-29 01:02:45 -04:00
Lincoln Stein
fe7ab6e480 fix crash in !del_model command 2022-10-28 11:20:04 -04:00
Lincoln Stein
aa785c3ef1 ready for merge after documentation added 2022-10-27 11:55:00 -04:00
Lincoln Stein
799dc6d0df acceptable integration of new prompting system and inpainting
This was a difficult merge because both PR #1108 and #1243 made
changes to obscure parts of the diffusion code.

- prompt weighting, merging and cross-attention working
  - cross-attention does not work with runwayML inpainting
    model, but weighting and merging are tested and working
- CLI command parsing code rewritten in order to get embedded
  quotes right
- --hires now works with runwayML inpainting
- --embiggen does not work with runwayML and will give an error
- Added an --invert option to invert masks applied to inpainting
- Updated documentation
2022-10-27 01:51:35 -04:00
Lincoln Stein
8d5a225011 allow for empty prompts (useful for inpaint removal) 2022-10-25 17:26:00 -04:00
Lincoln Stein
99d23c4d81 fix merge conflicts 2022-10-25 07:30:26 -04:00
Lincoln Stein
9bef643bf5 fix a few more metadata bugs
- facetool and upscale arguments now written into metadata
- cleaned up handling of !fetch command
2022-10-25 00:31:43 -04:00
Lincoln Stein
f6b31d51e0 fix incorrect handling of single quotes in prompts 2022-10-25 00:31:43 -04:00
Lincoln Stein
b159b2fe42 add support for safety checker (NSFW filter)
Now you can activate the Hugging Face `diffusers` library safety check
for NSFW and other potentially disturbing imagery.

To turn on the safety check, pass --safety_checker at the command
line. For developers, the flag is `safety_checker=True` passed to
ldm.generate.Generate(). Once the safety checker is turned on, it
cannot be turned off unless you reinitialize a new Generate object.

When the safety checker is active, suspect images will be blurred and
a warning icon is added. There is also a warning message printed in
the CLI, but it can be a little hard to see because of its positioning
in the output stream.

There is a slight but noticeable delay when the safety checker runs.

Note that invisible watermarking is *not* currently implemented. The
watermark code distributed by the CompViz distribution uses a library
that does not seem to be able to retrieve the watermarks it creates,
and it does not appear that Hugging Face `diffusers` or other SD
distributions are doing any watermarking.
2022-10-23 22:26:18 -04:00
Lincoln Stein
f25c1f900f add support for loading VAE autoencoders
To add a VAE autoencoder to an existing model:

1. Download the appropriate autoencoder and put it into
   models/ldm/stable-diffusion

   Note that you MUST use a VAE that was written for the
   original CompViz Stable Diffusion codebase. For v1.4,
   that would be the file named vae-ft-mse-840000-ema-pruned.ckpt
   that you can download from https://huggingface.co/stabilityai/sd-vae-ft-mse-original

2. Edit config/models.yaml to contain the following stanza, modifying `weights`
   and `vae` as required to match the weights and vae model file names. There is
   no requirement to rename the VAE file.

~~~
stable-diffusion-1.4:
  weights: models/ldm/stable-diffusion-v1/sd-v1-4.ckpt
  description: Stable Diffusion v1.4
  config: configs/stable-diffusion/v1-inference.yaml
  vae: models/ldm/stable-diffusion-v1/vae-ft-mse-840000-ema-pruned.ckpt
  width: 512
  height: 512
~~~

3. Alternatively from within the `invoke.py` CLI, you may use the command
   `!editmodel stable-diffusion-1.4` to bring up a simple editor that will
   allow you to add the path to the VAE.

4. If you are just installing InvokeAI for the first time, you can also
   use `!import_model models/ldm/stable-diffusion/sd-v1.4.ckpt` instead
   to create the configuration from scratch.

5. That's it!
2022-10-23 09:33:15 -04:00
Lincoln Stein
ce6d618e3b outcropping improvements
- catch syntax errors in the outcrop coordinates
- work (after a fashion) on non-Invoke generated images
2022-10-23 09:33:00 -04:00
Lincoln Stein
b2bf2b08ff Merge branch 'model-switching' into development 2022-10-21 21:27:59 -04:00
Lincoln Stein
c9f9eed04e resolve numerous small merge bugs
- This merges PR #882

Coauthor: ArDiouscuros
2022-10-21 12:57:15 -04:00
Lincoln Stein
be7de4849c
Merge branch 'development' into model-switching 2022-10-21 00:55:52 -04:00
Lincoln Stein
83e6ab08aa further improvements to model loading
- code for committing config changes to models.yaml now in module
  rather than in invoke script
- model marked "default" is now loaded if model not specified on
  command line
- uncache changed models when edited, so that they reload properly
- removed liaon from models.yaml and added stable-diffusion-1.5
2022-10-21 00:28:54 -04:00
psychedelicious
899ba975a6 Improves logic to determine if clipseg weights should be downloaded 2022-10-20 06:56:50 -04:00
psychedelicious
bfa65560eb Fixes torch.load() for MPS/CPU 2022-10-20 06:56:50 -04:00
psychedelicious
ed9307f469 Fix typo 2022-10-20 06:56:50 -04:00
Lincoln Stein
a357bf4f19 add !mask command to view output of clipseg
- The !mask command takes an image path, a text prompt, and
  (optionally) a masking threshold. It creates a mask over the region
  indicated by the prompt, and outputs several files that show which
  regions will be masked by the chosen prompt and threshold.

- The mask images should not be passed directly to img2img because
  they are designed for visualization only. Instead, use the
  --text_mask option to pass the selected prompt and threshold.

- See docs/features/INPAINTING.md for details.
2022-10-20 06:56:50 -04:00
Lincoln Stein
2ca4242f5f fix clipseg loading problems
- The directory "models" in the main InvokeAI directory was conflicting
  with loading "models.clipseg". To fix this issue, I have renamed the
  models.clipseg to clipseg_models.clipseg, and applied this change to
  the 'models-rename' branch of invoke-ai's fork of clipseg.
2022-10-20 06:56:50 -04:00
Lincoln Stein
62dd3b7d7d resolve models.clipseg vs clipseg ambiguity 2022-10-18 23:09:26 -04:00
Lincoln Stein
66f6ef1b35
fix syntax errors in preload 2022-10-18 19:25:18 -04:00
Lincoln Stein
a488b14373 prevent preload warning message 2022-10-18 17:09:17 -04:00
Lincoln Stein
32122e0312 clipseg library and environment in place 2022-10-18 08:27:48 -04:00
Lincoln Stein
c974c95e2b Merge branch 'development' of github.com:invoke-ai/InvokeAI into development 2022-10-17 23:14:55 -04:00
Lincoln Stein
3b2590243c ^C at invoke> cmd line exits gracefully 2022-10-17 23:14:32 -04:00
Lincoln Stein
0cf11ce488 add option to CLI and pngwriter that allows user to set PNG compression level
- In CLI: the argument is --png_compression <0..9> (-z<0..9>)
- In API, pass `compress_level` to PngWriter.save_image_and_prompt_to_png()

Compression ranges from 0 (no compression) to 9 (maximum compression).
Default value is 6 (as specified by Pillow package).

This addresses an issue first raised in #652.
2022-10-17 22:27:47 -04:00