mirror of
https://github.com/jags111/efficiency-nodes-comfyui.git
synced 2026-05-07 01:06:42 -03:00
Compare commits
3 Commits
copilot/se
...
copilot/se
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
96a32d8499 | ||
|
|
83a08492ef | ||
|
|
77031523a2 |
351
.github/copilot-instructions.md
vendored
351
.github/copilot-instructions.md
vendored
@@ -1,121 +1,306 @@
|
|||||||
# Copilot Instructions for efficiency-nodes-comfyui
|
# Copilot Instructions for Efficiency Nodes ComfyUI
|
||||||
|
|
||||||
## Project Overview
|
## Repository Overview
|
||||||
|
|
||||||
This repository contains **Efficiency Nodes for ComfyUI** — a collection of custom nodes for [ComfyUI](https://github.com/comfyanonymous/ComfyUI) that streamline AI image generation workflows and reduce total node count. The project is maintained by jags111 and is a fork/continuation of the original work by Luciano Cirino.
|
This repository provides custom efficiency nodes for [ComfyUI](https://github.com/comfyanonymous/ComfyUI), a powerful node-based UI for Stable Diffusion. The nodes streamline workflows by combining multiple operations into efficient, cached, and preview-enabled nodes.
|
||||||
|
|
||||||
## Repository Structure
|
## Project Structure
|
||||||
|
|
||||||
```
|
- **`efficiency_nodes.py`**: Main file containing all 45+ node class definitions (primary implementation file)
|
||||||
efficiency-nodes-comfyui/
|
- **`tsc_utils.py`**: Utility functions for caching, tensor operations, and console messaging
|
||||||
├── efficiency_nodes.py # Main file containing all node class definitions
|
- **`__init__.py`**: Entry point that exports NODE_CLASS_MAPPINGS for ComfyUI
|
||||||
├── tsc_utils.py # Utility functions (model caching, loading, helpers)
|
- **`py/`**: Specialized modules for upscaling, sampling, encoding, and tiling
|
||||||
├── __init__.py # Package entry point, registers WEB_DIRECTORY and exports
|
- **`node_settings.json`**: Configuration for model caching behavior
|
||||||
├── pyproject.toml # Project metadata and ComfyUI registry config
|
- **`requirements.txt`**: Python dependencies (clip-interrogator, simpleeval)
|
||||||
├── requirements.txt # Python dependencies
|
|
||||||
├── arial.ttf # Font used for image annotation nodes
|
|
||||||
├── node_settings.json # Default node settings
|
|
||||||
├── py/ # Helper modules (samplers, encoders, upscalers)
|
|
||||||
│ ├── bnk_adv_encode.py # Advanced CLIP text encoding
|
|
||||||
│ ├── bnk_tiled_samplers.py
|
|
||||||
│ ├── city96_latent_upscaler.py
|
|
||||||
│ ├── smZ_cfg_denoiser.py
|
|
||||||
│ └── ...
|
|
||||||
├── js/ # Frontend JavaScript for ComfyUI web interface
|
|
||||||
│ ├── appearance.js # Node color themes
|
|
||||||
│ ├── seedcontrol.js # Seed widget behavior
|
|
||||||
│ ├── widgethider.js # Dynamic widget visibility
|
|
||||||
│ └── node_options/ # Right-click context menu additions
|
|
||||||
└── workflows/ # Example workflow JSON files
|
|
||||||
```
|
|
||||||
|
|
||||||
## Architecture & Key Conventions
|
## Core Architecture
|
||||||
|
|
||||||
### Node Class Pattern
|
### Node Pattern
|
||||||
|
|
||||||
All nodes follow the ComfyUI node pattern:
|
All custom nodes follow the ComfyUI standard structure:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
class TSC_MyNode:
|
class TSC_NodeName:
|
||||||
@classmethod
|
@classmethod
|
||||||
def INPUT_TYPES(cls):
|
def INPUT_TYPES(cls):
|
||||||
return {
|
return {
|
||||||
"required": { "param": ("TYPE", {"default": value}) },
|
"required": {...}, # Required inputs
|
||||||
"optional": { "opt_param": ("TYPE",) },
|
"optional": {...}, # Optional inputs
|
||||||
"hidden": { "my_unique_id": "UNIQUE_ID" }
|
"hidden": {...} # Hidden inputs (UNIQUE_ID, PROMPT)
|
||||||
}
|
}
|
||||||
|
|
||||||
RETURN_TYPES = ("TYPE1", "TYPE2",)
|
RETURN_TYPES = ("TYPE1", "TYPE2")
|
||||||
RETURN_NAMES = ("name1", "name2",)
|
RETURN_NAMES = ("output1", "output2")
|
||||||
FUNCTION = "execute_method"
|
FUNCTION = "method_name"
|
||||||
CATEGORY = "Efficiency Nodes/Category"
|
CATEGORY = "Efficiency Nodes/SubCategory"
|
||||||
|
|
||||||
def execute_method(self, param, opt_param=None, my_unique_id=None):
|
def method_name(self, **kwargs):
|
||||||
# implementation
|
# Node logic here
|
||||||
return (result1, result2,)
|
return (result1, result2)
|
||||||
```
|
```
|
||||||
|
|
||||||
- All node classes are prefixed with `TSC_`
|
### Naming Conventions
|
||||||
- `FUNCTION` must match the name of the method that executes the node
|
|
||||||
- `CATEGORY` uses the `"Efficiency Nodes/..."` namespace for grouping in the ComfyUI UI
|
|
||||||
- Nodes with side effects (saving images, printing) should set `OUTPUT_NODE = True`
|
|
||||||
|
|
||||||
### Node Registration
|
- **Classes**: Use `TSC_` prefix (creator's initials) + descriptive name in PascalCase
|
||||||
|
- Examples: `TSC_EfficientLoader`, `TSC_KSampler`, `TSC_XYplot`
|
||||||
|
- **Methods**: Use snake_case for all methods
|
||||||
|
- **Constants**: Use UPPER_SNAKE_CASE for module-level constants
|
||||||
|
|
||||||
Nodes are registered at the bottom of `efficiency_nodes.py` by updating `NODE_CLASS_MAPPINGS`:
|
### Custom Data Types
|
||||||
|
|
||||||
|
The repository defines several custom types for workflow composition:
|
||||||
|
|
||||||
|
- `LORA_STACK`: Tuple for stacking multiple LoRA models
|
||||||
|
- `CONTROL_NET_STACK`: Tuple for stacking ControlNet configurations
|
||||||
|
- `SCRIPT`: Type for chaining script operations (XY Plot, HighRes-Fix, etc.)
|
||||||
|
- `XY`: Type for XY plot data
|
||||||
|
- `SDXL_TUPLE`: SDXL-specific configuration tuple
|
||||||
|
|
||||||
|
## Key Patterns
|
||||||
|
|
||||||
|
### 1. Wrapper Pattern
|
||||||
|
|
||||||
|
Efficiency nodes wrap base ComfyUI nodes to add features:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
NODE_CLASS_MAPPINGS = {
|
# Wraps KSampler with caching, preview, and script support
|
||||||
"KSampler (Efficient)": TSC_KSampler,
|
class TSC_KSampler:
|
||||||
"Efficient Loader": TSC_EfficientLoader,
|
def sample(self, ...):
|
||||||
# ...
|
# Check cache
|
||||||
|
# Execute base KSampler
|
||||||
|
# Store results
|
||||||
|
# Handle script execution
|
||||||
|
# Return enhanced output
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. Caching System
|
||||||
|
|
||||||
|
Use the caching utilities from `tsc_utils.py`:
|
||||||
|
|
||||||
|
```python
|
||||||
|
from tsc_utils import load_ksampler_results, store_ksampler_results
|
||||||
|
|
||||||
|
# Load cached results
|
||||||
|
cached = load_ksampler_results(unique_id, prompt)
|
||||||
|
|
||||||
|
# Store results for future use
|
||||||
|
store_ksampler_results(unique_id, prompt, results)
|
||||||
|
```
|
||||||
|
|
||||||
|
**Important**: Cache operations use `unique_id` and `prompt` from hidden inputs to ensure per-instance caching.
|
||||||
|
|
||||||
|
### 3. Stack Pattern
|
||||||
|
|
||||||
|
Support stacking for composable workflows:
|
||||||
|
|
||||||
|
```python
|
||||||
|
"optional": {
|
||||||
|
"lora_stack": ("LORA_STACK",),
|
||||||
|
"cnet_stack": ("CONTROL_NET_STACK",),
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Optional features (requiring extra packages like `simpleeval` or `animatediff`) are wrapped in `try/except ImportError` blocks and registered conditionally.
|
### 4. Script System
|
||||||
|
|
||||||
### Model Caching (tsc_utils.py)
|
Nodes can execute scripts for advanced workflows:
|
||||||
|
|
||||||
The `loaded_objects` and `last_helds` globals in `tsc_utils.py` implement a caching layer to avoid reloading models between node executions:
|
```python
|
||||||
|
"optional": {
|
||||||
|
"script": ("SCRIPT",),
|
||||||
|
}
|
||||||
|
|
||||||
- `loaded_objects["ckpt"]` — checkpoints
|
# In node execution:
|
||||||
- `loaded_objects["lora"]` — LoRA weights
|
if script:
|
||||||
- `loaded_objects["vae"]` — VAE models
|
# Execute script logic (XY Plot, HighRes-Fix, etc.)
|
||||||
- `last_helds["latent"]` / `last_helds["image"]` — KSampler output caches
|
```
|
||||||
|
|
||||||
Always call `globals_cleanup(prompt)` at the start of loader nodes to evict stale cache entries.
|
### 5. Dynamic UI Inputs
|
||||||
|
|
||||||
### Frontend JavaScript
|
Use `folder_paths` for dynamic dropdown population:
|
||||||
|
|
||||||
- JS files in `js/` are served by ComfyUI via `WEB_DIRECTORY = "js"` in `__init__.py`
|
```python
|
||||||
- Extensions are registered with `app.registerExtension({ name: "efficiency.<name>", ... })`
|
import folder_paths
|
||||||
- Use `import { app } from "../../scripts/app.js"` for ComfyUI's app object
|
|
||||||
- Widget helpers (`findWidgetByName`, `addMenuHandler`) are in `js/node_options/common/utils.js`
|
"required": {
|
||||||
|
"ckpt_name": (folder_paths.get_filename_list("checkpoints"),),
|
||||||
|
"vae_name": (["Baked VAE"] + folder_paths.get_filename_list("vae"),),
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
|
|
||||||
- **Python**: `torch`, `PIL` (Pillow), `numpy`, `comfy` (ComfyUI), `folder_paths`
|
### Required
|
||||||
- **Optional Python**: `simpleeval` (Evaluate nodes), `clip_interrogator` (CLIP Interrogator node)
|
|
||||||
- **ComfyUI extras**: `comfy_extras.nodes_align_your_steps`, `comfy_extras.nodes_gits`, `comfy_extras.nodes_upscale_model`
|
|
||||||
|
|
||||||
## Development Guidelines
|
- **PyTorch**: Core tensor operations
|
||||||
|
- **PIL**: Image processing
|
||||||
|
- **NumPy**: Array operations
|
||||||
|
- **clip-interrogator**: Image captioning
|
||||||
|
- **simpleeval**: Safe expression evaluation
|
||||||
|
|
||||||
- **Do not break the node contract**: Changing `RETURN_TYPES`, `RETURN_NAMES`, or `INPUT_TYPES` on existing nodes is a breaking change for saved workflows.
|
### ComfyUI Integration
|
||||||
- **Cache awareness**: When modifying loader nodes, preserve calls to `globals_cleanup()` and the caching functions (`load_checkpoint`, `load_lora`, `load_vae`).
|
|
||||||
- **Error messages**: Use the `warning()` and `error()` helpers from `tsc_utils.py` for consistent console output formatting.
|
|
||||||
- **Optional imports**: Wrap any new optional feature dependencies in `try/except ImportError` and print a warning when the package is missing.
|
|
||||||
- **Node naming**: Use the `TSC_` prefix for new node classes. Register them in `NODE_CLASS_MAPPINGS` with a human-readable display name (e.g., `"My New Node": TSC_MyNewNode`).
|
|
||||||
- **JS extensions**: Follow the existing pattern of using `app.registerExtension` with the `"efficiency.<extensionName>"` naming convention.
|
|
||||||
|
|
||||||
## Testing & Validation
|
The code integrates with ComfyUI via `sys.path` manipulation:
|
||||||
|
|
||||||
There is no automated test suite. Validation is done by loading the nodes in a running ComfyUI instance:
|
```python
|
||||||
|
# Pattern used throughout codebase
|
||||||
|
comfy_dir = os.path.abspath(os.path.join(my_dir, '..', '..'))
|
||||||
|
sys.path.append(comfy_dir)
|
||||||
|
from comfy import samplers, sd, utils
|
||||||
|
# ... imports ...
|
||||||
|
sys.path.remove(comfy_dir)
|
||||||
|
```
|
||||||
|
|
||||||
1. Install ComfyUI and place this package in `ComfyUI/custom_nodes/efficiency-nodes-comfyui/`
|
### Optional Dependencies
|
||||||
2. Start ComfyUI and check the console for import errors
|
|
||||||
3. Open the ComfyUI web interface and verify nodes appear under the `Efficiency Nodes` menu category
|
|
||||||
4. Load example workflows from the `workflows/` directory to test node behavior
|
|
||||||
|
|
||||||
## Publishing
|
- **comfyui_controlnet_aux**: ControlNet preprocessing
|
||||||
|
- **ComfyUI-AnimateDiff-Evolved**: AnimateDiff support
|
||||||
|
|
||||||
The package is published to the [ComfyUI Registry](https://registry.comfy.org/) via the GitHub Actions workflow `.github/workflows/publish.yml`, triggered when `pyproject.toml` is updated on `main`. Update the `version` field in `pyproject.toml` for each release.
|
Handle optional dependencies gracefully:
|
||||||
|
|
||||||
|
```python
|
||||||
|
try:
|
||||||
|
import optional_module
|
||||||
|
NODE_CLASS_MAPPINGS.update({"Node Name": NodeClass})
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
|
```
|
||||||
|
|
||||||
|
## Node Registration
|
||||||
|
|
||||||
|
Nodes are registered in `NODE_CLASS_MAPPINGS` dictionary:
|
||||||
|
|
||||||
|
```python
|
||||||
|
NODE_CLASS_MAPPINGS = {
|
||||||
|
"Display Name": TSC_ClassName,
|
||||||
|
"KSampler (Efficient)": TSC_KSampler,
|
||||||
|
"Efficient Loader": TSC_EfficientLoader,
|
||||||
|
# ... more nodes
|
||||||
|
}
|
||||||
|
|
||||||
|
# Optional nodes added conditionally
|
||||||
|
try:
|
||||||
|
from simpleeval import simple_eval
|
||||||
|
NODE_CLASS_MAPPINGS.update({
|
||||||
|
"Simple Eval Examples": TSC_SimpleEval,
|
||||||
|
})
|
||||||
|
except ImportError:
|
||||||
|
print("simpleeval not installed, skipping related nodes")
|
||||||
|
```
|
||||||
|
|
||||||
|
## Code Style Guidelines
|
||||||
|
|
||||||
|
### Imports
|
||||||
|
|
||||||
|
1. Standard library imports first
|
||||||
|
2. Third-party imports (torch, PIL, numpy)
|
||||||
|
3. ComfyUI imports (with path manipulation)
|
||||||
|
4. Local imports (tsc_utils, py modules)
|
||||||
|
|
||||||
|
### Error Handling
|
||||||
|
|
||||||
|
Use the colored messaging functions from `tsc_utils.py`:
|
||||||
|
|
||||||
|
```python
|
||||||
|
from tsc_utils import error, warning, success
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Operation
|
||||||
|
success("Operation completed")
|
||||||
|
except Exception as e:
|
||||||
|
error(f"Operation failed: {e}")
|
||||||
|
```
|
||||||
|
|
||||||
|
### Input Validation
|
||||||
|
|
||||||
|
Validate inputs in the INPUT_TYPES definition:
|
||||||
|
|
||||||
|
```python
|
||||||
|
"seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff}),
|
||||||
|
"steps": ("INT", {"default": 20, "min": 1, "max": 10000}),
|
||||||
|
"cfg": ("FLOAT", {"default": 8.0, "min": 0.0, "max": 100.0}),
|
||||||
|
"sampler_name": (comfy.samplers.KSampler.SAMPLERS,),
|
||||||
|
```
|
||||||
|
|
||||||
|
## Testing and Validation
|
||||||
|
|
||||||
|
This repository does not have formal unit tests. Changes should be validated by:
|
||||||
|
|
||||||
|
1. **Import Test**: Verify `__init__.py` imports successfully
|
||||||
|
2. **ComfyUI Integration**: Load nodes in ComfyUI UI and verify they appear
|
||||||
|
3. **Workflow Test**: Create test workflows and verify node functionality
|
||||||
|
4. **Error Testing**: Test edge cases and ensure graceful error messages
|
||||||
|
|
||||||
|
## Common Patterns to Follow
|
||||||
|
|
||||||
|
### Adding a New Node
|
||||||
|
|
||||||
|
1. Create class with `TSC_` prefix
|
||||||
|
2. Define `INPUT_TYPES`, `RETURN_TYPES`, `FUNCTION`, `CATEGORY`
|
||||||
|
3. Implement the function method
|
||||||
|
4. Add to `NODE_CLASS_MAPPINGS`
|
||||||
|
5. Test in ComfyUI workflow
|
||||||
|
|
||||||
|
### Adding Optional Features
|
||||||
|
|
||||||
|
1. Wrap in try/except for dependency checking
|
||||||
|
2. Use `.update()` to add to NODE_CLASS_MAPPINGS
|
||||||
|
3. Provide fallback or skip if dependency missing
|
||||||
|
4. Print informative message about missing dependency
|
||||||
|
|
||||||
|
### Working with Models
|
||||||
|
|
||||||
|
1. Use `folder_paths` for model discovery
|
||||||
|
2. Implement caching via `tsc_utils` functions
|
||||||
|
3. Store loaded models in `loaded_objects` dict with unique IDs
|
||||||
|
4. Handle model loading errors gracefully
|
||||||
|
|
||||||
|
### Handling UI Updates
|
||||||
|
|
||||||
|
1. Use hidden inputs for `UNIQUE_ID` and `PROMPT` tracking
|
||||||
|
2. Return UI update dictionaries when needed
|
||||||
|
3. Follow ComfyUI's output format for preview images
|
||||||
|
|
||||||
|
## Performance Considerations
|
||||||
|
|
||||||
|
- **Caching**: Always use caching for expensive operations (model loading, sampling)
|
||||||
|
- **Memory**: Be mindful of GPU memory with large models
|
||||||
|
- **Preview**: Implement progressive preview for long operations
|
||||||
|
- **Batching**: Support batch processing where applicable
|
||||||
|
|
||||||
|
## Documentation
|
||||||
|
|
||||||
|
- Update README.md for new nodes
|
||||||
|
- Add examples to the [project Wiki](https://github.com/jags111/efficiency-nodes-comfyui/wiki)
|
||||||
|
- Include workflow JSON examples for complex nodes
|
||||||
|
- Document any new configuration options in `node_settings.json`
|
||||||
|
|
||||||
|
## Key Files to Understand
|
||||||
|
|
||||||
|
1. **efficiency_nodes.py**: Study existing nodes for patterns
|
||||||
|
2. **tsc_utils.py**: Understand caching and utility functions
|
||||||
|
3. **py/bnk_adv_encode.py**: Advanced CLIP encoding examples
|
||||||
|
4. **py/smZ_cfg_denoiser.py**: Custom denoiser implementation
|
||||||
|
5. **__init__.py**: Entry point and version management
|
||||||
|
|
||||||
|
## ComfyUI-Specific Tips
|
||||||
|
|
||||||
|
- Nodes are instantiated fresh for each workflow execution
|
||||||
|
- Use `UNIQUE_ID` from hidden inputs for per-node-instance state
|
||||||
|
- `PROMPT` contains the full workflow graph
|
||||||
|
- Return types must match RETURN_TYPES exactly
|
||||||
|
- UI widgets are defined in INPUT_TYPES with tuples
|
||||||
|
- Use `folder_paths` for discovering models/resources
|
||||||
|
|
||||||
|
## Version Information
|
||||||
|
|
||||||
|
- Current version: 2.0+ (see `CC_VERSION` in `__init__.py`)
|
||||||
|
- Published to ComfyUI registry via `pyproject.toml`
|
||||||
|
- Auto-publishes on main branch when `pyproject.toml` changes
|
||||||
|
|
||||||
|
## Resources
|
||||||
|
|
||||||
|
- [ComfyUI Repository](https://github.com/comfyanonymous/ComfyUI)
|
||||||
|
- [Project Wiki](https://github.com/jags111/efficiency-nodes-comfyui/wiki)
|
||||||
|
- [Project README](../README.md)
|
||||||
|
- Original author: Luciano Cirino (TSC)
|
||||||
|
- Current maintainer: jags111
|
||||||
|
|||||||
272
README.md
272
README.md
@@ -249,275 +249,3 @@ Thank you for being awesome!
|
|||||||
|
|
||||||
<!-- end support-pitch -->
|
<!-- end support-pitch -->
|
||||||
|
|
||||||
✨🍬Planning to help this branch stay alive and any issues will try to solve or fix .. But will be slow as I run many github repos . before raising any issues, please update comfyUI to the latest and esnure all the required packages are updated ass well. Share your workflow in issues to retest same at our end and update the patch.🍬
|
|
||||||
|
|
||||||
|
|
||||||
<b> Efficiency Nodes for ComfyUI Version 2.0+
|
|
||||||
=======
|
|
||||||
### A collection of <a href="https://github.com/comfyanonymous/ComfyUI" >ComfyUI</a> custom nodes to help streamline workflows and reduce total node count.
|
|
||||||
## Releases
|
|
||||||
|
|
||||||
Please check out our WIKI for any use cases and new developments including workflow and settings.<br>
|
|
||||||
[Efficiency Nodes Wiki](https://github.com/jags111/efficiency-nodes-comfyui/wiki)<br>
|
|
||||||
|
|
||||||
### Nodes:
|
|
||||||
<!-------------------------------------------------------------------------------------------------------------------------------------------------------->
|
|
||||||
<details>
|
|
||||||
<summary><b>Efficient Loader</b> & <b>Eff. Loader SDXL</b></summary>
|
|
||||||
<ul>
|
|
||||||
<li>Nodes that can load & cache Checkpoint, VAE, & LoRA type models. <i>(cache settings found in config file 'node_settings.json')</i></li>
|
|
||||||
<li>Able to apply LoRA & Control Net stacks via their <code>lora_stack</code> and <code>cnet_stack</code> inputs.</li>
|
|
||||||
<li>Come with positive and negative prompt text boxes. You can also set the way you want the prompt to be <a href="https://github.com/BlenderNeko/ComfyUI_ADV_CLIP_emb">encoded</a> via the <code>token_normalization</code> and <code>weight_interpretation</code> widgets.</li>
|
|
||||||
<li>These node's also feature a variety of custom menu options as shown below.
|
|
||||||
<p></p><img src="https://github.com/LucianoCirino/efficiency-nodes-media/blob/main/images/nodes//NodeMenu%20-%20Efficient%20Loaders.png" width="240" style="display: inline-block;"></p>
|
|
||||||
<p><i>note: "🔍 View model info..." requires <a href="https://github.com/pythongosssss/ComfyUI-Custom-Scripts">ComfyUI-Custom-Scripts</a> to be installed to function.</i></p></li>
|
|
||||||
<li>These loaders are used by the <b>XY Plot</b> node for many of its plot type dependencies.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<p align="center">
|
|
||||||
<img src="https://github.com/LucianoCirino/efficiency-nodes-media/blob/main/images/nodes/NODE%20-%20Efficient%20Loader.png" width="240" style="display: inline-block;">
|
|
||||||
<img src="https://github.com/LucianoCirino/efficiency-nodes-media/blob/main/images/nodes/NODE%20-%20Eff.%20Loader%20SDXL.png" width="240" style="display: inline-block;">
|
|
||||||
</p>
|
|
||||||
</details>
|
|
||||||
<!-------------------------------------------------------------------------------------------------------------------------------------------------------->
|
|
||||||
<details>
|
|
||||||
<summary><b>KSampler (Efficient)</b>, <b>KSampler Adv. (Efficient)</b>, <b>KSampler SDXL (Eff.)</b></summary>
|
|
||||||
|
|
||||||
- Modded KSamplers with the ability to live preview generations and/or vae decode images.
|
|
||||||
- Feature a special seed box that allows for a clearer management of seeds. <i>(-1 seed to apply the selected seed behavior)</i>
|
|
||||||
- Can execute a variety of scripts, such as the <b>XY Plot</b> script. To activate the <code>script</code>, simply connect the input connection.
|
|
||||||
|
|
||||||
<p align="center">
|
|
||||||
<img src="https://github.com/LucianoCirino/efficiency-nodes-media/blob/main/images/nodes/NODE%20-%20KSampler%20(Efficient).png" width="240">
|
|
||||||
|
|
||||||
<img src="https://github.com/LucianoCirino/efficiency-nodes-media/blob/main/images/nodes/NODE%20-%20KSampler%20Adv.%20(Efficient).png" width="240">
|
|
||||||
|
|
||||||
<img src="https://github.com/LucianoCirino/efficiency-nodes-media/blob/main/images/nodes/NODE%20-%20KSampler%20SDXL%20(Eff.).png" width="240">
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</details>
|
|
||||||
<!-------------------------------------------------------------------------------------------------------------------------------------------------------->
|
|
||||||
<details>
|
|
||||||
<summary><b>Script Nodes</b></summary>
|
|
||||||
|
|
||||||
- A group of node's that are used in conjuction with the Efficient KSamplers to execute a variety of 'pre-wired' set of actions.
|
|
||||||
- Script nodes can be chained if their input/outputs allow it. Multiple instances of the same Script Node in a chain does nothing.
|
|
||||||
<p align="center">
|
|
||||||
<img src="https://github.com/LucianoCirino/efficiency-nodes-media/blob/main/images/nodes/ScriptChain.png" width="1080">
|
|
||||||
</p>
|
|
||||||
<!-------------------------------------------------------------------------------------------------------------------------------------------------------->
|
|
||||||
<details>
|
|
||||||
<summary><b>XY Plot</b></summary>
|
|
||||||
<ul>
|
|
||||||
<li>Node that allows users to specify parameters for the Efficiency KSamplers to plot on a grid.</li>
|
|
||||||
</ul>
|
|
||||||
<p align="center">
|
|
||||||
<img src="https://github.com/LucianoCirino/efficiency-nodes-media/blob/main/images/nodes/XY%20Plot%20-%20Node%20Example.png" width="1080">
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</details>
|
|
||||||
<!-------------------------------------------------------------------------------------------------------------------------------------------------------->
|
|
||||||
<details>
|
|
||||||
<summary><b>HighRes-Fix</b></summary>
|
|
||||||
<ul>
|
|
||||||
<li>Node that the gives user the ability to upscale KSampler results through variety of different methods.</li>
|
|
||||||
<li>Comes out of the box with popular Neural Network Latent Upscalers such as Ttl's <a href="https://github.com/Ttl/ComfyUi_NNLatentUpscale">ComfyUi_NNLatentUpscale</a> and City96's <a href="https://github.com/city96/SD-Latent-Upscaler">SD-Latent-Upscaler</a>.</li>
|
|
||||||
<li>Supports ControlNet guided latent upscaling. <i> (You must have Fannovel's <a href="https://github.com/Fannovel16/comfyui_controlnet_aux">comfyui_controlnet_aux</a> installed to unlock this feature)</i></li>
|
|
||||||
<li> Local models---The node pulls the required files from huggingface hub by default. You can create a models folder and place the modules there if you have a flaky connection or prefer to use it completely offline, it will load them locally instead. The path should be: ComfyUI/custom_nodes/efficiency-nodes-comfyui/models; Alternatively, just clone the entire HF repo to it: (git clone https://huggingface.co/city96/SD-Latent-Upscaler) to ComfyUI/custom_nodes/efficiency-nodes-comfyui/models</li>
|
|
||||||
</ul>
|
|
||||||
<p align="center">
|
|
||||||
<img src="https://github.com/LucianoCirino/efficiency-nodes-media/blob/main/images/nodes/HighResFix%20-%20Node%20Example.gif" width="1080">
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</details>
|
|
||||||
<!-------------------------------------------------------------------------------------------------------------------------------------------------------->
|
|
||||||
<details>
|
|
||||||
<summary><b>Noise Control</b></summary>
|
|
||||||
<ul>
|
|
||||||
<li>This node gives the user the ability to manipulate noise sources in a variety of ways, such as the sampling's RNG source.</li>
|
|
||||||
<li>The <a href="https://github.com/shiimizu/ComfyUI_smZNodes">CFG Denoiser</a> noise hijack was developed by smZ, it allows you to get closer recreating Automatic1111 results.</li>
|
|
||||||
<p></p><i>Note: The CFG Denoiser does not work with a variety of conditioning types such as ControlNet & GLIGEN</i></p>
|
|
||||||
<li>This node also allows you to add noise <a href="https://github.com/chrisgoringe/cg-noise">Seed Variations</a> to your generations.</li>
|
|
||||||
<li>For trying to replicate Automatic1111 images, this node will help you achieve it. Encode your prompt using "length+mean" <code>token_normalization</code> with "A1111" <code>weight_interpretation</code>, set the Noise Control Script node's <code>rng_source</code> to "gpu", and turn the <code>cfg_denoiser</code> to true.</li>
|
|
||||||
</ul>
|
|
||||||
<p align="center">
|
|
||||||
<img src="https://github.com/LucianoCirino/efficiency-nodes-media/blob/main/images/nodes/NODE%20-%20Noise%20Control%20Script.png" width="320">
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</details>
|
|
||||||
<!-------------------------------------------------------------------------------------------------------------------------------------------------------->
|
|
||||||
<details>
|
|
||||||
<summary><b>Tiled Upscaler</b></summary>
|
|
||||||
<ul>
|
|
||||||
<li>The Tiled Upscaler script attempts to encompas BlenderNeko's <a href="https://github.com/BlenderNeko/ComfyUI_TiledKSampler">ComfyUI_TiledKSampler</a> workflow into 1 node.</li>
|
|
||||||
<li>Script supports Tiled ControlNet help via the options.</li>
|
|
||||||
<li>Strongly recommend the <code>preview_method</code> be "vae_decoded_only" when running the script.</li>
|
|
||||||
</ul>
|
|
||||||
<p align="center">
|
|
||||||
<img src="https://github.com/LucianoCirino/efficiency-nodes-media/blob/main/images/nodes/Tiled%20Upscaler%20-%20Node%20Example.gif" width="1080">
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</details>
|
|
||||||
<!-------------------------------------------------------------------------------------------------------------------------------------------------------->
|
|
||||||
<details>
|
|
||||||
<summary><b>AnimateDiff</b></summary>
|
|
||||||
<ul>
|
|
||||||
<li>To unlock the AnimateDiff script it is required you have installed Kosinkadink's <a href="https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved">ComfyUI-AnimateDiff-Evolved</a>.</li>
|
|
||||||
<li>The latent <code>batch_size</code> when running this script becomes your frame count.</li>
|
|
||||||
</ul>
|
|
||||||
<p align="center">
|
|
||||||
<img src="https://github.com/LucianoCirino/efficiency-nodes-media/blob/main/images/nodes/AnimateDiff%20-%20Node%20Example.gif" width="1080">
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</details>
|
|
||||||
</details>
|
|
||||||
|
|
||||||
<!-------------------------------------------------------------------------------------------------------------------------------------------------------->
|
|
||||||
<details>
|
|
||||||
<summary><b>Image Overlay</b></summary>
|
|
||||||
<ul>
|
|
||||||
<li>Node that allows for flexible image overlaying. Works also with image batches.</li>
|
|
||||||
</ul>
|
|
||||||
<p align="center">
|
|
||||||
<img src="https://github.com/LucianoCirino/efficiency-nodes-media/blob/main/images/nodes/Image%20Overlay%20-%20Node%20Example.png" width="1080">
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</details>
|
|
||||||
<!-------------------------------------------------------------------------------------------------------------------------------------------------------->
|
|
||||||
<details>
|
|
||||||
<summary><b>SimpleEval Nodes</b></summary>
|
|
||||||
<ul>
|
|
||||||
<li>A collection of nodes that allows users to write simple Python expressions for a variety of data types using the <i><a href="https://github.com/danthedeckie/simpleeval" >simpleeval</a></i> library.</li>
|
|
||||||
<li>To activate you must have installed the simpleeval library in your Python workspace.</li>
|
|
||||||
<pre>pip install simpleeval</pre>
|
|
||||||
</ul>
|
|
||||||
<p align="center">
|
|
||||||
<img src="https://github.com/LucianoCirino/efficiency-nodes-media/blob/main/images/nodes/NODE%20-%20Evaluate%20Integers.png" width="320">
|
|
||||||
|
|
||||||
<img src="https://github.com/LucianoCirino/efficiency-nodes-media/blob/main/images/nodes/NODE%20-%20Evaluate%20Floats.png" width="320">
|
|
||||||
|
|
||||||
<img src="https://github.com/LucianoCirino/efficiency-nodes-media/blob/main/images/nodes/NODE%20-%20Evaluate%20Strings.png" width="320">
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</details>
|
|
||||||
|
|
||||||
<!-------------------------------------------------------------------------------------------------------------------------------------------------------->
|
|
||||||
<details>
|
|
||||||
<summary><b>Latent Upscale nodes</b></summary>
|
|
||||||
<ul>
|
|
||||||
<li>Forked from NN latent this node provides some remarkable neural enhancement to the latents making scaling a cool task</li>
|
|
||||||
<li>Both NN latent upscale and Latent upscaler does the Latent improvemnet in remarkable ways. If you face any issue regarding same please install the nodes from this link([SD-Latent-Upscaler](https://github.com/city96/SD-Latent-Upscaler) and the NN latent upscale from [ComfyUI_NNlatentUpscale](https://github.com/Ttl/ComfyUi_NNLatentUpscale) </li>
|
|
||||||
|
|
||||||
</ul>
|
|
||||||
<p align="center">
|
|
||||||
<img src="images/2023-12-08_19-53-37.png" width="320">
|
|
||||||
|
|
||||||
<img src="images/2023-12-08_19-54-11.png" width="320">
|
|
||||||
|
|
||||||
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</details>
|
|
||||||
|
|
||||||
## Workflow Examples:
|
|
||||||
|
|
||||||
Kindly load all PNG files in same name in the (workflow driectory) to comfyUI to get all this workflows. The PNG files have the json embedded into them and are easy to drag and drop !<br>
|
|
||||||
|
|
||||||
1. HiRes-Fixing<br>
|
|
||||||
[<img src="https://github.com/jags111/efficiency-nodes-comfyui/blob/main/workflows/HiResfix_workflow.png" width="800">](https://github.com/jags111/efficiency-nodes-comfyui/blob/main/workflows/HiResfix_workflow.png)<br>
|
|
||||||
|
|
||||||
2. SDXL Refining & **Noise Control Script**<br>
|
|
||||||
[<img src="https://github.com/jags111/efficiency-nodes-comfyui/blob/main/workflows/SDXL_base_refine_noise_workflow.png" width="800">](https://github.com/jags111/efficiency-nodes-comfyui/blob/main/workflows/SDXL_base_refine_noise_workflow.png)<br>
|
|
||||||
|
|
||||||
3. **XY Plot**: LoRA <code>model_strength</code> vs <code>clip_strength</code><br>
|
|
||||||
[<img src="https://github.com/jags111/efficiency-nodes-comfyui/blob/main/workflows/Eff_XYPlot%20-%20LoRA%20Model%20vs%20Clip%20Strengths01.png" width="800">](https://github.com/jags111/efficiency-nodes-comfyui/blob/main/workflows/Eff_XYPlot%20-%20LoRA%20Model%20vs%20Clip%20Strengths01.png)<br>
|
|
||||||
|
|
||||||
4. Stacking Scripts: **XY Plot** + **Noise Control** + **HiRes-Fix**<br>
|
|
||||||
[<img src="https://github.com/LucianoCirino/efficiency-nodes-comfyui/blob/v2.0/workflows/XYPlot%20-%20Seeds%20vs%20Checkpoints%20%26%20Stacked%20Scripts.png" width="800">](https://github.com/LucianoCirino/efficiency-nodes-comfyui/blob/v2.0/workflows/XYPlot%20-%20Seeds%20vs%20Checkpoints%20%26%20Stacked%20Scripts.png)<br>
|
|
||||||
|
|
||||||
5. Stacking Scripts: **HiRes-Fix** (with ControlNet)<br>
|
|
||||||
[<img src="https://github.com/jags111/efficiency-nodes-comfyui/blob/main/workflows/eff_animatescriptWF001.gif" width="800">](https://github.com/jags111/efficiency-nodes-comfyui/blob/main/workflows/eff_animatescriptWF001.gif)<br>
|
|
||||||
|
|
||||||
6. SVD workflow: **Stable Video Diffusion** + *Kohya Hires** (with latent control)<br>
|
|
||||||
<br>
|
|
||||||
|
|
||||||
|
|
||||||
### Dependencies
|
|
||||||
The python library <i><a href="https://github.com/danthedeckie/simpleeval" >simpleeval</a></i> is required to be installed if you wish to use the **Simpleeval Nodes**.
|
|
||||||
<pre>pip install simpleeval</pre>
|
|
||||||
Also can be installed with a simple pip command <br>
|
|
||||||
'pip install simpleeval'
|
|
||||||
|
|
||||||
A single file library for easily adding evaluatable expressions into python projects. Say you want to allow a user to set an alarm volume, which could depend on the time of day, alarm level, how many previous alarms had gone off, and if there is music playing at the time.
|
|
||||||
|
|
||||||
check Notes for more information.
|
|
||||||
|
|
||||||
## **Install:**
|
|
||||||
To install, drop the "_**efficiency-nodes-comfyui**_" folder into the "_**...\ComfyUI\ComfyUI\custom_nodes**_" directory and restart UI.
|
|
||||||
|
|
||||||
## Todo
|
|
||||||
|
|
||||||
[ ] Add guidance to notebook
|
|
||||||
|
|
||||||
|
|
||||||
# Comfy Resources
|
|
||||||
|
|
||||||
**Efficiency Linked Repos**
|
|
||||||
- [BlenderNeko ComfyUI_ADV_CLIP_emb](https://github.com/BlenderNeko/ComfyUI_ADV_CLIP_emb) by@BlenderNeko
|
|
||||||
- [Chrisgoringe cg-noise](https://github.com/chrisgoringe/cg-noise) by@Chrisgoringe
|
|
||||||
- [pythongosssss ComfyUI-Custom-Scripts](https://github.com/pythongosssss/ComfyUI-Custom-Scripts) by@pythongosssss
|
|
||||||
- [shiimizu ComfyUI_smZNodes](https://github.com/shiimizu/ComfyUI_smZNodes) by@shiimizu
|
|
||||||
- [LEv145_images-grid-comfyUI-plugin](https://github.com/LEv145/images-grid-comfy-plugin)) by@LEv145
|
|
||||||
- [ltdrdata-ComfyUI-Inspire-Pack](https://github.com/ltdrdata/ComfyUI-Inspire-Pack) by@ltdrdata
|
|
||||||
- [pythongosssss-ComfyUI-custom-Scripts](https://github.com/pythongosssss/ComfyUI-Custom-Scripts) by@pythongosssss
|
|
||||||
- [RockOfFire-ComfyUI_Comfyroll_CustomNodes](https://github.com/RockOfFire/ComfyUI_Comfyroll_CustomNodes) by@RockOfFire
|
|
||||||
|
|
||||||
**Guides**:
|
|
||||||
- [Official Examples (eng)](https://comfyanonymous.github.io/ComfyUI_examples/)-
|
|
||||||
- [ComfyUI Community Manual (eng)](https://blenderneko.github.io/ComfyUI-docs/) by @BlenderNeko
|
|
||||||
|
|
||||||
- **Extensions and Custom Nodes**:
|
|
||||||
- [Plugins for Comfy List (eng)](https://github.com/WASasquatch/comfyui-plugins) by @WASasquatch
|
|
||||||
- [ComfyUI tag on CivitAI (eng)](https://civitai.com/tag/comfyui)-
|
|
||||||
- [Tomoaki's personal Wiki (jap)](https://comfyui.creamlab.net/guides/) by @tjhayasaka
|
|
||||||
|
|
||||||
## Support
|
|
||||||
If you create a cool image with our nodes, please show your result and message us on twitter at @jags111 or @NeuralismAI .
|
|
||||||
|
|
||||||
You can join the <a href="https://discord.gg/vNVqT82W" alt="Neuralism Discord"> NEURALISM AI DISCORD </a> or <a href="https://discord.gg/UmSd4qyh" alt =Jags AI Discord > JAGS AI DISCORD </a>
|
|
||||||
Share your work created with this model. Exchange experiences and parameters. And see more interesting custom workflows.
|
|
||||||
|
|
||||||
Support us in Patreon for more future models and new versions of AI notebooks.
|
|
||||||
- tip me on <a href="https://www.patreon.com/jags111"> [patreon]</a>
|
|
||||||
|
|
||||||
My buymeacoffee.com pages and links are here and if you feel you are happy with my work just buy me a coffee !
|
|
||||||
|
|
||||||
<a href="https://www.buymeacoffee.com/jagsAI"> coffee for JAGS AI</a>
|
|
||||||
|
|
||||||
Thank you for being awesome!
|
|
||||||
|
|
||||||
<img src = "images/ComfyUI_temp_vpose_00005_.png" width = "50%">
|
|
||||||
|
|
||||||
<!-- end support-pitch -->
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Issue #300 Improvements
|
|
||||||
Date: 2026-03-13 17:21:22
|
|
||||||
|
|
||||||
### Changes
|
|
||||||
- Added installation instructions
|
|
||||||
- Enhanced code documentation
|
|
||||||
- Added usage examples
|
|
||||||
- Fixed broken links
|
|
||||||
|
|
||||||
### Security Enhancements
|
|
||||||
- Added input sanitization examples
|
|
||||||
- Included security best practices
|
|
||||||
- Updated error handling guidelines
|
|
||||||
|
|
||||||
### Testing
|
|
||||||
- Verified documentation accuracy
|
|
||||||
- Added test examples
|
|
||||||
|
|
||||||
Let me know if you need any clarification about this issue.
|
|
||||||
|
|||||||
@@ -221,16 +221,12 @@ def encode_token_weights_l(model, token_weight_pairs):
|
|||||||
l_out, _ = model.clip_l.encode_token_weights(token_weight_pairs)
|
l_out, _ = model.clip_l.encode_token_weights(token_weight_pairs)
|
||||||
return l_out, None
|
return l_out, None
|
||||||
|
|
||||||
def encode_token_weights(model, token_weight_pairs, encode_func):
|
def encode_token_weights(model, token_weight_pairs, encode_func):
|
||||||
# Keep CLIP options aligned with ComfyUI's core encode path so token
|
if model.layer_idx is not None:
|
||||||
# tensors are created on the same device as the active text encoder pass.
|
model.cond_stage_model.set_clip_options({"layer": model.layer_idx})
|
||||||
model.cond_stage_model.reset_clip_options()
|
|
||||||
if model.layer_idx is not None:
|
model_management.load_model_gpu(model.patcher)
|
||||||
model.cond_stage_model.set_clip_options({"layer": model.layer_idx})
|
return encode_func(model.cond_stage_model, token_weight_pairs)
|
||||||
|
|
||||||
model_management.load_model_gpu(model.patcher)
|
|
||||||
model.cond_stage_model.set_clip_options({"execution_device": model.patcher.load_device})
|
|
||||||
return encode_func(model.cond_stage_model, token_weight_pairs)
|
|
||||||
|
|
||||||
def prepareXL(embs_l, embs_g, pooled, clip_balance):
|
def prepareXL(embs_l, embs_g, pooled, clip_balance):
|
||||||
l_w = 1 - max(0, clip_balance - .5) * 2
|
l_w = 1 - max(0, clip_balance - .5) * 2
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "efficiency-nodes-comfyui"
|
name = "efficiency-nodes-comfyui"
|
||||||
description = "Efficiency Nodes for ComfyUI Version 2.0 A collection of ComfyUI custom nodes to help streamline workflows and reduce total node count."
|
description = "Efficiency Nodes for ComfyUI Version 2.0 A collection of ComfyUI custom nodes to help streamline workflows and reduce total node count."
|
||||||
version = "1.0.9"
|
version = "1.0.8"
|
||||||
license = { file = "LICENSE" }
|
license = { file = "LICENSE" }
|
||||||
dependencies = ["clip-interrogator", "simpleeval"]
|
dependencies = ["clip-interrogator", "simpleeval"]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user