Local ComfyUI Image Generation (Chinese Prompts)
Skill File Index (Read This First to Decide Which Sections to Read)
| File | When to Read |
|---|---|
SKILL.md | This file: prerequisites / local-first / cloud startup/shutdown / three calling methods / parameters / long-term conventions / waiting for results |
image_gen.py | Implementation of generate_image(); call according to SKILL.md, read the corresponding function only when modifying behaviour |
feed_screen.py | Video information feed (UI template): spec → six-section skeleton prompt → submit |
references/01-Environment&Routing.md | Check prerequisites, local-first routing, automatic cloud startup/shutdown before starting work |
references/02-Calling&Parameters.md | How to call generate_image, parameter defaults, output location |
references/03-OutfitValidationDetails.md | When character images are blocked by ValueError, check validation keywords and release conditions |
references/04-BatchResultDetails.md | When generating multiple images at once, check two waiting methods and the "screen not moving ≠ stuck" criterion |
references/05-LongTermConventions.md | Check red-line criteria before writing prompts, before passing reference images, or when encountering outfit validation or <imageN> errors |
references/06-VideoInformationFeed.md | When creating video information feed UI templates (play page / live page / note detail / product detail, including status bar / navigation bar / interaction counts / bottom navigation), check segment order, UI five-zone structure, size table, and acceptance items |
Submit "Chinese prompts" to the locally deployed ComfyUI (Qwen2.1 image processing workflow), generate PNG, and return a local path.
The core logic is in image_gen.py: generate_image only does parameter mapping; the actual "placeholder workflow submission → polling → HTTP download" is handled by the shared client fxai-workflow/comfy_client.py (shared with fxai-scene-gen / fxai-fourview-gen / fxai-mv-pipeline). All use the placeholder pattern (fxai_xxx placeholders injected by comfy_client).
🚨 Pre-Work Checklist (Read Before Starting)
- 🔴 First step: read
fxai-workflow/SKILL.mdsection "🚨 ComfyUI Server Mode Irreducible Rules" — the irreducible rules are in the dependency's SKILL.md, not incomfy_client.py(reading only the function will miss them). Core: ComfyUI is started/stopped by "Fengxi Local AI Console"/launcher; this skill only sends HTTP by address; if port 8188 is unreachable → use cloud or prompt user to start; resource availability is determined solely by the server API.
🔴 Font Licensing Gate (Read Before Rendering Text)
🔴 If any text appears in the output (covers/illustrations), you must first read fxai-standard/references/06-Font&AssetLicensing.md before rendering: fonts must be chosen only from the white list in section 06 (prefer Noto Sans SC / OFL on local; Microsoft YaHei bundled with Windows is also allowed). Commercial font libraries such as Huawen are prohibited. Record the font name and license when delivering.
Prerequisites
The remaining four prerequisites are in references/01-Environment&Routing.md.
🔴 Local First, Then Xiān Gōng Yún (Cloud)
Routing details and cloud startup/shutdown are in references/01-Environment&Routing.md.
Xiān Gōng Yún: Auto-Boot + Auto-Shutdown After Work
Three Calling Methods
Method A: Direct Import (Preferred for In-Conversation Scripts)
See reference 02.
Method B: CLI (Run Directly in Bash; Must Allow Sandbox Network to Reach ComfyUI)
See reference 02.
Method C: Video Information Feed (UI Template)
python feed_screen.py <spec.json> --tag <project>_<interface> --save-dir <project_directory>
python feed_screen.py <spec.json> --print-only # only view the composed prompt
Segment order, UI five-zone structure, size table, and acceptance items: see references/06-VideoInformationFeed.md.
Parameters (generate_image)
Long-Term Conventions (Must Follow; Details in references/05-LongTermConventions.md)
- 🔴 Reference images: Characters must always use the own role images 000/001 (
role=woman/man/bothor a custom relative path); covers / posters must use that work's own character image, not the global avatar libraryavatar/000, 001. - 🔴 Prompts: Chinese directly to image, no English needed; if a person appears in the scene, you must write [outfit/clothing] + [head shape/hairstyle];
check_outfit()enforces a hard validation. - 🔴 Multiple reference images: For N images, you must write
<imageN>for each; missing one triggersValueError(check_image_refs()); numbering = order of reference images, male character first. - Attire red line: Chest / private areas must remain covered; aim for "sheer but not exposed."
- Output validation: After HTTP download,
png_okchecks for the IEND chunk; if incomplete, retry. This skill only generates images; publishing is handled byfxai-weixin-gzh-publisher.
Output Directory
Output location: see references/02-Calling&Parameters.md.
Waiting for Results: Global Broadcast Listener (Built-in)
generate_image internally calls comfy_client.submit_workflow. After submission, it waits via broadcast listener:
After queued <pid> in the log, real-time progress updates appear line by line; once complete, it automatically fetches the URL and downloads the image, returning a local path —
Use this broadcast link to wait for results (calling sleep + polling /history or /fxai/tasks/result will yield duplicate states).
While waiting for GPU in the queue, the listener checks /queue to confirm "still in queue" and continues waiting. Manual check:
comfy_watch.py status <pid_prefix> / comfy_watch.py top (skill fxai-comfyui-watcher).
🔴 How to Wait for Batch Generation
Once you receive "still running / will be notified automatically," stop querying immediately; use block=true only when remaining time ≤ 60 seconds. Three task_id states and the "screen not moving ≠ stuck" criterion: see references/04-BatchResultDetails.md.
Validation
After modifying image_gen.py, run: python image_gen.py "test, pure scene landscape" --role "" --tag smoke_test,
Confirm it returns a valid PNG path and the file is intact (>100 bytes, contains IEND).
Once you have determined what to do, read only the corresponding one or two reference files; skip the rest.
Project List (Page Shows Progress Accordingly)
Create the output directory and record the project; update after each completed segment; structure: see fxai-standard reference 01.
P=~/.workbuddy/skills/fxai-standard/scripts/fxai_project.py
python "$P" init "<project>" --title <name> --category image --skill fxai-comfyui-image-gen
python "$P" stage "<project>" --script 2 --image 1 --audio 0 --video 0