Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
30bab38e89 | ||
|
|
b6d4f0beb4 | ||
|
|
827757ae82 | ||
|
|
335b69b4b8 | ||
|
|
04a0d1d3cf | ||
|
|
b54fd6fa02 | ||
|
|
438be4427f | ||
|
|
ada2b851e8 | ||
|
|
eb55ea75e1 | ||
|
|
ec67664a93 | ||
|
|
b7c0f723b2 | ||
|
|
590773f1f3 | ||
|
|
97a91a0e81 | ||
|
|
84b2ab5694 | ||
|
|
6627c15d39 | ||
|
|
b51b12e61d | ||
|
|
21c496482c | ||
|
|
57f70002b6 | ||
|
|
5abe65bf72 | ||
|
|
edd7d52628 | ||
|
|
fc4c334b80 | ||
|
|
7c0364e4fa | ||
|
|
60786c455d | ||
|
|
1f33d2d863 | ||
|
|
4b58068606 | ||
|
|
638024d67f | ||
|
|
c4beb39109 | ||
|
|
da95d17883 | ||
|
|
9d439eb92e | ||
|
|
f8cf053261 | ||
|
|
3ad46aae08 | ||
|
|
4fcc08cddf | ||
|
|
54b22247f9 | ||
|
|
7571c2fa50 | ||
|
|
b174ed8c71 | ||
|
|
0e830a67c4 | ||
|
|
d05925c9bc | ||
|
|
d7ff4ac68a | ||
|
|
c239b879cd | ||
|
|
9448123178 | ||
|
|
6761cdfac4 | ||
|
|
f4caaba828 | ||
|
|
5c5a99119e | ||
|
|
23e6d5d3e4 | ||
|
|
4513d481d0 | ||
|
|
cf79c3edd4 | ||
|
|
43ddf78333 | ||
|
|
b2e5d91a8c | ||
|
|
3757156700 | ||
|
|
ca096a9027 | ||
|
|
5c68c8006c | ||
|
|
2bfd2ac65f | ||
|
|
56aa1bef12 | ||
|
|
b4a82be05b | ||
|
|
7445bc4971 | ||
|
|
e022b92ef1 | ||
|
|
7d807b5728 | ||
|
|
f6633f19e4 |
+9
-1
@@ -1 +1,9 @@
|
||||
__pycache__
|
||||
__pycache__
|
||||
AGENTS.md
|
||||
|
||||
# Nutzerspezifische Konfigurationsdateien – nicht durch Updates überschreiben
|
||||
ta_discord_link.json
|
||||
ta_model_choices.json
|
||||
ta_model_presets.json
|
||||
ta_sampler_presets.json
|
||||
ta_smart_llm_models.json
|
||||
|
||||
@@ -16,7 +16,76 @@ A collection of nodes designed for use in thomo.ART workflows, focused on flexib
|
||||
The full documentation is available via the built-in **Help button** in each node (opens in your browser at `http://localhost:8188/ta-nodes/wiki/index.html`).
|
||||
|
||||
---
|
||||
## Credits
|
||||
This project was inspired by or builds upon the following open-source works:
|
||||
|
||||
- **[ComfyUI-EBU-LMStudio](https://github.com/burnsbert/ComfyUI-EBU-LMStudio)** by [burnsbert (Eric W. Burns)](https://github.com/burnsbert)
|
||||
Inspiration for the LM Studio / LLM integration in ComfyUI, implemented in the **TASmartLLM** node with support for both LM Studio and Ollama.
|
||||
|
||||
- **[Comfyui-Memory_Cleanup](https://github.com/LAOGOU-666/Comfyui-Memory_Cleanup)** by [LAOGOU-666](https://github.com/LAOGOU-666)
|
||||
Inspiration for the VRAM and RAM cleanup logic in the **TACleanupSwitch** node.
|
||||
|
||||
**[Fast Laplacian Sharpen](https://github.com/vrgamegirl19/comfyui-vrgamedevgirl)** by [VRGameDevGirl](https://github.com/vrgamegirl19)
|
||||
Basis and inspiration for the **TAFastLaplacianSharpen** node.
|
||||
---
|
||||
## Tested on the following system (2026-10-03):
|
||||
- CPU: AMD Ryzen 9 5900X
|
||||
- RAM: 64GB
|
||||
- GPU: RTX 3090 (24GB VRAM)
|
||||
- Python: 3.12.10
|
||||
- Torch version: 2.11.0+cu130
|
||||
- Triton version: 3.6.0.post26
|
||||
- LM Studio: 0.4.25 (Build 1)
|
||||
- Ollama: 0.35.0
|
||||
- ComfyUI: 0.38.0
|
||||
|
||||
## Changelog
|
||||
**v2.2.3 added ta_film_grain.py v1.0**
|
||||
- added self-contained `TAFilmGrain` node (`🎞️ TA Film Grain`, RGB/RGBA, 1:1 parameter-compatible with `ProPostFilmGrain`)
|
||||
- updated example workflow to `TA-FLEXMOD-LLM v2.89.json` using `TAFilmGrain`
|
||||
|
||||
**v2.2.2 changed ta_sageattention_toggler.py to v2.2**
|
||||
- added kitchen_enable Toggle (comfy-kitchen int8_attention)
|
||||
|
||||
**v2.2.1 added ta_fastlaplaciansharpen.py v1.0**
|
||||
- added RGBA to TA FastLaplacianSharpen for Qwen-Image-2.1 compatibility
|
||||
|
||||
**v2.2.0 changed ta_save_image_optional.py to v2.2**
|
||||
- RGBA-to-RGB conversion before save — fixes JPEG save crash with qwen-image 2.1
|
||||
|
||||
**v2.1.0 changed ta_ksampler.py to v2.3**
|
||||
- fixed empty-latent downscaling, added Qwen-Image-2.1 compatibility
|
||||
|
||||
**v2.0.9 changed ta_smart_llm to v3.8**
|
||||
- added a reasoning output to TA Smart LLM
|
||||
|
||||
**v2.0.8 changed ta_smart_llm to v3.7**
|
||||
|
||||
v3.3 — Empty LLM response detection: status output now shows a warning instead of silently passing an empty prompt downstream.
|
||||
v3.4 — Added thinking_mode toggle (✅ Thinking ON / ❌ Thinking OFF) to strip or keep the [think]...[/think} block from models with reasoning/thinking capabilities.
|
||||
v3.5 — LM Studio 0.4.7+ compatibility: the node now reads reasoning_content as fallback when content is empty, fixing the blank prompt issue introduced in newer LM Studio versions.
|
||||
v3.6 — Fixed inverted thinking_mode logic and refactored response parsing to correctly handle all three scenarios: LM Studio 0.4.6 (content with tags), LM Studio 0.4.7+ (reasoning_content without tags), and Ollama.
|
||||
v3.7 — Renamed internal parameter strip_thinking to thinking_mode for clarity.
|
||||
|
||||
**v2.0.6 changed ta_smart_llm to v3.2**
|
||||
- `request_timeout` is built as an INT widget between `max_tokens` and `unload_image_models_first` — default 120s, adjustable from 30 to 600s in increments of 30.
|
||||
|
||||
**v2.0.5 changed .gitignore**
|
||||
- All JSON files have been added to Gitignore so that they will no longer be overwritten during an update.
|
||||
|
||||
**v2.0.3 changed ta_smart_llm**
|
||||
ta_smart_llm v3.1:
|
||||
- `unload_image_models_first` and `unload_llm_after` now default to `True`. Note that existing nodes in the workflow retain their saved values—the new default only applies to newly placed nodes.
|
||||
|
||||
**v2.0.2 changed ta_smart_llm**
|
||||
ta_smart_llm v3.0 is the consolidated version with all fixes:
|
||||
- Active models are now displayed at the top of the dropdown, offline models at the bottom — no validation error
|
||||
- timeout=0.5 for all backend queries
|
||||
- IS_CHANGED returns "disabled" if llm_enable=False — the node is cached
|
||||
- _flush_lmstudio_context removed — saves the 0.5s pause before vision requests
|
||||
- temperature + max_tokens as configurable parameters
|
||||
|
||||
---
|
||||
## Nodes
|
||||
|
||||
### 🧠 TA Unified Model Switcher
|
||||
@@ -61,6 +130,9 @@ Extends ComfyUI's built-in SaveImage with optional companion `.txt` files contai
|
||||
### 🎬 TA SeedVR2 Gate
|
||||
Enable/disable gate for the SeedVR2 upscaler pipeline using lazy evaluation. When disabled, all upstream nodes (including the ~14 GB model loaders) are skipped entirely.
|
||||
|
||||
### 🎞️ TA Film Grain
|
||||
Self-contained film grain node for RGB and RGBA `IMAGE` tensors (alpha preserved untouched) with shadow/highlight response, gamma shaping, grayscale option, and post-grain sharpening. 1:1 parameter-compatible with `ProPostFilmGrain` without external `filmgrainer` dependencies.
|
||||
|
||||
### 💬 TA Discord Link
|
||||
Displays a clickable Discord invite link directly inside the ComfyUI graph. URL and button label are configurable via a browser-based editor.
|
||||
|
||||
@@ -69,7 +141,7 @@ Displays a clickable Discord invite link directly inside the ComfyUI graph. URL
|
||||
## Installation
|
||||
|
||||
### Via ComfyUI Manager
|
||||
Search for `TA-ComfyUI-Nodes-Pack` in the ComfyUI Manager and install.
|
||||
Search for `TA ComfyUI Nodes Pack` in the ComfyUI Manager and install.
|
||||
|
||||
### Manual
|
||||
```bash
|
||||
|
||||
+8
-2
@@ -2,8 +2,8 @@
|
||||
TA ComfyUI Nodes Pack
|
||||
© Thomas Möhrling (thomo.ART)
|
||||
Erstelldatum: 2026-03-02
|
||||
Änderungsdatum: 2026-03-13
|
||||
Version: v4.0 - TADiscordLink hinzugefügt
|
||||
Änderungsdatum: 2026-11-15
|
||||
Version: v4.1 - TAFilmGrain hinzugefügt
|
||||
"""
|
||||
|
||||
print("\n" + "="*60)
|
||||
@@ -33,6 +33,8 @@ from .ta_directory_captioning import TACaptioning
|
||||
from .ta_cleanup_switch import TACleanupSwitch
|
||||
from .ta_help_link import TAHelpLink
|
||||
from .ta_discord_link import TADiscordLink
|
||||
from .ta_fastlaplaciansharpen import TAFastLaplacianSharpen
|
||||
from .ta_film_grain import TAFilmGrain
|
||||
|
||||
# Erweiterte Mappings (alt + neu)
|
||||
NODE_CLASS_MAPPINGS.update({
|
||||
@@ -55,6 +57,8 @@ NODE_CLASS_MAPPINGS.update({
|
||||
"TACleanupSwitch": TACleanupSwitch,
|
||||
"TAHelpLink": TAHelpLink,
|
||||
"TADiscordLink": TADiscordLink,
|
||||
"TAFastLaplacianSharpen": TAFastLaplacianSharpen,
|
||||
"TAFilmGrain": TAFilmGrain,
|
||||
})
|
||||
|
||||
NODE_DISPLAY_NAME_MAPPINGS.update({
|
||||
@@ -77,6 +81,8 @@ NODE_DISPLAY_NAME_MAPPINGS.update({
|
||||
"TACleanupSwitch": "🧹 TA Cleanup Switch",
|
||||
"TAHelpLink": "🔗 TA Help Link",
|
||||
"TADiscordLink": "💬 TA Discord Link",
|
||||
"TAFastLaplacianSharpen": "🌀 TA Fast Laplacian Sharpen",
|
||||
"TAFilmGrain": "🎞️ TA Film Grain",
|
||||
})
|
||||
|
||||
WEB_DIRECTORY = "./web/js"
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"name": "TA-ComfyUI-Nodes-Pack",
|
||||
"author": "tmode-1960",
|
||||
"description": "Some useful nodes for ComfyUI (Model Loader, LM Studio, Ollama and more)",
|
||||
"version": "2.0.0",
|
||||
"description": "Custom ComfyUI nodes for advanced AI image workflows. Includes smart model loaders (FLUX, SDXL, ZImage, Qwen), LM Studio/Ollama integration, sampler presets, VRAM/RAM cleanup, and prompt utilities.",
|
||||
"version": "2.2.3",
|
||||
"repository": "https://github.com/tmode-1960/TA-ComfyUI-Nodes-Pack",
|
||||
"license": "Apache 2.0"
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+4
-4
@@ -1,10 +1,10 @@
|
||||
[project]
|
||||
name = "TA-ComfyUI-Nodes-Pack"
|
||||
version = "2.0.0"
|
||||
description = "Some useful nodes for ComfyUI (Model Loader, LM Studio, Ollama and more))"
|
||||
version = "2.2.3"
|
||||
description = "Custom ComfyUI nodes for advanced AI image workflows. Includes smart model loaders (FLUX, SDXL, ZImage, Qwen), LM Studio/Ollama integration, sampler presets, VRAM/RAM cleanup, and prompt utilities."
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.8"
|
||||
license = {text = "MIT"}
|
||||
license = {text = "Apache-2.0"}
|
||||
authors = [
|
||||
{name = "tmode-1960", email = "info@thomo.art"}
|
||||
]
|
||||
@@ -27,5 +27,5 @@ build-backend = "setuptools.build_meta"
|
||||
# ComfyUI Registry Konfiguration
|
||||
[tool.comfy]
|
||||
PublisherId = "tmode-1960"
|
||||
DisplayName = "TA ComfyUI Nodes Pack"
|
||||
DisplayName = "TA-ComfyUI-Nodes-Pack"
|
||||
Icon = "" # Optional: URL zu einem Icon
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"discord_url": "https://discord.gg/f7S3zjGWbW",
|
||||
"label": "Join Bocodemy on Discord"
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
"""
|
||||
================================================================================
|
||||
Node Name : TAFastLaplacianSharpen
|
||||
Created : 2026-10-01
|
||||
Modified : 2026-10-01
|
||||
Copyright : © 2026, Thomas Möhrling (thomo.ART)
|
||||
Version : 1.0
|
||||
--------------------------------------------------------------------------------
|
||||
Part of ComfyUI-TA-Nodes-Pack
|
||||
License : Apache 2.0
|
||||
Description:
|
||||
Fast Laplacian sharpen for IMAGE tensors (RGB or RGBA). CPU by default,
|
||||
optional GPU. Alpha channel is preserved and NOT sharpened — only the RGB
|
||||
components are processed with a 3x3 Laplacian kernel. Works with Qwen
|
||||
Image, FLUX, SDXL and other pipelines that emit RGBA.
|
||||
Changelog:
|
||||
1.0 2026-10-01 Initial implementation
|
||||
================================================================================
|
||||
"""
|
||||
|
||||
from typing import Tuple
|
||||
|
||||
import numpy as np
|
||||
import torch
|
||||
import torch.nn.functional as F
|
||||
import comfy.model_management
|
||||
|
||||
|
||||
# 3x3 Laplacian kernel (second derivative, 4-cross, no diagonal weighting)
|
||||
LAPLACIAN_KERNEL = np.array(
|
||||
[[0, -1, 0],
|
||||
[-1, 4, -1],
|
||||
[0, -1, 0]],
|
||||
dtype=np.float32,
|
||||
)
|
||||
|
||||
|
||||
class TAFastLaplacianSharpen:
|
||||
"""
|
||||
Fast Laplacian sharpen node for ComfyUI IMAGE tensors.
|
||||
|
||||
Applies a single-tap 3x3 Laplacian (cross) filter per color channel and
|
||||
adds a user-defined strength to the original. The result is clipped to
|
||||
[0..1]. The alpha channel (if present) is left untouched.
|
||||
|
||||
Two processing paths:
|
||||
- CPU path (default): numpy-based convolution, works on any hardware.
|
||||
- GPU path (opt-in) : torch F.conv2d with groups=3 on RGB, then
|
||||
re-attached alpha. Uses ComfyUI's torch device.
|
||||
|
||||
The node is channel-count agnostic for 3 (RGB) and 4 (RGBA) inputs,
|
||||
which is required for pipelines like Qwen-Image that emit RGBA.
|
||||
"""
|
||||
|
||||
CATEGORY = "TA Nodes/Enhancement"
|
||||
FUNCTION = "apply_laplacian"
|
||||
RETURN_TYPES = ("IMAGE",)
|
||||
RETURN_NAMES = ("IMAGE",)
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"images": ("IMAGE",),
|
||||
"strength": ("FLOAT",
|
||||
{"default": 0.5, "min": 0.0, "max": 2.0, "step": 0.01}),
|
||||
"use_gpu": ("BOOLEAN", {"default": False}),
|
||||
},
|
||||
}
|
||||
|
||||
def apply_laplacian(
|
||||
self,
|
||||
images: torch.Tensor,
|
||||
strength: float,
|
||||
use_gpu: bool,
|
||||
) -> Tuple[torch.Tensor]:
|
||||
"""
|
||||
Apply Laplacian sharpen to a batch of IMAGE tensors.
|
||||
|
||||
Args:
|
||||
images : ComfyUI IMAGE tensor, shape (B, H, W, C) with C in {3, 4}.
|
||||
strength : Sharpen strength added on top of the original.
|
||||
0.0 returns the input unchanged (after clip).
|
||||
use_gpu : If True, run on the ComfyUI torch device; otherwise CPU.
|
||||
|
||||
Returns:
|
||||
Tuple[torch.Tensor]: (sharpened_IMAGE_tensor,).
|
||||
"""
|
||||
channels = images.shape[-1]
|
||||
if channels not in (3, 4):
|
||||
raise ValueError(
|
||||
f"TAFastLaplacianSharpen erwartet RGB oder RGBA, "
|
||||
f"bekommen: {channels} Kanale"
|
||||
)
|
||||
|
||||
if use_gpu:
|
||||
return self._apply_gpu(images, strength, channels)
|
||||
return self._apply_cpu(images, strength, channels)
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# GPU path
|
||||
# ------------------------------------------------------------------
|
||||
def _apply_gpu(self, images: torch.Tensor, strength: float, channels: int):
|
||||
device = comfy.model_management.get_torch_device()
|
||||
|
||||
# (B, H, W, C) -> (B, C, H, W)
|
||||
x = images.to(device=device, dtype=torch.float32).permute(0, 3, 1, 2)
|
||||
|
||||
# Split alpha if present; only sharpen RGB (3 channels).
|
||||
if channels == 4:
|
||||
alpha = x[:, 3:4]
|
||||
rgb = x[:, :3]
|
||||
else:
|
||||
alpha = None
|
||||
rgb = x
|
||||
|
||||
kernel = torch.tensor(LAPLACIAN_KERNEL,
|
||||
dtype=rgb.dtype, device=device).expand(3, 1, 3, 3)
|
||||
|
||||
edges = F.conv2d(rgb, kernel, padding=1, groups=3)
|
||||
out = (rgb + strength * edges).clamp(0.0, 1.0)
|
||||
|
||||
if alpha is not None:
|
||||
out = torch.cat((out, alpha), dim=1)
|
||||
|
||||
# (B, C, H, W) -> (B, H, W, C) and move back to the intermediate device
|
||||
# ComfyUI uses to feed downstream nodes.
|
||||
out = out.permute(0, 2, 3, 1)
|
||||
return (out.to(comfy.model_management.intermediate_device()),)
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# CPU path (default)
|
||||
# ------------------------------------------------------------------
|
||||
def _apply_cpu(self, images: torch.Tensor, strength: float, channels: int):
|
||||
if images.is_cuda:
|
||||
images = images.cpu()
|
||||
|
||||
img = images.contiguous().numpy().astype(np.float32) # (B, H, W, C)
|
||||
|
||||
# Split alpha if present; only sharpen RGB.
|
||||
if channels == 4:
|
||||
alpha = img[..., 3:4]
|
||||
rgb = img[..., :3]
|
||||
else:
|
||||
alpha = None
|
||||
rgb = img
|
||||
|
||||
# Edge padding keeps RGB at same HxW after the 3x3 convolution.
|
||||
p = np.pad(rgb,
|
||||
pad_width=((0, 0), (1, 1), (1, 1), (0, 0)),
|
||||
mode="edge")
|
||||
|
||||
lap = (
|
||||
p[:, 1:-1, 0:-2] +
|
||||
p[:, 0:-2, 1:-1] +
|
||||
p[:, 2: , 1:-1] +
|
||||
p[:, 1:-1, 2: ] -
|
||||
4.0 * rgb
|
||||
)
|
||||
|
||||
out = rgb + strength * lap
|
||||
np.clip(out, 0.0, 1.0, out=out)
|
||||
|
||||
if alpha is not None:
|
||||
out = np.concatenate((out, alpha), axis=-1)
|
||||
|
||||
return (torch.from_numpy(out),)
|
||||
|
||||
|
||||
NODE_CLASS_MAPPINGS = {
|
||||
"TAFastLaplacianSharpen": TAFastLaplacianSharpen,
|
||||
}
|
||||
|
||||
NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
"TAFastLaplacianSharpen": "🌀 TA Fast Laplacian Sharpen",
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
"""
|
||||
================================================================================
|
||||
Node Name : TAFilmGrain
|
||||
Created : 2026-11-13
|
||||
Modified : 2026-11-13
|
||||
Copyright : © 2026, Thomas Möhrling (thomo.ART)
|
||||
Version : 1.0
|
||||
--------------------------------------------------------------------------------
|
||||
Part of ComfyUI-TA-Nodes-Pack
|
||||
License : Apache 2.0
|
||||
Description:
|
||||
Self-contained Film Grain node for IMAGE tensors (RGB or RGBA).
|
||||
1:1 parameter-compatible with ProPostFilmGrain without external
|
||||
filmgrainer package imports (avoids namespace collisions). Alpha channel
|
||||
is preserved untouched.
|
||||
Changelog:
|
||||
1.0 2026-11-13 Initial implementation
|
||||
================================================================================
|
||||
"""
|
||||
|
||||
from typing import Tuple
|
||||
|
||||
import numpy as np
|
||||
import torch
|
||||
from PIL import Image, ImageFilter
|
||||
|
||||
|
||||
GRAIN_PROFILES = {
|
||||
"Fine": (0.80, 0.25),
|
||||
"Fine Simple": (1.00, 0.18),
|
||||
"Coarse": (1.60, 0.30),
|
||||
"Coarser": (2.40, 0.36),
|
||||
}
|
||||
|
||||
|
||||
class TAFilmGrain:
|
||||
"""
|
||||
Self-contained Film Grain node for ComfyUI IMAGE tensors.
|
||||
|
||||
Applies organic luminance/chrominance film grain with shadow/highlight
|
||||
response, gamma shaping, optional grayscale conversion, and optional
|
||||
post-grain sharpening. Supports 3-channel (RGB) and 4-channel (RGBA)
|
||||
tensors; alpha is preserved unchanged.
|
||||
"""
|
||||
|
||||
CATEGORY = "TA Nodes/Enhancement"
|
||||
FUNCTION = "apply_filmgrain"
|
||||
RETURN_TYPES = ("IMAGE",)
|
||||
RETURN_NAMES = ("IMAGE",)
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"image": ("IMAGE",),
|
||||
"gray_scale": ("BOOLEAN", {"default": False}),
|
||||
"grain_type": (["Fine", "Fine Simple", "Coarse", "Coarser"],),
|
||||
"grain_sat": ("FLOAT", {"default": 0.15, "min": 0.0, "max": 1.0, "step": 0.01}),
|
||||
"grain_power": ("FLOAT", {"default": 0.40, "min": 0.0, "max": 1.0, "step": 0.01}),
|
||||
"shadows": ("FLOAT", {"default": 0.20, "min": 0.0, "max": 1.0, "step": 0.01}),
|
||||
"highs": ("FLOAT", {"default": 0.20, "min": 0.0, "max": 1.0, "step": 0.01}),
|
||||
"scale": ("FLOAT", {"default": 0.65, "min": 0.0, "max": 10.0, "step": 0.01}),
|
||||
"sharpen": ("INT", {"default": 0, "min": 0, "max": 10}),
|
||||
"src_gamma": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.01}),
|
||||
"seed": ("INT", {"default": 1, "min": 1, "max": 18446744073709551615}),
|
||||
},
|
||||
}
|
||||
|
||||
def apply_filmgrain(
|
||||
self,
|
||||
image: torch.Tensor,
|
||||
gray_scale: bool,
|
||||
grain_type: str,
|
||||
grain_sat: float,
|
||||
grain_power: float,
|
||||
shadows: float,
|
||||
highs: float,
|
||||
scale: float,
|
||||
sharpen: int,
|
||||
src_gamma: float,
|
||||
seed: int,
|
||||
) -> Tuple[torch.Tensor]:
|
||||
"""
|
||||
Apply film grain to a batch of IMAGE tensors.
|
||||
|
||||
Args:
|
||||
image : ComfyUI IMAGE tensor, shape (B, H, W, C) with C in {3, 4}.
|
||||
gray_scale : Convert RGB to grayscale before adding grain.
|
||||
grain_type : Grain profile ("Fine", "Fine Simple", "Coarse", "Coarser").
|
||||
grain_sat : Color saturation of the grain (0.0 = monochrome, 1.0 = full RGB).
|
||||
grain_power : Overall grain intensity [0..1].
|
||||
shadows : Grain response in shadow areas [0..1].
|
||||
highs : Grain response in highlight areas [0..1].
|
||||
scale : Grain size scale factor.
|
||||
sharpen : Optional post-grain sharpen passes [0..10].
|
||||
src_gamma : Source gamma curve applied to luminance response.
|
||||
seed : Base random seed (incremented per batch item).
|
||||
|
||||
Returns:
|
||||
Tuple[torch.Tensor]: (grained_IMAGE_tensor,).
|
||||
"""
|
||||
channels = image.shape[-1]
|
||||
if channels not in (3, 4):
|
||||
raise ValueError(
|
||||
f"TAFilmGrain erwartet RGB oder RGBA, bekommen: {channels} Kanale"
|
||||
)
|
||||
|
||||
src = image.cpu() if image.is_cuda else image
|
||||
img_np = src.contiguous().numpy().astype(np.float32)
|
||||
batch_size, height, width, _ = img_np.shape
|
||||
out_np = np.empty_like(img_np)
|
||||
|
||||
grain_size_mult, profile_amp = GRAIN_PROFILES.get(grain_type, (1.0, 0.25))
|
||||
eff_scale = max(0.25, float(scale) * grain_size_mult)
|
||||
gamma_val = max(0.05, float(src_gamma))
|
||||
|
||||
for b in range(batch_size):
|
||||
frame = np.clip(img_np[b], 0.0, 1.0)
|
||||
if channels == 4:
|
||||
rgb = frame[..., :3]
|
||||
alpha = frame[..., 3:4]
|
||||
else:
|
||||
rgb = frame
|
||||
alpha = None
|
||||
|
||||
if gray_scale:
|
||||
luma = (0.299 * rgb[..., 0] + 0.587 * rgb[..., 1] + 0.114 * rgb[..., 2])[..., None]
|
||||
rgb = np.repeat(luma, 3, axis=-1)
|
||||
|
||||
if grain_power > 0.0:
|
||||
rng = np.random.default_rng((int(seed) + b) & 0xFFFFFFFFFFFFFFFF)
|
||||
noise_w = max(1, int(round(width / eff_scale)))
|
||||
noise_h = max(1, int(round(height / eff_scale)))
|
||||
|
||||
mono_noise = rng.normal(0.0, 1.0, (noise_h, noise_w, 1)).astype(np.float32)
|
||||
color_noise = rng.normal(0.0, 1.0, (noise_h, noise_w, 3)).astype(np.float32)
|
||||
sat = float(np.clip(grain_sat, 0.0, 1.0))
|
||||
raw_noise = (1.0 - sat) * mono_noise + sat * color_noise
|
||||
|
||||
if noise_w != width or noise_h != height:
|
||||
resized_ch = []
|
||||
for c in range(3):
|
||||
ch_img = Image.fromarray(raw_noise[..., c], mode="F")
|
||||
ch_res = ch_img.resize((width, height), resample=Image.BILINEAR)
|
||||
resized_ch.append(np.asarray(ch_res, dtype=np.float32))
|
||||
noise = np.stack(resized_ch, axis=-1)
|
||||
else:
|
||||
noise = raw_noise
|
||||
|
||||
lum = 0.299 * rgb[..., 0] + 0.587 * rgb[..., 1] + 0.114 * rgb[..., 2]
|
||||
if abs(gamma_val - 1.0) > 1e-4:
|
||||
lum_g = np.power(np.clip(lum, 0.0, 1.0), 1.0 / gamma_val)
|
||||
else:
|
||||
lum_g = lum
|
||||
|
||||
mid_weight = 4.0 * lum_g * (1.0 - lum_g)
|
||||
shadow_weight = (1.0 - lum_g) ** 2 * float(shadows) * 2.0
|
||||
high_weight = (lum_g ** 2) * float(highs) * 2.0
|
||||
mask = np.clip(mid_weight + shadow_weight + high_weight, 0.0, 1.5)[..., None]
|
||||
|
||||
amp = float(grain_power) * profile_amp
|
||||
rgb = np.clip(rgb + noise * amp * mask, 0.0, 1.0)
|
||||
|
||||
if sharpen > 0:
|
||||
pil_rgb = Image.fromarray((rgb * 255.0).astype(np.uint8), mode="RGB")
|
||||
for _ in range(int(sharpen)):
|
||||
pil_rgb = pil_rgb.filter(ImageFilter.SHARPEN)
|
||||
rgb = np.asarray(pil_rgb, dtype=np.float32) / 255.0
|
||||
|
||||
if alpha is not None:
|
||||
out_np[b] = np.concatenate((rgb, alpha), axis=-1)
|
||||
else:
|
||||
out_np[b] = rgb
|
||||
|
||||
return (torch.from_numpy(out_np),)
|
||||
|
||||
|
||||
NODE_CLASS_MAPPINGS = {
|
||||
"TAFilmGrain": TAFilmGrain,
|
||||
}
|
||||
|
||||
NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
"TAFilmGrain": "🎞️ TA Film Grain",
|
||||
}
|
||||
+22
-5
@@ -2,9 +2,9 @@
|
||||
================================================================================
|
||||
Node Name : TA KSampler
|
||||
Created : 2026-03-07
|
||||
Modified : 2026-03-14
|
||||
Modified : 2026-09-26
|
||||
Copyright : © 2026, Thomas Möhrling (thomo.ART)
|
||||
Version : 2.1
|
||||
Version : 2.3
|
||||
--------------------------------------------------------------------------------
|
||||
Part of ComfyUI-TA-Nodes-Pack
|
||||
License : Apache 2.0
|
||||
@@ -14,6 +14,12 @@ Description:
|
||||
STRING inputs, making it directly connectable to the TA Sampler Preset node.
|
||||
Provides per-step live latent2rgb preview via pbar.update_absolute(),
|
||||
identical in behaviour to ComfyUI's built-in KSampler preview.
|
||||
Changelog:
|
||||
2.3 2026-09-26 Default downscale ratios (8/1) when the latent source omits the ratio keys (Fix: ResolutionMaster -> Qwen-Image-2.1)
|
||||
2.2 2026-09-26 Pass downscale_ratio_spacial/_temporal to fix_empty_latent_channels (Fix: latent size for Qwen-Image-2.1)
|
||||
2.1 2026-03-14 Error fixes and updates
|
||||
2.0 2026-03-12 New version V2
|
||||
1.0 2026-03-07 Initial version
|
||||
================================================================================
|
||||
"""
|
||||
|
||||
@@ -300,9 +306,18 @@ class TAKSampler:
|
||||
last_step = end_at_step if end_at_step < 9999 else None
|
||||
|
||||
# ── Prepare latent ─────────────────────────────────────────────────
|
||||
latent = latent_image.copy()
|
||||
latent_data = latent["samples"]
|
||||
latent_data = comfy.sample.fix_empty_latent_channels(model, latent_data)
|
||||
# Latent-Quellen ohne downscale_ratio_*-Key (z. B. ResolutionMaster)
|
||||
# erben die Core-EmptyLatent-Konvention (8, 1); fix_empty_latent_channels
|
||||
# reskaliert nur vollständig leere (All-Zero) Latents.
|
||||
latent = latent_image.copy()
|
||||
latent_data = latent["samples"]
|
||||
ratio_spacial = latent.get("downscale_ratio_spacial", 8)
|
||||
ratio_temporal = latent.get("downscale_ratio_temporal", 1)
|
||||
latent_data = comfy.sample.fix_empty_latent_channels(
|
||||
model, latent_data,
|
||||
ratio_spacial,
|
||||
ratio_temporal,
|
||||
)
|
||||
|
||||
# ── Noise ──────────────────────────────────────────────────────────
|
||||
if disable_noise:
|
||||
@@ -345,6 +360,8 @@ class TAKSampler:
|
||||
)
|
||||
|
||||
latent["samples"] = samples
|
||||
latent.pop("downscale_ratio_spacial", None)
|
||||
latent.pop("downscale_ratio_temporal", None)
|
||||
return (latent,)
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"choices": [
|
||||
"Model-Presets",
|
||||
"Model-Loader 1"
|
||||
]
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
[
|
||||
{
|
||||
"name": "ZImage (BF16)",
|
||||
"model_file": "[D] ZIMAGE/z_image_turbo_bf16.safetensors",
|
||||
"clip_name_1": "ZIMAGE/qwen_3_4b_bf16.safetensors",
|
||||
"clip_name_2": "",
|
||||
"clip_type": "lumina2",
|
||||
"clip_device": "default",
|
||||
"vae_name": "ZIMAGE/zImage_vae.safetensors",
|
||||
"shift": "3.10"
|
||||
},
|
||||
{
|
||||
"name": "Qwen Diffusion",
|
||||
"model_file": "[D] QWEN/qwen_image_fp8_e4m3fn.safetensors",
|
||||
"clip_name_1": "QWEN/qwen_2.5_vl_7b_fp8_scaled.safetensors",
|
||||
"clip_name_2": "",
|
||||
"clip_type": "qwen_image",
|
||||
"clip_device": "default",
|
||||
"vae_name": "QWEN/qwen_image_vae.safetensors",
|
||||
"shift": "",
|
||||
"weight_dtype": "fp8_e4m3fn"
|
||||
},
|
||||
{
|
||||
"name": "FLUX Dev (FP8)",
|
||||
"model_file": "[D] FLUX/flux1-dev-fp8.safetensors",
|
||||
"clip_name_1": "FLUX/t5xxl_fp8_e4m3fn.safetensors",
|
||||
"clip_name_2": "FLUX/clip_l.safetensors",
|
||||
"clip_type": "flux",
|
||||
"clip_device": "default",
|
||||
"vae_name": "FLUX/FLUX_VAE.safetensors"
|
||||
},
|
||||
{
|
||||
"name": "SDXL (Juggernaut)",
|
||||
"model_file": "[C] SDXL/juggernautXL_ragnarokBy.safetensors",
|
||||
"clip_name_1": "",
|
||||
"clip_name_2": "",
|
||||
"clip_type": "auto",
|
||||
"clip_device": "default",
|
||||
"vae_name": ""
|
||||
},
|
||||
{
|
||||
"name": "ACE",
|
||||
"model_file": "[D] ACE/acestep_v1.5_merge_sft_turbo_ta_0.5.safetensors",
|
||||
"clip_name_1": "ACE/qwen_0.6b_ace15.safetensors",
|
||||
"clip_name_2": "ACE/qwen_4b_ace15.safetensors",
|
||||
"clip_type": "ace",
|
||||
"clip_device": "default",
|
||||
"vae_name": "ACE/ace_1.5_vae.safetensors",
|
||||
"weight_dtype": "auto",
|
||||
"shift": ""
|
||||
}
|
||||
]
|
||||
+107
-30
@@ -2,18 +2,21 @@
|
||||
================================================================================
|
||||
Node Name : TA SageAttention Toggler
|
||||
Created : 2025
|
||||
Modified : 2026-03-11
|
||||
Modified : 2026-10-02
|
||||
Copyright : © 2026, Thomas Möhrling (thomo.ART)
|
||||
Version : 2.0
|
||||
Version : 2.2
|
||||
--------------------------------------------------------------------------------
|
||||
Part of ComfyUI-TA-Nodes-Pack
|
||||
License : Apache 2.0
|
||||
|
||||
Description:
|
||||
Patches a ComfyUI MODEL with SageAttention and/or PyTorch FP16 matmul
|
||||
acceleration. Exposes all five SageAttention modes available in
|
||||
ComfyUI-KJNodes: auto, qk_int8_pv_fp16_cuda, qk_int8_pv_fp16_triton,
|
||||
qk_int8_pv_fp8_cuda, and qk_fp8_pv_fp8_cuda.
|
||||
Patches a ComfyUI MODEL with an attention kernel and/or PyTorch FP16
|
||||
matmul acceleration. The attention engine is selected via mutually
|
||||
exclusive (XOR) toggles: SageAttention (all five ComfyUI-KJNodes modes:
|
||||
auto, qk_int8_pv_fp16_cuda, qk_int8_pv_fp16_triton, qk_int8_pv_fp8_cuda,
|
||||
qk_fp8_pv_fp8_cuda) or comfy-kitchen int8_attention. torch_enable is
|
||||
independent of the attention engine choice.
|
||||
Changelog:
|
||||
2.2 2026-10-02 kitchen_enable Toggle (comfy-kitchen int8_attention)
|
||||
================================================================================
|
||||
"""
|
||||
|
||||
@@ -31,14 +34,19 @@ NODE_DISPLAY_NAME_MAPPINGS = {"TASageAttentionToggler": "🔧 TA SageAttention T
|
||||
|
||||
class TASageAttentionToggler:
|
||||
"""
|
||||
Applies SageAttention and/or PyTorch FP16 matmul patches to a MODEL.
|
||||
Applies an attention kernel and/or a PyTorch FP16 matmul patch to a MODEL.
|
||||
|
||||
SageAttention and comfy-kitchen int8_attention are mutually exclusive:
|
||||
enabling both simultaneously raises a ValueError at sampling time. Exactly
|
||||
one (or neither) may be active. The FP16 matmul patch (torch_enable) is
|
||||
independent and can be combined with either engine.
|
||||
|
||||
SageAttention replaces the standard attention function with a quantised
|
||||
CUDA/Triton kernel for faster inference. The FP16 matmul patch enables
|
||||
torch.backends.cuda.matmul.allow_fp16_accumulation for additional
|
||||
throughput on supported hardware (requires PyTorch Nightly 2.7+).
|
||||
CUDA/Triton kernel. comfy-kitchen provides an INT8 attention kernel
|
||||
(ck.int8_attention) backed by the comfy_kitchen dispatch system
|
||||
(hip/cuda/triton/eager backends).
|
||||
|
||||
Both patches are independent and can be enabled or disabled individually.
|
||||
Both attention engines are optional; torch_enable is optional too.
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
@@ -47,13 +55,17 @@ class TASageAttentionToggler:
|
||||
Defines all input widgets shown in the ComfyUI node UI.
|
||||
|
||||
Inputs:
|
||||
model: The ComfyUI MODEL to patch.
|
||||
sage_enable: Toggle to apply the SageAttention patch.
|
||||
torch_enable: Toggle to apply the FP16 matmul patch.
|
||||
sage_mode: Selects the SageAttention kernel variant.
|
||||
'auto' uses the default sageattn() entry point;
|
||||
the other options select specific quantisation
|
||||
configurations (CUDA or Triton backends).
|
||||
model: The ComfyUI MODEL to patch.
|
||||
sage_enable: Toggle to apply the SageAttention patch.
|
||||
Mutually exclusive with kitchen_enable.
|
||||
torch_enable: Toggle to apply the FP16 matmul patch.
|
||||
Independent of the attention engine choice.
|
||||
sage_mode: Selects the SageAttention kernel variant.
|
||||
'auto' uses the default sageattn() entry point;
|
||||
the other options select specific quantisation
|
||||
configurations (CUDA or Triton backends).
|
||||
kitchen_enable: Toggle to apply the comfy-kitchen int8_attention
|
||||
patch. Mutually exclusive with sage_enable.
|
||||
|
||||
Returns:
|
||||
dict: ComfyUI INPUT_TYPES dictionary with all required inputs.
|
||||
@@ -70,6 +82,7 @@ class TASageAttentionToggler:
|
||||
"sageattn_qk_int8_pv_fp8_cuda",
|
||||
"sageattn_qk_fp8_pv_fp8_cuda"
|
||||
], {"default": "auto"}),
|
||||
"kitchen_enable": ("BOOLEAN", {"default": False, "label_on": "✅ Kitchen ON", "label_off": "❌ OFF"}),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,34 +90,61 @@ class TASageAttentionToggler:
|
||||
FUNCTION = "apply_patches"
|
||||
CATEGORY = "TA Smart LLM"
|
||||
|
||||
def apply_patches(self, model, sage_enable, torch_enable, sage_mode):
|
||||
def apply_patches(self, model, sage_enable, torch_enable, sage_mode, kitchen_enable):
|
||||
"""
|
||||
Applies the selected patches to the model and returns the patched result.
|
||||
|
||||
Each patch is applied independently based on its toggle. If sage_enable
|
||||
is True, _apply_sage_patch() is called first; if torch_enable is True,
|
||||
_apply_torch_patch() is called afterwards. Both patches modify the model
|
||||
object in-place and also return it for chaining.
|
||||
The attention engine (SageAttention or comfy-kitchen) is mutually
|
||||
exclusive: setting both sage_enable and kitchen_enable to True raises
|
||||
a ValueError. torch_enable is independent of the engine choice.
|
||||
|
||||
If sage_enable is True, _apply_sage_patch() is called.
|
||||
If kitchen_enable is True, _apply_kitchen_patch() is called.
|
||||
If torch_enable is True, _apply_torch_patch() is called.
|
||||
All patches modify the model in-place and return it for chaining.
|
||||
|
||||
Args:
|
||||
model: ComfyUI MODEL object to patch.
|
||||
sage_enable (bool): Whether to apply the SageAttention patch.
|
||||
torch_enable (bool): Whether to apply the FP16 matmul patch.
|
||||
sage_mode (str): SageAttention kernel variant to use.
|
||||
model: ComfyUI MODEL object to patch.
|
||||
sage_enable (bool): Whether to apply the SageAttention patch.
|
||||
torch_enable (bool): Whether to apply the FP16 matmul patch.
|
||||
sage_mode (str): SageAttention kernel variant to use.
|
||||
kitchen_enable (bool): Whether to apply the comfy-kitchen patch.
|
||||
|
||||
Returns:
|
||||
tuple: Single-element tuple containing the patched MODEL object.
|
||||
|
||||
Raises:
|
||||
ValueError: If both sage_enable and kitchen_enable are True.
|
||||
"""
|
||||
logger.info(f"🚀 [TA] SageToggler START | Sage:{sage_enable} | Torch:{torch_enable} | Mode:{sage_mode}")
|
||||
logger.info(f"🚀 [TA] SageToggler START | Sage:{sage_enable} | Torch:{torch_enable} | Mode:{sage_mode} | Kitchen:{kitchen_enable}")
|
||||
|
||||
if sage_enable and kitchen_enable:
|
||||
raise ValueError(
|
||||
"SageAttention und Comfort Kitchen sind exklusiv. "
|
||||
"Bitte nur eins aktivieren (sage_enable ODER kitchen_enable)."
|
||||
)
|
||||
|
||||
patched_model = model
|
||||
|
||||
applied = []
|
||||
|
||||
if sage_enable:
|
||||
patched_model = self._apply_sage_patch(patched_model, sage_mode)
|
||||
applied.append(f"Sage({sage_mode})")
|
||||
|
||||
if kitchen_enable:
|
||||
patched_model = self._apply_kitchen_patch(patched_model)
|
||||
applied.append("Kitchen(int8_attention)")
|
||||
|
||||
if torch_enable:
|
||||
patched_model = self._apply_torch_patch(patched_model)
|
||||
applied.append("Torch FP16")
|
||||
|
||||
if applied:
|
||||
logger.info(f"✅ [TA] Patches applied: {', '.join(applied)}")
|
||||
else:
|
||||
logger.info("⏭️ [TA] No patches applied – all toggles disabled, model passed through.")
|
||||
|
||||
logger.info("✅ [TA] Patches applied!")
|
||||
return (patched_model, )
|
||||
|
||||
def _apply_sage_patch(self, model, sage_mode):
|
||||
@@ -177,6 +217,43 @@ class TASageAttentionToggler:
|
||||
|
||||
return model
|
||||
|
||||
def _apply_kitchen_patch(self, model):
|
||||
"""
|
||||
Patches the model with comfy-kitchen int8_attention.
|
||||
|
||||
Imports comfy_kitchen.int8_attention and wraps it in a lambda that
|
||||
matches ComfyUI's attention call signature (q, k, v, is_causal,
|
||||
attn_mask, tensor_layout). The wrapped function is stored as
|
||||
model.kitchen_func and model.kitchen_active is set to True on success.
|
||||
|
||||
If the comfy_kitchen package is not installed, model.kitchen_active
|
||||
is set to False and an installation hint is logged.
|
||||
|
||||
Args:
|
||||
model: ComfyUI MODEL object to patch.
|
||||
|
||||
Returns:
|
||||
MODEL: The model with kitchen_func and kitchen_active set.
|
||||
"""
|
||||
logger.info(f"🔥 comfy-kitchen PATCH")
|
||||
|
||||
try:
|
||||
from comfy_kitchen import int8_attention as ck_int8_attn
|
||||
|
||||
kitchen_func = lambda q, k, v, is_causal=False, attn_mask=None, tensor_layout="NHD": \
|
||||
ck_int8_attn(q, k, v, is_causal=is_causal, attn_mask=attn_mask, tensor_layout=tensor_layout)
|
||||
|
||||
logger.info(f"✅ comfy_kitchen int8_attention loaded successfully!")
|
||||
model.kitchen_func = kitchen_func
|
||||
model.kitchen_active = True
|
||||
|
||||
except ImportError as e:
|
||||
logger.error(f"❌ comfy_kitchen import error: {e}")
|
||||
logger.info("💡 Install with: pip install comfy-kitchen")
|
||||
model.kitchen_active = False
|
||||
|
||||
return model
|
||||
|
||||
def _apply_torch_patch(self, model):
|
||||
"""
|
||||
Enables PyTorch FP16 matmul accumulation on the CUDA backend.
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
{
|
||||
"Z-Image Turbo": {
|
||||
"steps": 9,
|
||||
"cfg": 1.0,
|
||||
"start_at_step": 0,
|
||||
"end_at_step": 9999,
|
||||
"sampler_name": "euler",
|
||||
"scheduler": "beta"
|
||||
},
|
||||
"FLUX": {
|
||||
"steps": 35,
|
||||
"cfg": 1.0,
|
||||
"start_at_step": 0,
|
||||
"end_at_step": 9999,
|
||||
"sampler_name": "deis",
|
||||
"scheduler": "beta"
|
||||
},
|
||||
"FLUX.1-DEV Turbo": {
|
||||
"steps": 8,
|
||||
"cfg": 7.0,
|
||||
"start_at_step": 0,
|
||||
"end_at_step": 9999,
|
||||
"sampler_name": "euler",
|
||||
"scheduler": "normal"
|
||||
},
|
||||
"QWEN": {
|
||||
"steps": 20,
|
||||
"cfg": 2.5,
|
||||
"start_at_step": 0,
|
||||
"end_at_step": 9999,
|
||||
"sampler_name": "dpmpp_2m",
|
||||
"scheduler": "sgm_uniform"
|
||||
},
|
||||
"QWEN Lightning": {
|
||||
"steps": 8,
|
||||
"cfg": 1.0,
|
||||
"start_at_step": 0,
|
||||
"end_at_step": 9999,
|
||||
"sampler_name": "dpmpp_2m",
|
||||
"scheduler": "sgm_uniform"
|
||||
},
|
||||
"SDXL": {
|
||||
"steps": 25,
|
||||
"cfg": 7.0,
|
||||
"start_at_step": 0,
|
||||
"end_at_step": 9999,
|
||||
"sampler_name": "dpmpp_2m",
|
||||
"scheduler": "karras"
|
||||
},
|
||||
"SD1.5": {
|
||||
"steps": 20,
|
||||
"cfg": 7.0,
|
||||
"start_at_step": 0,
|
||||
"end_at_step": 9999,
|
||||
"sampler_name": "euler_ancestral",
|
||||
"scheduler": "normal"
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,9 @@
|
||||
================================================================================
|
||||
Node Name : TA Save Image Optional
|
||||
Created : 2025
|
||||
Modified : 2026-03-12
|
||||
Modified : 2026-10-01
|
||||
Copyright : © 2026, Thomas Möhrling (thomo.ART)
|
||||
Version : 2.1
|
||||
Version : 2.2
|
||||
--------------------------------------------------------------------------------
|
||||
Part of ComfyUI-TA-Nodes-Pack
|
||||
License : Apache 2.0
|
||||
@@ -14,6 +14,13 @@ Description:
|
||||
Supports JPEG and WebP output formats with configurable quality, an
|
||||
enable/disable toggle, and optional companion .txt files containing the
|
||||
positive and negative prompts alongside a timestamp and filename reference.
|
||||
RGBA inputs (e.g. from FLUX / qwen-image 2.1) are converted to RGB; the
|
||||
alpha channel is discarded.
|
||||
Changelog:
|
||||
2.2 2026-10-01 Convert RGBA to RGB before save (qwen-image 2.1 JPEG/WebP compatibility)
|
||||
2.1 2026-03-12 Updates after version 2.0
|
||||
2.0 2026-03-12 New version V2
|
||||
1.0 Initial version
|
||||
================================================================================
|
||||
"""
|
||||
|
||||
@@ -148,7 +155,7 @@ class TASaveImageOptional(SaveImage):
|
||||
|
||||
for i, img in enumerate(images):
|
||||
img = ((img.cpu() * 255).clip(0, 255).cpu().numpy()).astype(np.uint8)
|
||||
pil_img = Image.fromarray(img)
|
||||
pil_img = Image.fromarray(img).convert("RGB")
|
||||
file_base = f"{filename}_{current_counter:05}_"
|
||||
save_path = os.path.join(full_output_folder, f"{file_base}{ext}")
|
||||
|
||||
@@ -188,5 +195,5 @@ NODE_CLASS_MAPPINGS = {
|
||||
"TASaveImageOptional": TASaveImageOptional
|
||||
}
|
||||
NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
"TASaveImageOptional": "TA Save Image Optional v2.1"
|
||||
"TASaveImageOptional": "TA Save Image Optional v2.2"
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
Node Name : TA Save Image With Prompt
|
||||
Created : 2025
|
||||
Modified : 2026-03-11
|
||||
Copyright : © 2026, Thomas Möhring (thomo.ART)
|
||||
Copyright : © 2026, Thomas Möhrling (thomo.ART)
|
||||
Version : 2.0
|
||||
--------------------------------------------------------------------------------
|
||||
Part of ComfyUI-TA-Nodes-Pack
|
||||
|
||||
+96
-51
@@ -2,9 +2,9 @@
|
||||
================================================================================
|
||||
Node Name : TA Smart LLM
|
||||
Created : 2025
|
||||
Modified : 2026-03-13
|
||||
Modified : 2026-04-05
|
||||
Copyright : © 2026, Thomas Möhrling (thomo.ART)
|
||||
Version : 2.2
|
||||
Version : 3.8
|
||||
--------------------------------------------------------------------------------
|
||||
Part of ComfyUI-TA-Nodes-Pack
|
||||
License : Apache 2.0
|
||||
@@ -35,7 +35,8 @@ VISION_KEYWORDS = ["llava", "vision", "-vl-", "_vl_", "vl-", "vl_", "moondream",
|
||||
|
||||
# Manual additions (exact model names without backend prefix, lowercase)
|
||||
# Example: VISION_MANUAL = {"my-vision-model-7b", "another-model-13b"}
|
||||
VISION_MANUAL = set()
|
||||
# VISION_MANUAL = set()
|
||||
VISION_MANUAL = {"qwen3.5-9b-uncensored-hauhaucs-aggressive"}
|
||||
|
||||
|
||||
def is_vision_model(model_id: str) -> bool:
|
||||
@@ -99,39 +100,48 @@ class TASmartLLM:
|
||||
Discovers and caches available models from LM Studio (port 1234) and
|
||||
Ollama (port 11434). Tags vision-capable models with [Vision] suffix.
|
||||
|
||||
Per-backend logic:
|
||||
- If a backend responds, its models replace the cached entries for
|
||||
that backend (additions and deletions are reflected immediately).
|
||||
- If a backend is offline, its cached entries are kept unchanged so
|
||||
that saved workflows remain valid without breaking validation.
|
||||
Display logic:
|
||||
- All known models are always shown (prevents validation errors).
|
||||
- Active models appear at the top of the list, offline models below.
|
||||
- No prefix is added to model names so stored values remain stable
|
||||
across restarts regardless of which backend is active.
|
||||
- Per-backend cache is updated on each call if the backend responds,
|
||||
so added/removed models are reflected immediately.
|
||||
"""
|
||||
known = cls._load_cached_models()
|
||||
|
||||
# Split cache by backend
|
||||
known_lmstudio = {m for m in known if m.startswith("LMStudio/")}
|
||||
known_ollama = {m for m in known if m.startswith("Ollama/")}
|
||||
|
||||
active_lmstudio = set()
|
||||
active_ollama = set()
|
||||
|
||||
# Query LM Studio — replace cache if reachable
|
||||
try:
|
||||
r = requests.get("http://127.0.0.1:1234/v1/models", timeout=2)
|
||||
r = requests.get("http://127.0.0.1:1234/v1/models", timeout=0.5)
|
||||
if r.status_code == 200:
|
||||
known_lmstudio = {f"LMStudio/{m['id']}" for m in r.json()['data']}
|
||||
active_lmstudio = known_lmstudio
|
||||
except:
|
||||
pass # offline — keep existing cache
|
||||
pass
|
||||
|
||||
# Query Ollama — replace cache if reachable
|
||||
try:
|
||||
r = requests.get("http://127.0.0.1:11434/api/tags", timeout=2)
|
||||
r = requests.get("http://127.0.0.1:11434/api/tags", timeout=0.5)
|
||||
if r.status_code == 200:
|
||||
known_ollama = {f"Ollama/{m['name']}" for m in r.json()['models']}
|
||||
active_ollama = known_ollama
|
||||
except:
|
||||
pass # offline — keep existing cache
|
||||
pass
|
||||
|
||||
all_models = known_lmstudio | known_ollama
|
||||
cls._save_cached_models(all_models)
|
||||
cls._save_cached_models(known_lmstudio | known_ollama)
|
||||
|
||||
tagged = [tag_model(m) for m in sorted(all_models)]
|
||||
return tagged if tagged else ["No Backend"]
|
||||
active = sorted(active_lmstudio | active_ollama)
|
||||
offline = sorted((known_lmstudio | known_ollama) - (active_lmstudio | active_ollama))
|
||||
|
||||
# Active models first, offline models after — no prefix in stored value
|
||||
result = [tag_model(m) for m in active] + [tag_model(m) for m in offline]
|
||||
return result if result else ["No Backend"]
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
@@ -159,21 +169,32 @@ class TASmartLLM:
|
||||
"model": (models, {"default": models[0] if models else "No Backend"}),
|
||||
"user_prompt": ("STRING", {"multiline": True, "default": ""}),
|
||||
"system_prompt": ("STRING", {"multiline": True, "default": "You are an expert SD prompt generator."}),
|
||||
"unload_image_models_first": ("BOOLEAN", {"default": False}),
|
||||
"unload_llm_after": ("BOOLEAN", {"default": False}),
|
||||
"temperature": ("FLOAT", {"default": 0.7, "min": 0.0, "max": 2.0, "step": 0.05}),
|
||||
"max_tokens": ("INT", {"default": 1024, "min": 64, "max": 8192, "step": 64}),
|
||||
"request_timeout": ("INT", {"default": 120, "min": 30, "max": 600, "step": 30}),
|
||||
"thinking_mode": ("BOOLEAN", {"default": True, "label_on": "✅ Thinking ON", "label_off": "❌ Thinking OFF"}),
|
||||
"unload_image_models_first": ("BOOLEAN", {"default": True}),
|
||||
"unload_llm_after": ("BOOLEAN", {"default": True}),
|
||||
},
|
||||
"optional": {
|
||||
"image": ("IMAGE",)
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("STRING", "STRING")
|
||||
RETURN_NAMES = ("prompt", "status")
|
||||
RETURN_TYPES = ("STRING", "STRING", "STRING")
|
||||
RETURN_NAMES = ("prompt", "status", "reasoning")
|
||||
FUNCTION = "generate"
|
||||
CATEGORY = "TA Tools"
|
||||
|
||||
@classmethod
|
||||
def IS_CHANGED(cls, *args, **kwargs):
|
||||
def IS_CHANGED(cls, llm_enable, model, user_prompt, system_prompt,
|
||||
temperature=0.7, max_tokens=1024, request_timeout=120,
|
||||
thinking_mode=False,
|
||||
unload_image_models_first=False, unload_llm_after=False,
|
||||
image=None):
|
||||
# Wenn deaktiviert: fixer Wert → Node wird von ComfyUI gecacht, kein erneuter Aufruf
|
||||
if not llm_enable:
|
||||
return "disabled"
|
||||
return time.time()
|
||||
|
||||
def _backend_reachable(self, backend, port):
|
||||
@@ -182,7 +203,7 @@ class TASmartLLM:
|
||||
"""
|
||||
try:
|
||||
url = f"http://127.0.0.1:{port}/v1/models" if "LMStudio" in backend else f"http://127.0.0.1:{port}/api/tags"
|
||||
return requests.get(url, timeout=2).status_code == 200
|
||||
return requests.get(url, timeout=0.5).status_code == 200
|
||||
except:
|
||||
return False
|
||||
|
||||
@@ -230,30 +251,20 @@ class TASmartLLM:
|
||||
img.save(buffer, 'PNG')
|
||||
return base64.b64encode(buffer.getvalue()).decode('utf-8')
|
||||
|
||||
def _flush_lmstudio_context(self, url, model_name):
|
||||
"""
|
||||
Sends a minimal request to clear LM Studio chat context.
|
||||
"""
|
||||
try:
|
||||
requests.post(url, json={
|
||||
"model": model_name,
|
||||
"messages": [{"role": "user", "content": "."}],
|
||||
"max_tokens": 1
|
||||
}, timeout=10)
|
||||
except:
|
||||
pass
|
||||
time.sleep(0.5)
|
||||
|
||||
def _post_with_retry(self, url, payload, is_lmstudio, max_retries=3, retry_delay=1.5):
|
||||
def _post_with_retry(self, url, payload, is_lmstudio, max_retries=3, retry_delay=1.5, timeout=120):
|
||||
"""
|
||||
Posts to LLM API with retry logic for transient errors.
|
||||
For LM Studio returns the full message dict; for Ollama returns the response string.
|
||||
"""
|
||||
last_error = None
|
||||
for attempt in range(1, max_retries + 1):
|
||||
try:
|
||||
r = requests.post(url, json=payload, timeout=120)
|
||||
r = requests.post(url, json=payload, timeout=timeout)
|
||||
r.raise_for_status()
|
||||
return r.json()['choices'][0]['message']['content'] if is_lmstudio else r.json()['response']
|
||||
if is_lmstudio:
|
||||
return r.json()['choices'][0]['message'] # Return full message dict
|
||||
else:
|
||||
return r.json()['response']
|
||||
except requests.exceptions.HTTPError as e:
|
||||
last_error = e
|
||||
if e.response is not None and e.response.status_code in (400, 500, 502, 503) and attempt < max_retries:
|
||||
@@ -269,6 +280,8 @@ class TASmartLLM:
|
||||
raise last_error
|
||||
|
||||
def generate(self, llm_enable, model, user_prompt, system_prompt,
|
||||
temperature=0.7, max_tokens=1024, request_timeout=120,
|
||||
thinking_mode=False,
|
||||
unload_image_models_first=False, unload_llm_after=False,
|
||||
image=None):
|
||||
"""
|
||||
@@ -291,10 +304,10 @@ class TASmartLLM:
|
||||
image: Optional IMAGE for vision models.
|
||||
|
||||
Returns:
|
||||
tuple: (generated_prompt: str, status: str)
|
||||
tuple: (generated_prompt: str, status: str, reasoning: str)
|
||||
"""
|
||||
if not llm_enable:
|
||||
return ("", "DISABLED")
|
||||
return ("", "DISABLED", "")
|
||||
|
||||
clean_model = strip_vision_tag(model)
|
||||
backend = clean_model.split('/')[0]
|
||||
@@ -302,7 +315,7 @@ class TASmartLLM:
|
||||
port = 1234 if "LMStudio" in backend else 11434
|
||||
|
||||
if not self._backend_reachable(backend, port):
|
||||
return ("", f"SKIPPED - {backend} not reachable")
|
||||
return ("", f"SKIPPED - {backend} not reachable", "")
|
||||
|
||||
print(f"[TA Smart LLM] Loading model: {clean_model}")
|
||||
|
||||
@@ -318,7 +331,6 @@ class TASmartLLM:
|
||||
if "LMStudio" in backend:
|
||||
url = f"http://127.0.0.1:{port}/v1/chat/completions"
|
||||
if img_b64:
|
||||
self._flush_lmstudio_context(url, model_name)
|
||||
user_content = [
|
||||
{"type": "text", "text": full_prompt},
|
||||
{"type": "image_url", "image_url": {"url": f"data:image/png;base64,{img_b64}"}}
|
||||
@@ -331,10 +343,30 @@ class TASmartLLM:
|
||||
{"role": "system", "content": system_prompt},
|
||||
{"role": "user", "content": user_content}
|
||||
],
|
||||
"max_tokens": 1024
|
||||
"temperature": temperature,
|
||||
"max_tokens": max_tokens
|
||||
}
|
||||
|
||||
result = self._post_with_retry(url, payload, is_lmstudio=True)
|
||||
message = self._post_with_retry(url, payload, is_lmstudio=True, timeout=request_timeout)
|
||||
|
||||
content = (message.get('content') or '').strip()
|
||||
reasoning = (message.get('reasoning_content') or '').strip()
|
||||
|
||||
if thinking_mode:
|
||||
# Thinking ON → return full content including thinking
|
||||
result = content if content else reasoning
|
||||
else:
|
||||
# Thinking OFF → return only the final answer, strip thinking
|
||||
if content:
|
||||
if "</think>" in content:
|
||||
result = content.split("</think>", 1)[-1].strip()
|
||||
else:
|
||||
result = content
|
||||
else:
|
||||
if "</think>" in reasoning:
|
||||
result = reasoning.split("</think>", 1)[-1].strip()
|
||||
else:
|
||||
result = "" # Pure thinking block, no answer
|
||||
|
||||
# Unload LM Studio model after request
|
||||
if unload_llm_after:
|
||||
@@ -345,22 +377,35 @@ class TASmartLLM:
|
||||
payload = {
|
||||
"model": model_name,
|
||||
"prompt": f"{system_prompt}\n\n{full_prompt}".strip(),
|
||||
"stream": False
|
||||
"stream": False,
|
||||
"options": {
|
||||
"temperature": temperature,
|
||||
"num_predict": max_tokens
|
||||
}
|
||||
}
|
||||
|
||||
if img_b64:
|
||||
payload["images"] = [img_b64]
|
||||
result = self._post_with_retry(url, payload, is_lmstudio=False)
|
||||
result = self._post_with_retry(url, payload, is_lmstudio=False, timeout=request_timeout)
|
||||
reasoning = ""
|
||||
|
||||
# Ollama: strip <think> tags if thinking is OFF
|
||||
if not thinking_mode and "</think>" in result:
|
||||
reasoning = result.split("</think>", 1)[0].replace("<think>", "").strip()
|
||||
result = result.split("</think>", 1)[-1].strip()
|
||||
|
||||
# Unload Ollama model after request
|
||||
if unload_llm_after:
|
||||
self._unload_ollama_llm(model_name)
|
||||
|
||||
return (result.strip(), f"{clean_model} ✅")
|
||||
if result.strip():
|
||||
return (result.strip(), f"{clean_model} ✅", reasoning)
|
||||
else:
|
||||
return ("", f"WARNING: {clean_model} returned empty response", reasoning)
|
||||
|
||||
except Exception as e:
|
||||
return (f"ERROR: {str(e)}", clean_model)
|
||||
return (f"ERROR: {str(e)}", clean_model, "")
|
||||
|
||||
|
||||
NODE_CLASS_MAPPINGS = {"TASmartLLM": TASmartLLM}
|
||||
NODE_DISPLAY_NAME_MAPPINGS = {"TASmartLLM": "TA Smart LLM v2.2"}
|
||||
NODE_DISPLAY_NAME_MAPPINGS = {"TASmartLLM": "TA Smart LLM v3.8"}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
["LMStudio/cognitivecomputations_dolphin-mistral-24b-venice-edition", "LMStudio/cydonia-24b-v4.1", "LMStudio/deepseek-coder-v2-lite-16b", "LMStudio/gemma-3-27b-it-qat", "LMStudio/huihui-qwen3-vl-8b-instruct-abliterated", "LMStudio/llama-3.1-unhinged-vision-8b", "LMStudio/llama-3.2-1b-instruct", "LMStudio/llava-v1.5-7b-llamafile", "LMStudio/mistral-catmacaroni-slerp-uncensored-7b", "LMStudio/mistral-small-3.1-draft-0.5b", "LMStudio/mistralai/devstral-small-2-2512", "LMStudio/mistralai/ministral-3-14b-reasoning", "LMStudio/qwen2.5-0.5b-instruct", "LMStudio/qwen2.5-0.5b-song-lyrics-generation", "LMStudio/qwen3-30b-a3b-thinking-2507-claude-4.5-sonnet-high-reasoning-distill", "LMStudio/qwen3-4b-thinking-2507", "LMStudio/qwen3-coder-30b-a3b-instruct", "LMStudio/qwen3-vl-8b-instruct", "LMStudio/text-embedding-nomic-embed-text-v1.5", "LMStudio/wizardlm-1.0-uncensored-llama2-13b", "LMStudio/xortron2025"]
|
||||
@@ -21,7 +21,7 @@ app.registerExtension({
|
||||
if (onNodeCreated) onNodeCreated.apply(this, arguments);
|
||||
|
||||
this.addWidget("button", "✏️ Model Preset Editor öffnen", null, () => {
|
||||
window.open("http://localhost:8188/ta_model_presets/ui", "_blank");
|
||||
window.open(window.location.origin + "/ta_model_presets/ui", "_blank");
|
||||
});
|
||||
};
|
||||
},
|
||||
|
||||
@@ -21,7 +21,7 @@ app.registerExtension({
|
||||
if (onNodeCreated) onNodeCreated.apply(this, arguments);
|
||||
|
||||
this.addWidget("button", "✏️ Preset Editor öffnen", null, () => {
|
||||
window.open("http://localhost:8188/ta_sampler_presets/ui", "_blank");
|
||||
window.open(window.location.origin + "/ta_sampler_presets/ui", "_blank");
|
||||
});
|
||||
};
|
||||
},
|
||||
|
||||
+60
-14
@@ -426,9 +426,13 @@ Der Node erkennt automatisch welche Modelle Vision-fähig sind und kennzeichnet
|
||||
| Name | Typ | Beschreibung |
|
||||
|------|-----|--------------|
|
||||
| `llm_enable` | BOOLEAN | Master-Schalter. Bei `OFF` wird der Node übersprungen und gibt leeren String zurück. |
|
||||
| `model` | Dropdown | Auswahl des LLM-Modells. Automatisch befüllt aus LM Studio und Ollama. Vision-Modelle sind mit `[Vision]` gekennzeichnet. |
|
||||
| `model` | Dropdown | Auswahl des LLM-Modells. Automatisch befüllt aus LM Studio und Ollama. Vision-Modelle sind mit `[Vision]` gekennzeichnet. Aktive Modelle erscheinen oben in der Liste. |
|
||||
| `user_prompt` | STRING | Haupteingabe für den LLM (Text2Prompt oder Bildbeschreibungsanweisung). |
|
||||
| `system_prompt` | STRING | Systemanweisung für das Modell, z.B. Rolle oder Ausgabeformat. |
|
||||
| `temperature` | FLOAT | Kreativität der Ausgabe. Niedrig (0.3–0.5) für präzise Beschreibungen, höher (0.7–0.9) für kreative Prompts. Standard: `0.7`. |
|
||||
| `max_tokens` | INT | Maximale Anzahl an Tokens in der Antwort. Obere Grenze – das Modell hört auf wenn es fertig ist. Standard: `1024`. |
|
||||
| `request_timeout` | INT | Timeout für die LLM-Anfrage in Sekunden. Bei langsamen Systemen oder großen `max_tokens`-Werten erhöhen. Standard: `120`. |
|
||||
| `thinking_mode` | BOOLEAN | Steuerung des Thinking-Modus für Reasoning-Modelle (z.B. Qwen3). `ON` = Thinking-Block wird ausgegeben, `OFF` = nur der finale Prompt wird zurückgegeben. |
|
||||
| `unload_image_models_first` | BOOLEAN | Entlädt ComfyUI-Bildmodelle vor der LLM-Anfrage, um VRAM freizugeben. |
|
||||
| `unload_llm_after` | BOOLEAN | Entlädt das LLM-Modell nach der Generierung aus dem Backend. |
|
||||
| `image` | IMAGE *(optional)* | Bild-Input für Vision-Modelle (Image2Prompt). Wird ignoriert wenn kein Vision-Modell ausgewählt ist. |
|
||||
@@ -437,8 +441,8 @@ Der Node erkennt automatisch welche Modelle Vision-fähig sind und kennzeichnet
|
||||
|
||||
| Name | Typ | Beschreibung |
|
||||
|------|-----|--------------|
|
||||
| `prompt` | STRING | Der generierte Prompt-Text. |
|
||||
| `status` | STRING | Status der Ausführung, z.B. `LMStudio/model ✅`, `DISABLED`, `SKIPPED - Ollama not reachable`. |
|
||||
| `prompt` | STRING | Der generierte Prompt-Text. Leer wenn das Modell keine Antwort liefert. |
|
||||
| `status` | STRING | Status der Ausführung, z.B. `LMStudio/model ✅`, `DISABLED`, `SKIPPED - Ollama not reachable`, `WARNING: model returned empty response`. |
|
||||
|
||||
---
|
||||
|
||||
@@ -456,9 +460,13 @@ Modelle die nicht automatisch erkannt werden, können manuell in `VISION_MANUAL`
|
||||
|
||||
Beim Start fragt der Node LM Studio (Port `1234`) und Ollama (Port `11434`) nach verfügbaren Modellen. Die Ergebnisse werden in der Datei `ta_smart_llm_models.json` im Node-Pack-Verzeichnis gespeichert.
|
||||
|
||||
Ist ein Backend beim nächsten Start nicht erreichbar, werden die zuletzt bekannten Modelle aus dem Cache geladen und im Dropdown angezeigt – so bleibt das Dropdown auch bei gestopptem Backend befüllt.
|
||||
**Aktive Modelle erscheinen oben** in der Dropdown-Liste, Modelle von nicht erreichbaren Backends werden darunter angezeigt – so ist auf einen Blick erkennbar welches Backend gerade läuft.
|
||||
|
||||
> ⚠️ **ComfyUI muss neu gestartet werden**, damit neu installierte Modelle im Dropdown erscheinen.
|
||||
Ist ein Backend beim nächsten Start nicht erreichbar, werden die zuletzt bekannten Modelle aus dem Cache geladen und im Dropdown angezeigt – das gespeicherte Modell bleibt immer in der Liste und der Workflow bricht nicht ab.
|
||||
|
||||
Neu installierte oder gelöschte Modelle werden automatisch beim nächsten Workflow-Run erkannt – ein ComfyUI-Neustart ist nicht erforderlich.
|
||||
|
||||
> ⚠️ Die Datei `ta_smart_llm_models.json` sollte als leere Datei (`[]`) weitergegeben werden, damit Empfänger nicht deine persönlichen Modellnamen im Dropdown sehen.
|
||||
|
||||
---
|
||||
|
||||
@@ -467,8 +475,17 @@ Ist ein Backend beim nächsten Start nicht erreichbar, werden die zuletzt bekann
|
||||
**Kein Backend erreichbar**
|
||||
Ist weder LM Studio noch Ollama beim Start von ComfyUI erreichbar und kein Cache vorhanden, zeigt das Dropdown `No Backend`. Der Node gibt dann beim Ausführen `SKIPPED` als Status zurück und erzeugt keinen Fehler im Workflow.
|
||||
|
||||
**ComfyUI-Neustart nach Modellinstallation**
|
||||
Neu installierte Modelle in LM Studio oder Ollama erscheinen erst nach einem Neustart von ComfyUI im Dropdown, da die Modellliste nur beim Start befüllt wird.
|
||||
**Leere Antwort**
|
||||
Gibt das Modell einen leeren Prompt zurück, erscheint im `status` Output `WARNING: model returned empty response`. Das deutet auf ein Modell- oder Backend-Problem hin, nicht auf einen Node-Fehler.
|
||||
|
||||
**Thinking-Modelle (z.B. Qwen3)**
|
||||
Modelle mit Reasoning-Modus generieren intern einen Denkprozess. Mit `thinking_mode OFF` wird dieser automatisch entfernt und nur der finale Prompt ausgegeben. LM Studio 0.4.7+ liefert Thinking-Content im separaten Feld `reasoning_content` – der Node liest beide Felder korrekt aus.
|
||||
|
||||
**temperature & max_tokens**
|
||||
Für Text2Prompt empfiehlt sich `temperature` zwischen `0.7` und `0.9`. Für Image2Prompt (präzise Bildbeschreibung) ist `0.3`–`0.5` sinnvoller. `max_tokens` ist eine Obergrenze – das Modell hört auf wenn es fertig ist, nicht erst bei Erreichen des Limits.
|
||||
|
||||
**request_timeout**
|
||||
Bei großen `max_tokens`-Werten oder langsamen Systemen den Timeout entsprechend erhöhen. Standard ist `120` Sekunden.
|
||||
|
||||
**VRAM-Management**
|
||||
`unload_image_models_first` ist nützlich bei knappem VRAM – es entlädt alle ComfyUI-Bildmodelle bevor das LLM lädt. `unload_llm_after` gibt den VRAM nach der Generierung wieder frei, bevor der restliche Workflow die Bildmodelle lädt.
|
||||
@@ -476,6 +493,12 @@ Neu installierte Modelle in LM Studio oder Ollama erscheinen erst nach einem Neu
|
||||
**Image2Prompt**
|
||||
Für Image2Prompt ein `[Vision]`-Modell auswählen und ein Bild am `image`-Eingang verbinden. Im `user_prompt` die gewünschte Anweisung eingeben, z.B. `Describe this image as a detailed Stable Diffusion prompt.`
|
||||
|
||||
**Manuelle Vision-Kennzeichnung**
|
||||
Modelle die nicht automatisch als Vision erkannt werden (z.B. weil `vl` nicht im Namen vorkommt) können manuell in `VISION_MANUAL` in der Datei `ta_smart_llm.py` eingetragen werden:
|
||||
```python
|
||||
VISION_MANUAL = {"mein-vision-model-7b"}
|
||||
```
|
||||
|
||||
---
|
||||
---
|
||||
|
||||
@@ -1341,9 +1364,13 @@ The node automatically detects which models are vision-capable and marks them in
|
||||
| Name | Type | Description |
|
||||
|------|------|-------------|
|
||||
| `llm_enable` | BOOLEAN | Master toggle. When `OFF`, the node is skipped and returns an empty string. |
|
||||
| `model` | Dropdown | LLM model selection. Auto-populated from LM Studio and Ollama. Vision models are marked with `[Vision]`. |
|
||||
| `model` | Dropdown | LLM model selection. Auto-populated from LM Studio and Ollama. Vision models are marked with `[Vision]`. Active models appear at the top of the list. |
|
||||
| `user_prompt` | STRING | Main input for the LLM (Text2Prompt or image description instruction). |
|
||||
| `system_prompt` | STRING | System instruction for the model, e.g. role or output format. |
|
||||
| `temperature` | FLOAT | Output creativity. Low (0.3–0.5) for precise descriptions, higher (0.7–0.9) for creative prompts. Default: `0.7`. |
|
||||
| `max_tokens` | INT | Maximum number of tokens in the response. Upper limit – the model stops when finished, not necessarily at this value. Default: `1024`. |
|
||||
| `request_timeout` | INT | Timeout for the LLM request in seconds. Increase for slow systems or large `max_tokens` values. Default: `120`. |
|
||||
| `thinking_mode` | BOOLEAN | Controls the thinking mode for reasoning models (e.g. Qwen3). `ON` = thinking block is included in the output, `OFF` = only the final prompt is returned. |
|
||||
| `unload_image_models_first` | BOOLEAN | Unloads ComfyUI image models before the LLM request to free VRAM. |
|
||||
| `unload_llm_after` | BOOLEAN | Unloads the LLM model from the backend after generation. |
|
||||
| `image` | IMAGE *(optional)* | Image input for vision models (Image2Prompt). Ignored if no vision model is selected. |
|
||||
@@ -1352,8 +1379,8 @@ The node automatically detects which models are vision-capable and marks them in
|
||||
|
||||
| Name | Type | Description |
|
||||
|------|------|-------------|
|
||||
| `prompt` | STRING | The generated prompt text. |
|
||||
| `status` | STRING | Execution status, e.g. `LMStudio/model ✅`, `DISABLED`, `SKIPPED - Ollama not reachable`. |
|
||||
| `prompt` | STRING | The generated prompt text. Empty if the model returns no response. |
|
||||
| `status` | STRING | Execution status, e.g. `LMStudio/model ✅`, `DISABLED`, `SKIPPED - Ollama not reachable`, `WARNING: model returned empty response`. |
|
||||
|
||||
---
|
||||
|
||||
@@ -1371,9 +1398,13 @@ Models that are not detected automatically can be added manually to `VISION_MANU
|
||||
|
||||
On startup, the node queries LM Studio (port `1234`) and Ollama (port `11434`) for available models. The results are saved to `ta_smart_llm_models.json` in the node pack directory.
|
||||
|
||||
If a backend is unavailable on the next startup, the last known models are loaded from the cache and shown in the dropdown – keeping the dropdown populated even when a backend is stopped.
|
||||
**Active models appear at the top** of the dropdown list, while models from unreachable backends are shown below – making it immediately clear which backend is currently running.
|
||||
|
||||
> ⚠️ **ComfyUI must be restarted** for newly installed models to appear in the dropdown.
|
||||
If a backend is unavailable on the next startup, the last known models are loaded from the cache and shown in the dropdown – the saved model is always kept in the list to prevent workflow validation errors.
|
||||
|
||||
Added or removed models are detected automatically on the next workflow run – no ComfyUI restart required.
|
||||
|
||||
> ⚠️ The file `ta_smart_llm_models.json` should be distributed as an empty file (`[]`) so that recipients do not see your personal model names in the dropdown.
|
||||
|
||||
---
|
||||
|
||||
@@ -1382,8 +1413,17 @@ If a backend is unavailable on the next startup, the last known models are loade
|
||||
**No backend reachable**
|
||||
If neither LM Studio nor Ollama is reachable at ComfyUI startup and no cache exists, the dropdown shows `No Backend`. When executed, the node returns `SKIPPED` as status and does not cause a workflow error.
|
||||
|
||||
**ComfyUI restart after model installation**
|
||||
Newly installed models in LM Studio or Ollama only appear in the dropdown after restarting ComfyUI, as the model list is only populated at startup.
|
||||
**Empty response**
|
||||
If the model returns an empty prompt, the `status` output shows `WARNING: model returned empty response`. This indicates a model or backend issue, not a node error.
|
||||
|
||||
**Thinking models (e.g. Qwen3)**
|
||||
Models with a reasoning mode generate an internal thinking process. With `thinking_mode OFF`, this is automatically removed and only the final prompt is returned. LM Studio 0.4.7+ delivers thinking content in the separate `reasoning_content` field – the node reads both fields correctly.
|
||||
|
||||
**temperature & max_tokens**
|
||||
For Text2Prompt a `temperature` between `0.7` and `0.9` is recommended. For Image2Prompt (precise image description), `0.3`–`0.5` is more appropriate. `max_tokens` is an upper limit – the model stops when it is done, not necessarily at this value.
|
||||
|
||||
**request_timeout**
|
||||
For large `max_tokens` values or slow systems, increase the timeout accordingly. Default is `120` seconds.
|
||||
|
||||
**VRAM management**
|
||||
`unload_image_models_first` is useful when VRAM is tight – it unloads all ComfyUI image models before the LLM loads. `unload_llm_after` frees VRAM after generation before the rest of the workflow loads image models.
|
||||
@@ -1391,6 +1431,12 @@ Newly installed models in LM Studio or Ollama only appear in the dropdown after
|
||||
**Image2Prompt**
|
||||
For Image2Prompt, select a `[Vision]` model and connect an image to the `image` input. Enter the desired instruction in `user_prompt`, e.g. `Describe this image as a detailed Stable Diffusion prompt.`
|
||||
|
||||
**Manual vision tagging**
|
||||
Models not automatically detected as vision-capable (e.g. because `vl` is not in the name) can be added manually to `VISION_MANUAL` in `ta_smart_llm.py`:
|
||||
```python
|
||||
VISION_MANUAL = {"my-vision-model-7b"}
|
||||
```
|
||||
|
||||
---
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user