MCPcopy Index your code
hub / github.com/Extraltodeus/DistanceSampler

github.com/Extraltodeus/DistanceSampler @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
20 symbols 50 edges 3 files 1 documented · 5%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

DistanceSampler

A custom experimental sampler based on relative distances. The first few steps are slower and then the sampler accelerates (the end is made with Heun).

The idea is to get a more precise start since this is when most of the work is being done.

A more technical explaination

Pros:

  • Less body horror / merged fused people.
  • Little steps required (4-10, recommanded general use: 7 with beta or AYS)
  • Can sample simple subjects without unconditional prediction (meaning with a CFG scale at 1) with a good quality.

Cons:

  • Slow, which is also a plus. Relax, the image is generating ⛱ (but really since it requires little amounts of steps while giving a lesser percentage of horrors I personally prefer it)

Variations:

  • The variation having a "n" in the name stands for "negative" and makes use of the unconditional prediction so to determin the best output. The results may vary depending on your negative prompt. In general it seems to make less mistakes. This is what I sample with in general.

  • The "p" variation uses a comparison with each previous step so to enhance the result. In general things become smoother / less messy.

New:

Thanks to Blepping there is now an ancestral version!

More infos here


Potential compatibility issue:

If any error was to relate to tensors shape, uncomment these two lines in the file "presets_to_add.py":

extra_samplers["Distance_fast"] = distance_wrap(resample=3,resample_end=1,cfgpp=False,sharpen=False)
extra_samplers["Distance_fast_n"] = distance_wrap(resample=3,resample_end=1,cfgpp=False,sharpen=False,use_negative=True)

These are basically the same except they don't use a spherical interpolation at the end. The interpolation was made with latent spaces such as those used in Stable Diffusion in mind. These two alternatives use a weighted average instead (the difference is barely noticeable from my testing).


Comparisons

Examples below are using the beta scheduler. The amount of steps has been adjusted to match the duration has this sampler is quite slow, yet requires little amounts of steps.

left: Distance, 7 steps

right: dpmpp2m, 20 steps

combined_side_by_side

Distance, 10 steps:

distance_10_steps

Distance n, 10 steps:

distance_n_10_steps

DPM++SDE (gpu), 14 steps:

dpmppsder_14steps

Disabled Guidance (CFG=1)

CFG scale at 1 on a normal SDXL model (works for simple subjects):

ComfyUI_00645_

ComfyUI_00640_

ComfyUI_00632_

Distance p with a CFG at 1 and 6 steps:

ComfyUI_00695_

ComfyUI_00692_

Core symbols most depended-on inside this repo

distance_wrap
called by 6
custom_samplers.py
internal_step
called by 3
custom_samplers.py
fix_step_range
called by 3
custom_samplers.py
get_ancestral_step_ext
called by 2
custom_samplers.py
diff_step
called by 2
custom_samplers.py
add_samplers
called by 1
__init__.py
matrix_batch_slerp
called by 1
custom_samplers.py
fast_distance_weights
called by 1
custom_samplers.py

Shape

Function 15
Class 3
Method 2

Languages

Python100%

Modules by API surface

custom_samplers.py19 symbols
__init__.py1 symbols

For agents

$ claude mcp add DistanceSampler \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact