Files
fn_registry/python/functions/pipelines/comfyui_txt2img_oneshot.md
T
egutierrez f686b338d6 chore: auto-commit (14 archivos)
- docs/capabilities/comfyui.md
- python/functions/ml/comfyui_build_image_to_3d_workflow.md
- python/functions/ml/comfyui_build_image_to_3d_workflow.py
- python/functions/ml/tests/test_comfyui_build_image_to_3d_workflow.py
- python/functions/ml/comfyui_build_facedetailer_workflow.md
- python/functions/ml/comfyui_build_facedetailer_workflow.py
- python/functions/ml/comfyui_build_hires_fix_workflow.md
- python/functions/ml/comfyui_build_hires_fix_workflow.py
- python/functions/ml/tests/test_comfyui_build_facedetailer_workflow.py
- python/functions/ml/tests/test_comfyui_build_hires_fix_workflow.py
- ...

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-24 02:34:10 +02:00

4.2 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_txt2img_oneshot pipeline py pipelines 1.0.0 impure def comfyui_txt2img_oneshot(prompt: str, *, ckpt: str = "dreamshaper_8.safetensors", negative: str = "", server: str = "127.0.0.1:8188", dest: str | None = None, wait_timeout: float = 300.0, **gen) -> dict Pipeline prompt de texto -> PNG en disco en una sola llamada. Construye el workflow txt2img de Stable Diffusion, lo encola en ComfyUI, espera y descarga la imagen. Compone comfyui_build_txt2img_workflow + comfyui_submit_workflow + comfyui_wait_result + comfyui_fetch_output_image. Promocion de secuencia (issue 0087). Impuro: HTTP + disco.
comfyui
pipelines
txt2img
stable-diffusion
launcher
comfyui_build_txt2img_workflow_py_ml
comfyui_submit_workflow_py_ml
comfyui_wait_result_py_ml
comfyui_fetch_output_image_py_ml
false error_py_core
comfyui_build_txt2img_workflow_py_ml
comfyui_submit_workflow_py_ml
comfyui_wait_result_py_ml
comfyui_fetch_output_image_py_ml
name desc
prompt Prompt positivo (lo que se quiere ver en la imagen).
name desc
ckpt Checkpoint Stable Diffusion tal como lo ve el servidor (CheckpointLoaderSimple). Por defecto 'dreamshaper_8.safetensors'. keyword-only.
name desc
negative Prompt negativo. Por defecto ''. keyword-only.
name desc
server host:port del servidor ComfyUI (sin esquema). keyword-only.
name desc
dest Directorio local donde guardar el PNG (None = cwd). keyword-only.
name desc
wait_timeout Segundos maximos esperando a que el server termine. keyword-only.
name desc
gen Parametros de generacion pasados a comfyui_build_txt2img_workflow (steps, cfg, width, height, seed, sampler_name, scheduler, filename_prefix). keyword-only (**gen).
dict {ok, image_path, prompt_id, error}. image_path = ruta local del PNG descargado; prompt_id = id del trabajo en ComfyUI. Si falla, ok=False y error explica en que paso. false
python/functions/pipelines/comfyui_txt2img_oneshot.py

Ejemplo

# Genera una imagen desde texto y la baja a /tmp.
./fn run comfyui_txt2img_oneshot "a red apple on a wooden table, sharp focus"
import sys, os
sys.path.insert(0, os.path.join(os.environ["HOME"], "fn_registry", "python", "functions"))
from pipelines.comfyui_txt2img_oneshot import comfyui_txt2img_oneshot

res = comfyui_txt2img_oneshot(
    "a red apple on a wooden table, sharp focus",
    negative="blurry, low quality",
    dest="/tmp/comfy_txt2img",
    steps=20,
    seed=42,
)
# res["ok"] == True
# res["image_path"]  # ruta local del PNG
print(res["image_path"], res["prompt_id"])

Cuando usarla

Cuando solo quieres "texto → imagen" sin montar el grafo a mano ni encadenar submit/wait/fetch tú mismo. Es la forma de una sola llamada del flujo txt2img más común. Para añadir detalle de caras encadénala con comfyui_build_facedetailer_workflow, o para nitidez en alta con comfyui_build_hires_fix_workflow (esos son builders; este pipeline ejecuta el camino básico end-to-end).

Gotchas

  • Impuro: requiere el servidor ComfyUI vivo en server (default 127.0.0.1:8188). Si está caído, falla en el paso submit con el error de conexión.
  • ckpt debe existir en el servidor (CheckpointLoaderSimple). Default dreamshaper_8.safetensors; cámbialo si usas SDXL u otro.
  • dest es un directorio (se crea si no existe), no un nombre de archivo: el PNG conserva el nombre que le da ComfyUI (<filename_prefix>_NNNNN_.png).
  • wait_timeout por defecto 300 s. Subir resolución/steps puede requerir más; si el server está cargando el modelo por primera vez, la primera generación tarda más.
  • Devuelve el primer PNG de los outputs. Para batches de varias imágenes usa comfyui_batch_generate o itera con distintos seed.
  • No reintenta: si el server está ocupado con otra cola, encola igualmente y espera su turno hasta wait_timeout.

Capability growth log

  • v1.0.0 (2026-06-24) — pipeline inicial. Compone build_txt2img + submit + wait + fetch_output_image (issue 0087, roadmap del report 0092).