diff --git a/docs/features/OTHER.md b/docs/features/OTHER.md index f1fd6c78e9..1e85499e33 100644 --- a/docs/features/OTHER.md +++ b/docs/features/OTHER.md @@ -95,12 +95,19 @@ do not need to add up to 1. Two new options are the thresholding (`--threshold`) and the perlin noise initialization (`--perlin`) options. Thresholding limits the range of the latent values during optimization, which helps combat oversaturation with higher CFG scale values. Perlin noise initialization starts with a percentage (a value ranging from 0 to 1) of perlin noise mixed into the initial noise. Both features allow for more variations and options in the course of generating images. -For better intuition into what these options do in practice, [here is a graphic demonstrating them both](static/truncation_comparison.jpg) in use. Perlin noise at initialization is varied going across by 0.0, 0.1, 0.2, 0.4, 0.5, 0.6,, 0.8, 0.9, 1.0; and the threshold is varied going down from 0, 1, 2, 3, 4, 5, 10, 20, 100. The other options are fixed, so the initial prompt is as follows: +For better intuition into what these options do in practice, [here is a graphic demonstrating them both](static/truncation_comparison.jpg) in use. In generating this graphic, perlin noise at initialization was programmatically varied going across on the diagram by values 0.0, 0.1, 0.2, 0.4, 0.5, 0.6, 0.8, 0.9, 1.0; and the threshold was varied going down from +0, 1, 2, 3, 4, 5, 10, 20, 100. The other options are fixed, so the initial prompt is as follows (no thresholding or perlin noise): ``` a portrait of a beautiful young lady -S 1950357039 -s 100 -C 20 -A k_euler_a --threshold 0 --perlin 0 ``` +Here's an example of another prompt used when setting the threshold to 5 and perlin noise to 0.2: + +``` + a portrait of a beautiful young lady -S 1950357039 -s 100 -C 20 -A k_euler_a --threshold 5 --perlin 0.2 +``` + Note: currently the thresholding feature is only implemented for the k-diffusion style samplers, and empirically appears to work best with `k_euler_a` and `k_dpm_2_a`. Using 0 disables thresholding. Using 0 for perlin noise disables using perlin noise for initialization. Finally, using 1 for perlin noise uses only perlin noise for initialization. --- diff --git a/ldm/dream/generator/txt2img.py b/ldm/dream/generator/txt2img.py index 6e9c5149cd..822aaf9c55 100644 --- a/ldm/dream/generator/txt2img.py +++ b/ldm/dream/generator/txt2img.py @@ -61,7 +61,6 @@ class Txt2Img(Generator): height // self.downsampling_factor, width // self.downsampling_factor], device=device) - print(self.perlin) if self.perlin > 0.0: x = (1-self.perlin)*x + self.perlin*self.get_perlin_noise(width // self.downsampling_factor, height // self.downsampling_factor) return x diff --git a/ldm/generate.py b/ldm/generate.py index 857f325a25..bf9e2e6253 100644 --- a/ldm/generate.py +++ b/ldm/generate.py @@ -233,7 +233,7 @@ class Generate: image_callback // a function or method that will be called each time an image is generated with_variations // a weighted list [(seed_1, weight_1), (seed_2, weight_2), ...] of variations which should be applied before doing any generation variation_amount // optional 0-1 value to slerp from -S noise to random noise (allows variations on an image) - threshold // optional value to add thresholding to latent values for k-diffusion samplers (0 disables) + threshold // optional value >=0 to add thresholding to latent values for k-diffusion samplers (0 disables) perlin // optional 0-1 value to add a percentage of perlin noise to the initial noise embiggen // scale factor relative to the size of the --init_img (-I), followed by ESRGAN upscaling strength (0-1.0), followed by minimum amount of overlap between tiles as a decimal ratio (0 - 1.0) or number of pixels embiggen_tiles // list of tiles by number in order to process and replace onto the image e.g. `0 2 4` @@ -275,12 +275,16 @@ class Generate: m.padding_mode = 'circular' if seamless else m._orig_padding_mode assert cfg_scale > 1.0, 'CFG_Scale (-C) must be >1.0' + assert threshold >= 0.0, '--threshold must be >=0.0' assert ( 0.0 < strength < 1.0 ), 'img2img and inpaint strength can only work with 0.0 < strength < 1.0' assert ( 0.0 <= variation_amount <= 1.0 ), '-v --variation_amount must be in [0.0, 1.0]' + assert ( + 0.0 <= perlin <= 1.0 + ), '-v --perlin must be in [0.0, 1.0]' assert ( (embiggen == None and embiggen_tiles == None) or ((embiggen != None or embiggen_tiles != None) and init_img != None) ), 'Embiggen requires an init/input image to be specified' diff --git a/static/dream_web/index.html b/static/dream_web/index.html index 914e0dda0c..b190b82c19 100644 --- a/static/dream_web/index.html +++ b/static/dream_web/index.html @@ -72,11 +72,13 @@ - - - - - +