ComfyUI > Nodes > DistanceSampler

ComfyUI Extension: DistanceSampler

Repo Name

DistanceSampler

Author
Extraltodeus (Account age: 3473 days)
Nodes
View all nodes(1)
Latest Updated
2025-05-09
Github Stars
0.03K

How to Install DistanceSampler

Install this extension via the ComfyUI Manager by searching for DistanceSampler
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter DistanceSampler in the search bar
After installation, click the Restart button to restart ComfyUI. Then, manually refresh your browser to clear the cache and access the updated list of nodes.

Visit ComfyUI Online for ready-to-use ComfyUI environment

  • Free trial available
  • 16GB VRAM to 80GB VRAM GPU machines
  • 400+ preloaded models/nodes
  • Freedom to upload custom models/nodes
  • 200+ ready-to-run workflows
  • 100% private workspace with up to 200GB storage
  • Dedicated Support

Run ComfyUI Online

DistanceSampler Description

DistanceSampler is a heuristic modification of the Heun sampler for ComfyUI, utilizing a custom function based on normalized distances to enhance sampling efficiency and accuracy.

DistanceSampler Introduction

DistanceSampler is an innovative and experimental tool designed to enhance the quality of AI-generated images by focusing on the relative distances during the sampling process. This extension is particularly beneficial for AI artists who seek to create more precise and visually appealing images with fewer artifacts, such as body horror or merged figures. By using DistanceSampler, you can achieve high-quality results with fewer steps, making it an efficient choice for generating simple subjects without the need for unconditional prediction. This means you can maintain a low CFG (Classifier-Free Guidance) scale, even as low as 1, while still producing excellent image quality.

How DistanceSampler Works

At its core, DistanceSampler operates by initially taking slower steps to ensure a more accurate start, which is crucial as most of the image's foundational work is done in these early stages. As the process progresses, the sampler accelerates, culminating in a method known as Heun's method. This approach allows for a more refined and precise image generation process. Imagine it like painting a picture: you start with careful, deliberate strokes to outline the main features, and then you can speed up as you fill in the details, ensuring everything aligns perfectly.

DistanceSampler Features

DistanceSampler offers several features that can be tailored to your artistic needs:

  • Precision Start: The initial steps are slower, allowing for a more detailed and accurate beginning, which is crucial for the overall quality of the image.
  • Reduced Artifacts: By focusing on relative distances, the sampler minimizes common issues like body horror or merged figures, resulting in cleaner and more coherent images.
  • Efficiency: Requires fewer steps (typically 4-10, with 7 being recommended for general use) to achieve high-quality results, saving time and computational resources.
  • Customizable Variations:
  • Negative Variation ("n"): Utilizes unconditional prediction to determine the best output, often resulting in fewer mistakes. This is ideal when you want to ensure the highest quality with minimal errors.
  • Comparison Variation ("p"): Compares each step with the previous one to enhance the result, leading to smoother and less cluttered images.

DistanceSampler Models

DistanceSampler includes different variations that cater to specific needs:

  • Standard DistanceSampler: Best for general use with a balance of speed and quality.
  • DistanceSampler "n": Ideal for scenarios where minimizing errors is crucial, as it uses negative prompts to refine the output.
  • DistanceSampler "p": Suitable for artists who prefer smoother transitions and less noise in their images.

Troubleshooting DistanceSampler

If you encounter issues related to tensor shapes, a potential solution is to modify the "presets_to_add.py" file by uncommenting the following lines:

python 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 adjustments replace the spherical interpolation with a weighted average, which may resolve compatibility issues without significantly affecting the output quality.

Learn More about DistanceSampler

For those interested in diving deeper into the technical aspects of DistanceSampler, the author has provided a more technical explanation. Additionally, you can explore community forums and online tutorials to connect with other AI artists and share experiences, tips, and support. Engaging with these resources can enhance your understanding and mastery of DistanceSampler, allowing you to fully leverage its capabilities in your creative projects.

DistanceSampler Related Nodes

RunComfy
Copyright 2025 RunComfy. All Rights Reserved.

RunComfy is the premier ComfyUI platform, offering ComfyUI online environment and services, along with ComfyUI workflows featuring stunning visuals. RunComfy also provides AI Playground, enabling artists to harness the latest AI tools to create incredible art.