comfyui-stanno / __init__.py
oldman-dev's picture
Up-to-date with original repo
8a0f449 verified
# comfyui-stanno — STANNO Custom Nodes for ComfyUI
#
# Nodes provided (category "STANNO"):
# STANNOLoad — load or create a STANNO model from disk
# STANNOTrainImages — train STANNO as autoencoder on an image batch
# STANNOScoreImages — score / filter images by reconstruction error
# STANNODreamCond — inject dream-mode creativity into CONDITIONING
# STANNODynamicLoRA — patch MODEL attention weights via STANNO dream output
# STANNOCompositeCheck — route a batch to whichever of two STANNOs it matches best
# STANNOScan — DSANNO scanner: auto-calibrated threshold + top-k retrieval
# STANNOCascadeLoad — load or create a CascadeSTANNO (multi-stage chain)
# STANNOCascadeTrainImages— train a CascadeSTANNO end-to-end on an image batch
import os as _os
import sys as _sys
def _ensure_stanno_importable() -> None:
"""
Make the `stanno` Python package importable.
Resolution order:
1. Already pip-installed (pip install stanno or pip install -e .) → done.
2. Monorepo layout: this __init__.py is at <repo>/comfyui-stanno/__init__.py
and the stanno Python package lives at <repo>/stanno/.
→ add <repo> to sys.path.
3. Neither works → raise ImportError with install instructions.
"""
try:
import stanno # noqa: F401
return
except ImportError:
pass
# Monorepo detection: look for stanno/ one level above this file's directory.
_here = _os.path.dirname(_os.path.abspath(__file__))
_parent = _os.path.dirname(_here)
if _os.path.isdir(_os.path.join(_parent, "stanno")):
if _parent not in _sys.path:
_sys.path.insert(0, _parent)
try:
import stanno # noqa: F401
return
except ImportError:
pass
raise ImportError(
"The `stanno` package is not installed and could not be found automatically.\n"
"Install it with:\n"
" pip install git+https://github.com/USER/stanno.git\n"
"Or clone the stanno repo and place this comfyui-stanno/ folder inside it."
)
_ensure_stanno_importable()
from .nodes import ( # noqa: E402
comfy_entrypoint,
STANNOLoad,
STANNOTrainImages,
STANNOScoreImages,
STANNODreamCond,
STANNODynamicLoRA,
STANNOCompositeCheck,
STANNOScan,
STANNOCascadeLoad,
STANNOCascadeTrainImages,
)
# NODE_CLASS_MAPPINGS: required by older ComfyUI builds; harmless on newer ones.
NODE_CLASS_MAPPINGS = {
"STANNOLoad": STANNOLoad,
"STANNOTrainImages": STANNOTrainImages,
"STANNOScoreImages": STANNOScoreImages,
"STANNODreamCond": STANNODreamCond,
"STANNODynamicLoRA": STANNODynamicLoRA,
"STANNOCompositeCheck": STANNOCompositeCheck,
"STANNOScan": STANNOScan,
"STANNOCascadeLoad": STANNOCascadeLoad,
"STANNOCascadeTrainImages": STANNOCascadeTrainImages,
}
NODE_DISPLAY_NAME_MAPPINGS = {
"STANNOLoad": "STANNO Loader",
"STANNOTrainImages": "STANNO Train from Images",
"STANNOScoreImages": "STANNO Image Scorer",
"STANNODreamCond": "STANNO Dream Conditioning",
"STANNODynamicLoRA": "STANNO Dynamic LoRA",
"STANNOCompositeCheck": "STANNO Composite Style Checker",
"STANNOScan": "STANNO Scan (DSANNO)",
"STANNOCascadeLoad": "STANNO Cascade Loader",
"STANNOCascadeTrainImages": "STANNO Cascade Train from Images",
}
__all__ = [
"comfy_entrypoint",
"NODE_CLASS_MAPPINGS",
"NODE_DISPLAY_NAME_MAPPINGS",
]