File size: 3,667 Bytes
8a0f449
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# 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",
]