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>
4.4 KiB
4.4 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_judge_image | function | py | ml | 1.0.0 | impure | def comfyui_judge_image(image_path: str, prompt: str, *, weights: dict = None, threshold: float = 6.0, clip_threshold: float = 0.24, server: str = '127.0.0.1:8188', model: str = 'claude-opus-4-8', venv_python: str = '~/ComfyUI/.venv/bin/python3') -> dict | Panel multi-juez que vota good/bad la calidad de una imagen generada. Agregadora del grupo comfyui-judge: combina comfyui_score_aesthetic (estetico 0-10), comfyui_score_clip_alignment (fidelidad 0-1) y comfyui_critique_image_llm (LLM-vision good/bad). Cada juez vota; veredicto por MAYORIA. Si un juez falla, se excluye y se anota; el panel sigue con los restantes. Es el gate objetivo para tests/DoD y el bucle de mejora de skills. |
|
|
false | error_go_core |
|
dict {ok, verdict, score, votes, reasons, error, details}. verdict 'good'|'bad' por mayoria; score media ponderada 0-10 de los jueces vivos; votes = {clip, aesthetic, llm} cada uno 'good'|'bad'|'failed'; reasons agrega razones del critico + notas de jueces caidos; details lleva el dict crudo de cada juez. ok=False solo si los tres fallan. | true |
|
python/functions/ml/tests/test_comfyui_judge_image.py | python/functions/ml/comfyui_judge_image.py |
Ejemplo
import sys, os
sys.path.insert(0, os.path.join("python", "functions"))
from ml.comfyui_judge_image import comfyui_judge_image
img = os.path.expanduser("~/ComfyUI/output/comfy_sdxl_00001_.png")
res = comfyui_judge_image(img, "a majestic lion standing on rocks at sunset, photorealistic")
print(res["verdict"], round(res["score"], 2), res["votes"])
# good 7.1 {'aesthetic': 'good', 'clip': 'good', 'llm': 'good'}
CLI directa:
python/.venv/bin/python3 python/functions/ml/comfyui_judge_image.py ~/ComfyUI/output/comfy_sdxl_00001_.png "a majestic lion at sunset"
Cuando usarla
- Como GATE objetivo de un test o DoD: "la imagen que produce este skill ComfyUI debe pasar el panel (verdict='good')". Un voto mayoritario es mas robusto que un solo score.
- En el bucle de mejora de skills: si el panel vota 'bad', sus
reasonsdicen que arreglar. - Para elegir la mejor de N generaciones: ejecutar el panel sobre cada una y rankear por
score(o exigir verdict='good').
Gotchas
- Es la suma de las gotchas de sus tres jueces. Necesita el venv de ComfyUI (torch + open_clip) para estetico/fidelidad y la API Anthropic para el critico.
- Degradacion, no fallo. Si un juez cae (p.ej. el LLM en 429), se marca
votes[x]='failed', se anota enreasonsy el veredicto sale por mayoria de los 2 restantes. Solook=Falsesi los TRES fallan. - Empate => 'bad'. Con 2 jueces vivos y voto 1-1 (o cualquier empate), el veredicto es 'bad' por conservadurismo (ante la duda, no es producto).
- El voto es 1 juez = 1 voto; los
weightssolo ponderan elscorenumerico, no el veredicto. Para cambiar el veredicto, ajustathreshold/clip_threshold. - El juez critico cuesta API. Llamar al panel en bucle sobre muchas imagenes consume tokens; considerar saltarse el LLM (futuro flag) para barridos grandes.