346f859b86
Cubre 15 funciones del grupo comfyui (+ las 4 de comfyui-judge) que no tenian test, con tests offline (sin red, sin GPU, sin servidor ComfyUI): - 5 builders puros gamedev-2d: build_asset_variant, build_directional_sprite, build_inpaint_asset, build_outpaint_asset, build_sprite_from_sketch (estructura del workflow en API format + cableado + determinismo + error paths). - 3 impuras offline via PIL/stdlib: build_grid, flatten_alpha_on_color, read_png_metadata (PNGs reales en tmp, error paths). - 4 de comfyui-judge: score_aesthetic y score_clip_alignment por sus guards previos al subproceso torch; judge_image (panel) y critique_image_llm con la dependencia pesada monkeypatcheada. - 3 que componen otras funciones: resolve_workflow_deps, import_workflow_json, extract_recipe_from_png (dependencia de red monkeypatcheada o fallback offline). Cada .md actualizado con tested: true + test_file_path + tests. Cobertura del grupo comfyui (tag plano): 79 -> 90 con test (47 -> 36 sin). comfyui-judge: 0/4 -> 4/4. pytest: 101 passed; carpeta ml/tests: 376 passed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
3.8 KiB
3.8 KiB
name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, params, output, tested, tests, test_file_path, file_path
| name | kind | lang | domain | version | purity | signature | description | tags | uses_functions | uses_types | returns | returns_optional | error_type | imports | params | output | tested | tests | test_file_path | file_path | ||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| comfyui_build_grid | function | py | ml | 1.0.0 | impure | def comfyui_build_grid(image_paths: list, *, cols: int | None = None, cell: int = 512, out_path: str | None = None, labels: list | None = None) -> dict | Monta un grid / contact-sheet PIL de N imagenes para comparacion visual (p.ej. el output de comfyui_batch_generate con varios seeds). Cada celda conserva el aspect ratio (thumbnail centrado sobre fondo oscuro); rejilla casi cuadrada por defecto (cols=ceil(sqrt(N))). Rotulos opcionales por celda. Usa PIL (Pillow) del venv del registry. Devuelve {ok, out_path, rows, cols, error}. Impura: lee N imagenes y escribe un PNG. |
|
false | error_go_core |
|
dict con ok (bool), out_path (str, ruta del PNG generado), rows (int, filas), cols (int, columnas), error (str, vacio si OK). | true |
|
python/functions/ml/tests/test_comfyui_build_grid.py | python/functions/ml/comfyui_build_grid.py |
Ejemplo
import sys, os
sys.path.insert(0, os.path.join(os.environ["HOME"], "fn_registry", "python", "functions"))
from ml.comfyui_build_grid import comfyui_build_grid
imgs = [
os.path.expanduser("~/ComfyUI/output/comfy_00001_.png"),
os.path.expanduser("~/ComfyUI/output/comfy_00002_.png"),
os.path.expanduser("~/ComfyUI/output/comfy_00003_.png"),
os.path.expanduser("~/ComfyUI/output/comfy_00004_.png"),
]
res = comfyui_build_grid(imgs, cols=2, cell=512, out_path="/tmp/seeds_grid.png",
labels=["seed 1", "seed 2", "seed 3", "seed 4"])
# {'ok': True, 'out_path': '/tmp/seeds_grid.png', 'rows': 2, 'cols': 2, 'error': ''}
Cuando usarla
Tras un barrido de seeds con comfyui_batch_generate + comfyui_fetch_output_image:
en vez de abrir N PNGs uno a uno, montas un unico contact-sheet para elegir de un
vistazo la mejor variante (o comparar steps/cfg/sampler distintos). Tambien sirve
para documentar un report con una rejilla de resultados. Es post-proceso local
puro de imagen: no toca el servidor ComfyUI.
Gotchas
- Si alguna ruta de
image_pathsno existe, devuelveok=Falsecon la lista de faltantes (estricto): no monta una rejilla parcial silenciosamente. Filtra las rutas validas antes si quieres tolerar ausencias. - Cada imagen se reduce a
cellpx conservando proporcion (thumbnail); imagenes de distinto tamano quedan centradas en su celda con relleno, no estiradas. labelsse dibuja con la fuente por defecto de PIL (pequeña, sin TTF externo); para rotulos grandes habria que pasar una fuente — no soportado hoy (KISS).- Escribe el PNG en disco: si
out_pathapunta a un directorio inexistente lo crea; si no tiene permiso devuelveok=Falsecon el error. - N grande con
cellalto produce un canvas enorme (rowscolscell^2 px): para decenas de imagenes bajacell(p.ej. 256) para no agotar memoria.