Commit Graph

166 Commits

Author SHA1 Message Date
3491a1688b Merge branch 'development' of github.com:invoke-ai/InvokeAI into development 2022-09-27 18:15:14 -04:00
ac1999929f remove dangling debug statement 2022-09-27 18:13:45 -04:00
be99d5a4bd Merge branch 'development' into development 2022-09-26 09:21:15 -04:00
d80fff70f2 ESRGAN Improvements 2022-09-26 03:28:23 -04:00
d63897fc39 tweaks to get embiggen to work with new development changes PR #553
- swapped out calls to choose_autocast()
- fixed call to retrieve_png_metadata() so as to recover original prompt

Original author: @travco
2022-09-26 03:25:26 -04:00
485fe67c92 Add workaround low memory crash during image saving
Sample model moved to cpu before processing samples to image
2022-09-26 02:15:51 -04:00
47408bb568 Merge branch 'development' into development 2022-09-24 22:11:18 -04:00
636c356aaf facexlib and codeformer are broken on mps currently, force CPU device. 2022-09-24 21:22:24 +02:00
66dac1884b Fix Generate.sample_to_image crash.
Build the base generator in same place and way as other generators to reduce the chance of missed arguments in the future.
Fixes crash with display in-progress images, though note the feature still doesn't work for other reasons.
2022-09-24 05:20:28 -04:00
b1d1063a25 Fix CodeFormer not working if GFPGAN is enabeld 2022-09-24 05:19:07 -04:00
16a06ba66e fix typo 2022-09-24 05:00:57 -04:00
6858c14d94 Allow Generate to take images as readers or Image instances 2022-09-24 05:00:57 -04:00
bf21a0bf02 fix resizing of inpainting mask
- change image resampling method for mask shrinkage to prevent
  artifacts at edge of mask

Addresses #625
2022-09-24 04:37:34 -04:00
880142708d Merge branch 'development' into development 2022-09-23 15:41:06 -04:00
cd8be1d0e9 Restoration Modules are now optional 2022-09-23 10:51:41 +02:00
88e3b6d310 Merge branch 'development' into development 2022-09-21 17:47:14 -04:00
0ab5f2159d fix img2img incorrectly loading previous prompt 2022-09-21 15:18:59 -04:00
60f0090786 Merge branch 'development' into development 2022-09-21 03:10:49 -04:00
2cf294e6de Add outpainting functionality.
- Adapted from PR #489, author Dominic Letz [https://github.com/dominicletz]
- Too many upstream changes to merge, so frankensteined it in.
- Added support for !fix syntax
- Added documentation
2022-09-21 02:44:46 -04:00
b93f04ee38 fix normalized prompt when a variation is generated
- The seed printed needs to be the one generated prior to the
  initial noising operation. To do this, I added a new "first_seed"
  argument to the image callback in dream.py.
- Closes #641
2022-09-21 00:32:29 -04:00
8731b498c0 fix merge conflicts 2022-09-20 23:55:57 -04:00
f408ef2e6c resolved multiple conflicts between PR #683 and subsequent PRs 2022-09-20 23:41:43 -04:00
283a0d72c7 tweaks to make postprocess fixing work better
- modify strength of embiggen to reduce tiling ghosts
- normalize naming of postprocessed files (could improve more to avoid
name collisions)
- move restoration modules under ldm.dream
2022-09-20 23:38:04 -04:00
1b5013ab72 GFPGAN and Real ESRGAN Implementation Refactor 2022-09-20 23:37:19 -04:00
e8bb39370c add ability to post-process images from the CLI
- supports gfpgan, esrgan, codeformer and embiggen
- To use:
   dream> !fix ./outputs/img-samples/000056.292144555.png -ft gfpgan -U2 -G0.8
   dream> !fix ./outputs/img-samples/000056.292144555.png -ft codeformer -G 0.8
   dream> !fix ./outputs/img-samples/000056.29214455.png  -U4
   dream> !fix ./outputs/img-samples/000056.292144555.png -embiggen 1.5

   The first example invokes gfpgan to fix faces and esrgan to upscale.
   The second example invokes codeformer to fix faces, no upscaling
   The third example uses esrgan to upscale 4X
   The four example runs embiggen to enlarge 1.5X

- This is very preliminary work. There are some anomalies to note:
  1. The syntax is non-obvious. I would prefer something like:
     !fix esrgan,gfpgan
     !fix esrgan
     !fix embiggen,codeformer

     However, this will require refactoring the gfpgan and embiggen
     code.

   2. Images generated using gfpgan, esrgan or codeformer all are named
      "xxxxxx.xxxxxx.postprocessed.png" and the original is saved.
      However, the prefix is a new one that is not related to the
      original.

   3. Images generated using embiggen are named "xxxxx.xxxxxxx.png",
      and once again the prefix is new. I'm not sure whether the
      prefix should be aligned with the original file's prefix or not.
      Probably not, but opinions welcome.
2022-09-20 23:33:20 -04:00
fc61ddab3c Merge branch 'development' into postprocessing-commands 2022-09-20 18:48:42 -04:00
d5209965bc Merge branch 'development' into development 2022-09-20 17:40:21 -04:00
d176fb07cd Replace --full_precision with --precision that works even if not specified
Allowed values are 'auto', 'float32', 'autocast', 'float16'. If not specified or 'auto' a working precision is automatically selected based on the torch device.
Context: #526
Deprecated --full_precision / -F

Tested on both cuda and cpu by calling scripts/dream.py without arguments and checked the auto configuration worked. With --precision=auto/float32/autocast/float16 it performs as expected, either working or failing with a reasonable error. Also checked Img2Img.
2022-09-20 17:08:00 -04:00
23af057e5c tweaks to make postprocess fixing work better
- modify strength of embiggen to reduce tiling ghosts
- normalize naming of postprocessed files (could improve more to avoid
name collisions)
- move restoration modules under ldm.dream
2022-09-19 14:54:52 -04:00
c14bdcb8fd combine PRs #690 and #683 2022-09-19 13:59:43 -04:00
f816526d0d add ability to post-process images from the CLI
- supports gfpgan, esrgan, codeformer and embiggen
- To use:
   dream> !fix ./outputs/img-samples/000056.292144555.png -ft gfpgan -U2 -G0.8
   dream> !fix ./outputs/img-samples/000056.292144555.png -ft codeformer -G 0.8
   dream> !fix ./outputs/img-samples/000056.29214455.png  -U4
   dream> !fix ./outputs/img-samples/000056.292144555.png -embiggen 1.5

   The first example invokes gfpgan to fix faces and esrgan to upscale.
   The second example invokes codeformer to fix faces, no upscaling
   The third example uses esrgan to upscale 4X
   The four example runs embiggen to enlarge 1.5X

- This is very preliminary work. There are some anomalies to note:
  1. The syntax is non-obvious. I would prefer something like:
     !fix esrgan,gfpgan
     !fix esrgan
     !fix embiggen,codeformer

     However, this will require refactoring the gfpgan and embiggen
     code.

   2. Images generated using gfpgan, esrgan or codeformer all are named
      "xxxxxx.xxxxxx.postprocessed.png" and the original is saved.
      However, the prefix is a new one that is not related to the
      original.

   3. Images generated using embiggen are named "xxxxx.xxxxxxx.png",
      and once again the prefix is new. I'm not sure whether the
      prefix should be aligned with the original file's prefix or not.
      Probably not, but opinions welcome.
2022-09-19 12:38:14 -04:00
7b0cbb34d6 GFPGAN and Real ESRGAN Implementation Refactor 2022-09-19 23:38:56 +12:00
3692f223e1 Merge branch 'development' into development 2022-09-18 18:58:04 -04:00
f3292a6953 Implement CodeFormer Face Restoration (#669)
* Implement CodeFormer Face Restoration

* fix codeformer model destination path

Co-authored-by: Lincoln Stein <lincoln.stein@gmail.com>
2022-09-18 15:01:05 -04:00
c98ade9b25 Merge branch 'development' into development 2022-09-18 12:35:28 -04:00
045aa7a9a3 Support color correction for img2img and inpainting (#613)
* Support color correction for img2img and inpainting, avoiding the shift to magenta seen when running images through img2img repeatedly.

* Fix docs for color correction

* add --init_color to prompt reconstruction

* For best results, the --init_color option should point to the *very first* image used in the sequence of img2img operations. Otherwise color correction will skew towards cyan.

Co-authored-by: Lincoln Stein <lincoln.stein@gmail.com>
2022-09-18 09:47:57 -04:00
1e3200801f Merge remote-tracking branch 'upstream/development' into development 2022-09-16 19:29:08 -04:00
cbac95b02a Merge with PR #602
- New and improved web api
- Author: @Kyle0654
2022-09-16 16:35:34 -04:00
403d02d94f implementation of RFC #266 (#587)
* Feature complete for #266 with exception of several small deviations:
1. initial image and model weight hashes use full sha256 hash rather than first 8 digits
2. Initialization parameters for post-processing steps not provided
3. Uses top-level "images" tags for both a single image and a grid of images. This change was suggested in a comment.

* Added scripts/sd_metadata.py to retrieve and print metadata from PNG files
* New ldm.dream.args.Args class is a namespace like object which holds all defaults and can be modified during exection to hold current settings.
* Modified dream.py and server.py to accommodate Args class.
2022-09-16 13:09:04 -04:00
54b9cb49c1 Merge branch 'development' into development 2022-09-15 11:09:27 -04:00
60b731e7ab Update dream.py. k_euler_a and k_dpm_2_a M1 fix (#579)
* Update dream.py. k_euler_a and k_dpm_2_a M1 fix

Make results reproducible (so runs with the same seed produce the same result).
Implements fix by @wbowling referenced in https://github.com/lstein/stable-diffusion/issues/397#issuecomment-1240679294

* Update dream.py. Remove import torch from dream.py

* generate.py: k_euler_a and k_dpm_2_a M1 fix #579

Co-authored-by: Lincoln Stein <lincoln.stein@gmail.com>
2022-09-15 11:02:17 -04:00
8d2afefe6a fixup 2022-09-15 15:45:48 +02:00
9faf7025c6 fixup 2022-09-15 15:39:03 +02:00
511924c9ab fixup 2022-09-15 15:37:27 +02:00
4d997145b4 Add -D for outpainting 2022-09-15 15:34:23 +02:00
80579a30e5 Merge branch 'development' into development 2022-09-14 07:10:39 -04:00
e6179af46a Refactor generate.py and dream.py (#534)
* revert inadvertent change of conda env name (#528)

* Refactor generate.py and dream.py

* config file path (models.yaml) is parsed inside Generate() to simplify
API

* Better handling of keyboard interrupts in file loading mode vs
interactive

* Removed oodles of unused variables.

* move nonfunctional inpainting out of the scripts directory

* fix ugly ddim tqdm formatting
2022-09-14 07:02:31 -04:00
2e438542e9 * Fixes and updates for PR. 2022-09-13 21:56:17 -04:00
5e15f1e017 Merge branch 'development' into development 2022-09-12 16:59:15 -04:00
0bc6779361 Disable autocast for cpu to fix error. Remove unused precision arg. (#518)
When running on just cpu (intel), a call to torch.layer_norm would error with RuntimeError: expected scalar type BFloat16 but found Float
Fix buggy device handling in model.py.
Tested with scripts/dream.py --full_precision on just cpu on intel laptop. Works but slow at ~10s/it.
2022-09-12 16:55:21 -04:00