Commit Graph

110 Commits

Author SHA1 Message Date
Lincoln Stein
e6b2c15fc5 Merge branch 'main' into fit-init-img
add a --fit option to limit the size of the initial image to the
maximum boundaries specified by width and height.
2022-09-01 14:09:46 -04:00
Lincoln Stein
2455bb38a4
Remove redundant chain of types
torch->cuda and cuda->torch, so torch.cuda.torch.cuda actually works. However it looks like (and probably is) a typo.
2022-09-01 10:23:45 -04:00
Cora Johnson-Roberson
91565970c2 Move environment-mac.yaml to Python 3.9 and patch dream.py for Macs.
I'm using stable-diffusion on a 2022 Macbook M2 Air with 24 GB unified memory.
I see this taking about 2.0s/it.

I've moved many deps from pip to conda-forge, to take advantage of the
precompiled binaries. Some notes for Mac users, since I've seen a lot of
confusion about this:

One doesn't need the `apple` channel to run this on a Mac-- that's only
used by `tensorflow-deps`, required for running tensorflow-metal. For
that, I have an example environment.yml here:

https://developer.apple.com/forums/thread/711792?answerId=723276022#723276022

However, the `CONDA_ENV=osx-arm64` environment variable *is* needed to
ensure that you do not run any Intel-specific packages such as `mkl`,
which will fail with [cryptic errors](https://github.com/CompVis/stable-diffusion/issues/25#issuecomment-1226702274)
on the ARM architecture and cause the environment to break.

I've also added a comment in the env file about 3.10 not working yet.
When it becomes possible to update, those commands run on an osx-arm64
machine should work to determine the new version set.

Here's what a successful run of dream.py should look like:

```
$ python scripts/dream.py --full_precision                                                                                                           SIGABRT(6) ↵  08:42:59
* Initializing, be patient...

Loading model from models/ldm/stable-diffusion-v1/model.ckpt
LatentDiffusion: Running in eps-prediction mode
DiffusionWrapper has 859.52 M params.
making attention of type 'vanilla' with 512 in_channels
Working with z of shape (1, 4, 32, 32) = 4096 dimensions.
making attention of type 'vanilla' with 512 in_channels
Using slower but more accurate full-precision math (--full_precision)
>> Setting Sampler to k_lms
model loaded in 6.12s

* Initialization done! Awaiting your command (-h for help, 'q' to quit)
dream> "an astronaut riding a horse"
Generating:   0%|                                                                                                                                                                         | 0/1 [00:00<?, ?it/s]/Users/corajr/Documents/lstein/ldm/modules/embedding_manager.py:152: UserWarning: The operator 'aten::nonzero' is not currently supported on the MPS backend and will fall back to run on the CPU. This may have performance implications. (Triggered internally at /Users/runner/work/_temp/anaconda/conda-bld/pytorch_1662016319283/work/aten/src/ATen/mps/MPSFallback.mm:11.)
  placeholder_idx = torch.where(
100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 50/50 [01:37<00:00,  1.95s/it]
Generating: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [01:38<00:00, 98.55s/it]
Usage stats:
   1 image(s) generated in 98.60s
   Max VRAM used for this generation: 0.00G
Outputs:
outputs/img-samples/000001.1525943180.png: "an astronaut riding a horse" -s50 -W512 -H512 -C7.5 -Ak_lms -F -S1525943180
```
2022-09-01 09:04:30 -04:00
Lincoln Stein
28fe84177e optionally scale initial image to fit box defined by width x height
* This functionality is triggered by the --fit option in the CLI (default
false), and by the "fit" checkbox in the WebGUI (default True)

* In addition, this commit contains a number of whitespace changes to
make the code more readable, as well as an attempt to unify the visual
appearance of info and warning messages.
2022-09-01 00:52:43 -04:00
blessedcoolant
0433b3d625
Add Warning When Image Is Too Large (#271)
* Add Warning When Image Is Too Large

* fix incomprehensible formatting introduced by "blue"

Co-authored-by: Lincoln Stein <lincoln.stein@gmail.com>
2022-08-31 23:13:21 -04:00
Lincoln Stein
4b560b50c2
fix AttributeError crash when running on non-CUDA systems (#256)
* fix AttributeError crash when running on non-CUDA systems; closes issue #234 and issue #250
* although this prevents dream.py script from crashing immediately on MPS systems, MPS support still very much a work in progress.
2022-08-31 16:59:27 -04:00
Lincoln Stein
9ad79207c2 Merge branch 'main' of github.com:lstein/stable-diffusion into main 2022-08-31 14:44:18 -04:00
Lincoln Stein
0be2351c97 Merge branch 'resolution-checker' of https://github.com/blessedcoolant/stable-diffusion into main 2022-08-31 14:43:17 -04:00
_nderscore
c52ba1b022
feat: simplify and enhance prompt weight splitting (#258)
* feat: simplify and enhance prompt weight splitting

* fix: don't shadow the prompt variable

* feat: enable backslash-escaped colons in prompts
2022-08-31 14:00:10 -04:00
Lincoln Stein
5354122094
Merge branch 'main' into refactor-pngwriter-2 2022-08-31 01:24:17 -04:00
spezialspezial
64444025a9
Update simplet2i.py (#228)
Typo causing bug when preinitializing the model. Unsupported Sampler: klms, Defaulting to plms
2022-08-31 01:08:46 -04:00
Kevin Gibbons
153c93bdd4 refactor pngwriter 2022-08-30 22:03:51 -07:00
Lincoln Stein
bdb0651eb2 add support for Apple hardware using MPS acceleration 2022-08-31 00:33:23 -04:00
blessedcoolant
1480ef84dc Add Resolution Checker 2022-08-31 14:54:16 +12:00
Kevin Gibbons
1714816fe2
remove support for batch_size from dream.py (#227)
* remove dream.py support for batch_size

* expect to get a single image
2022-08-30 22:30:12 -04:00
Kevin Gibbons
8ca4d6542d
support progress for img2img (#215)
WebGUI shows progress bar when an initial image is provided.
2022-08-30 15:36:12 -04:00
Lincoln Stein
a51e18ea98
resize initial image to match requested width and height, preserving aspect ratio. Closes #210. Closes #207 (#214) 2022-08-30 15:26:02 -04:00
Lincoln Stein
7fe7cdc8c9
Merge pull request #176 from xraxra/show-tokenization
Print out tokenization data during image generation, allowing truncated prompts to be visible.
2022-08-29 15:36:10 -04:00
Lincoln Stein
c7db038c96 grid is broken, needs the grid-fix PR#166 to fix 2022-08-29 13:39:20 -04:00
Lincoln Stein
4acfb76be6 correctly handle upscaling in webUI, including displaying status messages during GFPGAN/ESRGAN postprocessing 2022-08-29 12:08:18 -04:00
tesseractcat
070795a3b4 webui: stream progress events to page 2022-08-28 21:54:10 -07:00
Lincoln Stein
46464ac677 remove unused metadatastr variable 2022-08-28 23:45:50 -04:00
Lincoln Stein
03d8eb19e0 when no callback used, modify results list so that upscaled/face-fixed image replaces the old one 2022-08-28 23:40:04 -04:00
xra
fef632e0e1 tokenization logging (take 2)
This adds an option -t argument that will print out color-coded tokenization, SD has a maximum of 77 tokens, it silently discards tokens over the limit if your prompt is too long.
By using -t you can see how your prompt is being tokenized which helps prompt crafting.
2022-08-29 12:28:49 +09:00
Lincoln Stein
05061a70b3 report errors on non-cuda systems rather than failing silently 2022-08-28 23:13:23 -04:00
Lincoln Stein
617a029ae7 pass outdir from txt2img() and img2img() to prompt2img() correctly 2022-08-28 23:12:49 -04:00
blessedcoolant
8a517fdc17 Fix sampler changer not working. 2022-08-29 11:26:19 +12:00
Lincoln Stein
b85773f332 resolved conflicts and write properly-formatted prompt string (with sampler & upscaling) into image file 2022-08-28 19:01:45 -04:00
Lincoln Stein
8bbe7936bd close Issue #165 2022-08-28 18:21:20 -04:00
Lincoln Stein
7c485a1a4a adjusted -U upscaling argument so that it defaults to upscaling strength 0.75 if the second argument is not given 2022-08-28 17:26:39 -04:00
blessedcoolant
6e49c070bb Optimize and Improve GFPGAN and Real-ESRGAN Pipeline 2022-08-29 08:14:29 +12:00
Lincoln Stein
a7ac93a899
Merge pull request #110 from sajattack/half-precision-embeddings
Support full-precision embeddings in half precision inference mode
2022-08-28 15:36:26 -04:00
Lincoln Stein
3b2569ebdd Merge branch 'yunsaki-main' into main 2022-08-28 14:20:48 -04:00
Lincoln Stein
8b9a520c5c adjusted handling of from_file 2022-08-28 14:20:34 -04:00
Lincoln Stein
ba03289c14 print current and max VRAM usage stats after each round of generation 2022-08-28 13:05:01 -04:00
blessedcoolant
d1551b1bd4 Enable users to set sampler using prompts 2022-08-29 04:27:54 +12:00
Lincoln Stein
800132970e
Merge pull request #105 from shusso/select-device
Move torch.device selection to it's own function
2022-08-26 12:23:21 -04:00
Paul Sajna
555f13e469
Merge branch 'main' into half-precision-embeddings 2022-08-26 08:33:46 -07:00
Paul Sajna
9b5101cd8d support full-precision embeddings in half precision mode 2022-08-26 08:30:58 -07:00
yun saki
5129f256a3 simplet2i: changed image file handling to work as stated in the [docs](https://pillow.readthedocs.io/en/stable/reference/open_files.html) 2022-08-26 14:13:16 +02:00
Samuel Husso
ed72ff3268 Move torch.device selection to it's own function 2022-08-26 14:43:18 +03:00
Sean McLellan
f3fad22cb6 Fix 2022-08-26 05:27:34 -04:00
Sean McLellan
7bf0bc5208 fix comment 2022-08-26 04:08:18 -04:00
Sean McLellan
4e5aa7e714 fix comment 2022-08-26 04:07:01 -04:00
Sean McLellan
46a223f229 Double check for null and 0, and add a comment to indicate intent 2022-08-26 04:05:09 -04:00
Lincoln Stein
4f02b72c9c prettified all the code using "blue" at the urging of @tildebyte 2022-08-26 03:15:42 -04:00
Sean McLellan
407d70a987 Fix backwards logic 2022-08-26 00:49:12 -04:00
Sean McLellan
f1ffb5b51b Fix blend if the target image has been upscaled 2022-08-26 00:45:19 -04:00
Sean McLellan
4f1664ec4f remove params 2022-08-26 00:41:41 -04:00
Sean McLellan
fcdd95b652 Refactor so that behavior is consolidated at top level 2022-08-26 00:39:57 -04:00