Initial commit

This commit is contained in:
Jordan Thompson
2026-04-27 08:25:43 -07:00
parent b91ad3aafd
commit 5e5edac72f
6 changed files with 2167 additions and 22 deletions
+22
View File
@@ -0,0 +1,22 @@
name: Publish to Comfy registry
on:
workflow_dispatch:
push:
branches:
- main
- master
paths:
- "pyproject.toml"
jobs:
publish-node:
name: Publish Custom Node to registry
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Publish Custom Node
uses: Comfy-Org/publish-node-action@main
with:
## Add your own personal access token to your Github Repository secrets and reference it here.
personal_access_token: ${{ secrets.REGISTRY_ACCESS_TOKEN }}
+21 -21
View File
@@ -1,21 +1,21 @@
MIT License
Copyright (c) 2026 WAS
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
MIT License
Copyright (c) 2026 Jordan "WAS" Thompson
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+155 -1
View File
@@ -1 +1,155 @@
# RES4SHO
# High-Frequency Detail Sampling based on Res Sampling
This is a ComfyUI custom node that enhances fine detail preservation in diffusion model outputs using spectral high-frequency emphasis (HFE).
## Installation
Clone or copy this folder into your ComfyUI `custom_nodes` directory:
```
ComfyUI/
custom_nodes/
RES4SHO/
__init__.py
sampling.py
```
Restart ComfyUI. The new samplers and schedulers will appear in the dropdown menus of any **KSampler** node.
## Samplers
All samplers are exponential integrators with phi-function coefficients. The HFE enhancement extracts high-frequency detail from inter-stage correction deltas via a 3x3 spatial high-pass filter and re-injects it with configurable strength.
### Fixed-Strength Presets
Each stage count offers 8 strength levels (`s1` = no emphasis, `s8` = maximum potential sharpness):
| Sampler | Stages | Model Evals/Step |
|---------|--------|-----------------|
| `hfe_s1` .. `hfe_s8` | 2 | 2 |
| `hfe3_s1` .. `hfe3_s8` | 3 | 3 |
| `hfe4_s1` .. `hfe4_s8` | 4 | 4 |
| `hfe5_s1` .. `hfe5_s8` | 5 | 5 |
Higher stage counts provide better ODE integration accuracy at the cost of more model evaluations per step.
### Adaptive (Auto) Samplers
Per-step adaptive `eta` based on sigma envelope and content gating:
| Sampler | Stages | Description |
|---------|--------|-------------|
| `hfe_auto` | 2 | Variable c2, eta, and kernel per step |
| `hfe3_auto` | 3 | Per-step eta with 3-stage integrator |
| `hfe4_auto` | 4 | Per-step eta with 4-stage integrator |
| `hfe5_auto` | 5 | Per-step eta with 5-stage integrator |
**How auto adapts:**
- **Sigma envelope** (smoothstep): suppresses emphasis at high noise (early steps), full strength in the detail-forming range
- **Content gate**: reduces emphasis when the model correction is already HF-rich; increases it when the correction is smooth and needs boosting
### Experimental Samplers (hfx_*)
Alternative HF extraction methods, all using a 2-stage base:
| Sampler | Method |
|---------|--------|
| `hfx_lap` | Laplacian pyramid multi-scale (3 bands) |
| `hfx_mom` | Correction momentum (EMA across steps) |
| `hfx_fft` | FFT spectral high-pass with smooth cutoff |
| `hfx_sde` | Stochastic HF noise injection |
| `hfx_spatial` | Spatially-adaptive per-pixel gating |
**Hybrids** (combine two techniques):
- `hfx_lap_mom` -- Laplacian pyramid + momentum
- `hfx_lap_spatial` -- Laplacian pyramid + spatial gating
- `hfx_fft_spatial` -- FFT spectral + spatial gating
**Band profile variants:**
- `hfx_lap_fine` -- fine-detail emphasis (edges, texture)
- `hfx_lap_broad` -- even emphasis across frequency bands
Each experimental mode also has 4 graduated strength presets (`_s1` .. `_s4`), e.g. `hfx_lap_s1`, `hfx_mom_s3`, etc.
## Schedulers
Arctangent S-curve schedulers that concentrate step density in the detail-forming sigma range:
| Scheduler | Description |
|-----------|-------------|
| `atan_gentle` | Mild mid-sigma concentration |
| `atan_focused` | Moderate detail-range concentration |
| `atan_steep` | Aggressive detail-range concentration |
| `karras_tan` | Karras-Tangent hybrid (experimental) |
| `logistic` | Logistic sigmoid S-curve (experimental) |
An ASCII sigma chart is printed to the console when a scheduler is used.
## Recommended Combinations
### Getting Started
| Goal | Sampler | Scheduler | Notes |
|------|---------|-----------|-------|
| General use | `hfe_auto` | `atan_focused` | Best all-rounder -- adaptive emphasis handles most content |
| Subtle enhancement | `hfe_s3` | `atan_gentle` | Light touch, minimal risk of artifacts |
| Strong detail | `hfe_s6` | `atan_steep` | Noticeably sharper textures and edges |
| Maximum sharpness | `hfe_s7` or `hfe_s8` | `atan_steep` | Aggressive -- inspect for over-sharpening |
### By Content Type
| Content | Sampler | Scheduler | Why |
|---------|---------|-----------|-----|
| Portraits / faces | `hfe_auto` | `atan_focused` | Auto gate protects smooth skin while sharpening eyes, hair, pores |
| Landscapes / nature | `hfe_s5` | `atan_gentle` | Fixed mid-strength avoids over-enhancing skies and gradients |
| Architecture / hard surfaces | `hfe_s7` | `atan_steep` | Strong emphasis on edges and geometric detail |
| Text / UI renders | `hfx_lap_fine` | `atan_steep` | Fine-band Laplacian targets glyph edges specifically |
| Fabric / organic texture | `hfx_lap_broad` | `atan_focused` | Even multi-scale emphasis across weave and folds |
| Illustrations / anime | `hfe_s4` | `atan_gentle` | Light emphasis preserves flat shading without adding unwanted texture |
### High-Accuracy Integrators
More model evaluations per step for better ODE integration -- useful at low step counts or with difficult models:
| Sampler | Scheduler | Use Case |
|---------|-----------|----------|
| `hfe3_auto` | `atan_focused` | Good balance of accuracy and speed (3 evals/step) |
| `hfe4_auto` | `atan_focused` | High accuracy for complex prompts (4 evals/step) |
| `hfe5_auto` | `atan_gentle` | Maximum integration accuracy (5 evals/step) |
| `hfe4_s5` | `atan_steep` | Fixed-strength detail + 4-stage accuracy |
| `hfe5_s6` | `karras_tan` | High emphasis + high accuracy + Karras hybrid spacing |
### Experimental Combinations
| Sampler | Scheduler | Character |
|---------|-----------|-----------|
| `hfx_lap` | `atan_focused` | Multi-scale detail -- good default experimental choice |
| `hfx_fft` | `atan_steep` | Frequency-domain sharpening -- clean spectral separation |
| `hfx_spatial` | `atan_focused` | Sharpens high-variance regions, leaves smooth areas alone |
| `hfx_mom` | `atan_gentle` | Accumulates detail across steps -- builds up gradually |
| `hfx_sde` | `atan_gentle` | Stochastic texture injection -- adds micro-variation |
| `hfx_lap_mom` | `atan_focused` | Multi-scale + momentum -- rich progressive detail |
| `hfx_lap_spatial` | `atan_steep` | Multi-scale + spatial gating -- targeted sharpening |
| `hfx_fft_spatial` | `atan_focused` | Spectral + spatial -- precise frequency-aware gating |
### Scheduler Pairings
| Scheduler | Best With | Character |
|-----------|-----------|-----------|
| `atan_gentle` | Low-strength samplers (`s1`-`s4`), stochastic modes | Mild concentration, safe for all content |
| `atan_focused` | Auto samplers, mid-strength presets (`s4`-`s6`) | Balanced step density in detail range |
| `atan_steep` | High-strength samplers (`s6`-`s8`), architectural content | Aggressive detail-range concentration |
| `karras_tan` | High-stage integrators (`hfe4_*`, `hfe5_*`) | Karras optimal spacing + tangent warp |
| `logistic` | Any -- alternative S-curve shape | Sharper transition through detail range, flatter extremes |
## How It Works
**Base integrator:** Multi-stage singlestep exponential integrator (res_Ns) with phi-function coefficients, giving exact treatment of exponential decay and higher-order corrections from intermediate evaluations.
**HFE enhancement:** The inter-stage correction delta captures what the model reveals at lower noise -- texture, edges, micro-structure. A spatial high-pass (residual after box blur in latent space) extracts the fine detail component, which is re-injected with extra weight `eta`. This compounds across every step.
**Cost:** One 3x3 `avg_pool` per step for all variants (negligible vs. model evaluation). Auto samplers add a few scalar ops on top.
## License
MIT
+14
View File
@@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-
"""
RES4SHO -- High-Frequency Detail Sampling for ComfyUI
Custom samplers and schedulers that enhance fine detail preservation
in diffusion model outputs via spectral high-frequency emphasis (HFE).
Adds new entries to the sampler and scheduler dropdowns in KSampler nodes.
No additional custom nodes are created.
"""
from .sampling import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS
__all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS"]
+28
View File
@@ -0,0 +1,28 @@
[project]
name = "RES4SHO"
version = "1.0.0"
description = "High-Frequency Detail Sampling based on Res Sampling for ComfyUI"
readme = "README.md"
requires-python = ">=3.10"
license = { text = "MIT License" }
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Environment :: GPU :: NVIDIA CUDA",
"Environment :: GPU :: AMD ROCm",
"Environment :: GPU :: Apple Metal"
]
dynamic = ["dependencies"]
[tool.setuptools.dynamic]
dependencies = { file = ["requirements.txt"] }
[project.urls]
Repository = "https://github.com/WASasquatch/RES4SHO"
"Bug Tracker" = "https://github.com/WASasquatch/RES4SHO/issues"
[tool.comfy]
PublisherId = "was"
DisplayName = "RES4SHO"
requires-comfyui = ">=1.0.0"
+1927
View File
File diff suppressed because it is too large Load Diff