yoinked commited on
Commit
6b8b82f
1 Parent(s): c9d8ca1

Upload 2024-0924.1.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. 2024-0924.1.md +39 -0
2024-0924.1.md ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Multi-Resolution Sampling/Scheduling Improves Image Consistency
3
+ author: yoinked
4
+ tags: image, diffusion, sampling, scheduler, sampler
5
+ abstract: sampling at multiple resolutions in the sampler improves outputs at out-of-distribution resolution, effectively doubling
6
+ date_published: 2024-09-24
7
+ paperid: 2024-0924.1
8
+ ---
9
+ # Multi-Resolution Sampling/Scheduling Improves Image Consistency
10
+ ## 1. Abstract
11
+ In this paper, we will present a novel technique for sampling diffusion models, in which the model's effective resolution can be doubled or even tripled. We also present a new series of schedulers which, can improve sampling efficiency by enhancing the sampler's strength in the middle steps of the generation process. These tools are presented in code samples available [here](https://gist.github.com/yoinked-h/c2f5eafcee5a1f8c962deac47a29ce6a).
12
+
13
+ ## 2. Methodology
14
+
15
+ ### 2.1 Sampler
16
+ The sampler we present is based on DPM++ 2S Ancestral, with 2 modifications; the first is that we implement CFG++, which enables us to use a lower Classifier Free Guidance value for inference, which leads to better prompt adherence; the second modification is our novel method of improving the model's consistency at higher resolutions. The method involves down-sampling the base latent [denoted as `Lin`], which, while it is a "lossy" procedure, still enables for the model to understand those usable latents. Afterwards, we pass the down-sampled latent [denoted `LDW`] through the diffusion model, which, in higher resolution cases, will result in a more consistent latent, due to the model having been trained on that lower resolution. After the first model call, we up-sample `LDW` and merge it with `Lin` at a ratio of `M`, which is simply defined as the root of the current step number divided by the total number of steps. Once the latents are merged [denoted as `LM`], we pass that into the diffusion model again, to get rid of the up-sampling abnormalities and to refine it at the higher resolution whilst having a consistent base. [All denoted in the diagram below.]
17
+ ![image](https://huggingface.co/datasets/yoinked/blue-arxiv-papers/resolve/main/uploads/multires-diagram.png)
18
+
19
+ ### 2.2 Scheduler
20
+ The schedulers we present help to assist the sampler mentioned above, by providing with a higher sigma value during middle steps, effectively increasing the strength of the model, whilst retaining the consistency of the multi-res sampling. The following 3 schedulers are the best schedulers for this sampler we've tested:
21
+
22
+ #### Sinusoidal scheduler with scaling factor (sinsf)
23
+ This scheduler is the "angriest" scheduler out of the 3, in other words, the scheduler that decreases the fastest at the start. While this attribute may sound un-optimal, some popular schedulers are also angry, most notably, the exponential scheduler. The scheduler is defined as `( ( ( sigma_min + ( sigma_max - sigma_min ) * ( 1 - sin( π / 2 * x ) ) ) / sigma_max ) ** sf ) * sigma_max`, in which `x` is defined as a list of numbers from [0 - 1] (inclusive) of length `N`, which is the number of steps, and in which `sf` is equal to the scaling factor provided, usually around 3 for `sinsf`.
24
+
25
+ #### Inverse cosinusoidal scheduler with scaling factor (invsf)
26
+ This scheduler is designed as being a mid-step between `sinsf` and `dynsf`, which attempts to be more like the most used Karras scheduler. The scheduler is defined as `( ( ( sigma_min + ( sigma_max - sigma_min ) * ( 0.5 * ( cos( x * π ) + 1 ) ) ) / sigma_max ) ** sf ) * sigma_max`, in which `x` is defined as a list of numbers from [0 - 1] (inclusive) of length `N`, which is the number of steps, and in which `sf` is equal to the scaling factor provided, usually around 3 for `invsf`.
27
+
28
+ #### Reactive cosinusoidal scheduler with scaling factor (dynsf)
29
+ This scheduler is the "calmest" scheduler out of the 3, in other words, the scheduler that decreases the slowest at the start. The scheduler is defined as `( ( ( sigma_min + ( sigma_max - sigma_min ) * ( cos( x * ( π/2 ) ) ) )/sigma_max ) ** sf ) * sigma_max`, in which `x` is defined as a list of numbers from [0 - 1] (inclusive) of length `N`, which is the number of steps, and in which `sf` is equal to the scaling factor provided, usually around 4 for `dynsf`.
30
+
31
+ ![image](https://huggingface.co/datasets/yoinked/blue-arxiv-papers/resolve/main/uploads/multires-schedulers.png)
32
+
33
+ ## 3. Results
34
+ We tested the sampler by generating images outside of its "attention range" (for sd1.x it is 768x768 pixels), in this example, we ran a generation on an image of size 1024x1792; the sampler we used to compare against was DPM++ 2S Ancestral CFG++, so the only difference in the sampler should be the new internal up-sampling. We used `invsf` for our scheduler of choice, as it still helps non-internal samplers.
35
+ ![image](https://huggingface.co/datasets/yoinked/blue-arxiv-papers/resolve/main/uploads/multires-genexample.png)
36
+ The deformities (multiple bodies/torsos) in the first image are caused due to the model not capturing enough in its "attention range" for it to understand how the main feature of the image should appear.
37
+
38
+ ## 4. Conclusion
39
+ In conclusion, our proposed new sampler (labled `dpmpp_2s_ancestral_cfgpp_intern`) attempts to solve some shortcomings of regular Stable Diffusion models, in which the model "forgets" where parts of the main subject should go. We solved it by down-sampling latents before calling it to the model, this does leave the downside of suffering on smaller resolutions, as we would effectively down-sample too far and be left with near-unworkable latents once we up-sampled. We also presented 3 new schedulers, each with their use-cases, improving image quality on all samplers, but mainly on our proposed sampler.