วิธีการใช้ ComfyUI: คู่มือเชิงปฏิบัติทีละขั้นตอนสำหรับผู้เริ่มต้น
หากคุณเคยได้ยินว่า ComfyUI เป็น "แบบ Node และทรงพลังอย่างมาก" แต่รู้สึกกลัวกับกล่องและสายไฟทั้งหมด ไม่ใช่คุณคนเดียว ข่าวดีคือ เมื่อคุณเรียนรู้แนวคิดหลักสองสามอย่าง เช่น จุดตรวจสอบ (checkpoints), ตัวเข้ารหัส (encoders), ตัวอย่าง (samplers) และตัวถอดรหัส (decoders) คุณจะสามารถสร้างเวิร์กโฟลว์รูปภาพได้อย่างมืออาชีพ คู่มือเชิงปฏิบัตินี้จะแนะนำคุณเกี่ยวกับวิธีการใช้ ComfyUI ตั้งแต่การติดตั้งไปจนถึงภาพ SDXL แรกของคุณ รวมถึงเวิร์กโฟลว์สำหรับ ControlNet, LoRA และการปรับแต่งคุณภาพ/ประสิทธิภาพ
เมื่อถึงตอนท้าย คุณจะรู้วิธีใช้ ComfyUI อย่างแม่นยำเพื่อสร้างภาพที่สอดคล้อง ทำซ้ำได้ และมีความยืดหยุ่น โดยไม่ต้องคาดเดา
ComfyUI คืออะไรและทำไมต้องใช้
ComfyUI คืออินเทอร์เฟซแบบเห็นภาพที่ใช้ Node สำหรับ Stable Diffusion ซึ่งช่วยให้คุณออกแบบไปป์ไลน์รูปภาพของคุณทีละขั้นตอน แทนที่จะมีปุ่ม "สร้าง" เพียงปุ่มเดียว คุณจะเชื่อมต่อ Node ซึ่งแต่ละ Node จะจัดการงานที่แตกต่างกัน เช่น การโหลดโมเดล การเข้ารหัสข้อความ การสุ่มตัวอย่าง Latent หรือการถอดรหัสรูปภาพสุดท้าย มันรวดเร็ว เป็นโมดูล และโปร่งใส เหมาะสำหรับการเรียนรู้ การทดลอง และเวิร์กโฟลว์การผลิต
เริ่มต้นอย่างรวดเร็ว: ติดตั้งและเปิด ComfyUI
- Windows/macOS/Linux: ทำตาม repository อย่างเป็นทางการและคู่มือการติดตั้งของชุมชน คุณสามารถใช้การติดตั้งด้วยตนเอง (Python + dependencies) หรือวิธีการแบบแพ็กเกจ ขึ้นอยู่กับแพลตฟอร์มและ GPU ของคุณ Wiki ของ ComfyUI มีการตั้งค่าทีละขั้นตอนสำหรับ Windows, macOS (รวมถึง Apple Silicon) และ Linux
- Models: วางจุดตรวจสอบ Stable Diffusion ของคุณ (เช่น SDXL base/refiner หรือ SD 1.5) ในโฟลเดอร์
models/checkpoints วางไฟล์ VAE ใน models/vae, LoRA ใน models/loras, โมเดล ControlNet ใน models/controlnet
- Launch: เรียกใช้สคริปต์เริ่มต้นสำหรับ OS ของคุณ ComfyUI จะเปิดขึ้นในเบราว์เซอร์ของคุณ Canvas เป็นที่ที่คุณจะเชื่อมต่อ Nodes เข้าด้วยกัน
คำแนะนำ: อัปเดตไดรเวอร์ GPU และ CUDA toolkit ของคุณให้เป็นปัจจุบันเสมอเพื่อประสิทธิภาพที่ดีที่สุด
แนวคิดหลัก: เวิร์กโฟลว์ Text-to-Image ขั้นต่ำ
โฟลว์ text-to-image พื้นฐานของ ComfyUI (สไตล์ SD 1.5) มีลักษณะดังนี้:
- Output: องค์ประกอบ UNet, CLIP และ VAE
- Node: CLIP Text Encode (Positive)
- Node: CLIP Text Encode (Negative)
- Output: Conditioning Embeddings สำหรับ Guidance
- Inputs: UNet, Positive/Negative Conditioning, Seed, Steps, Sampler (เช่น DPM++ 2M Karras) และ CFG Scale
กราฟพื้นฐานนี้—Checkpoint → CLIP (pos/neg) → KSampler → VAE Decode → Save—เป็นรากฐานสำหรับเกือบทุกสิ่งที่คุณจะทำใน ComfyUI
เวิร์กโฟลว์ SDXL: Base + (Optional) Refiner
SDXL ใช้ตัวเข้ารหัสข้อความคู่และมักจะได้รับประโยชน์จากการ Refiner Pass
- โหลด SDXL Base: ใช้ Checkpoint ที่เข้ากันได้กับ SDXL เทมเพลต SDXL จำนวนมากมีตัวเข้ารหัส CLIP สองตัว (สำหรับ Large/Small Context) ป้อนทั้ง Positive และ Negative Prompts
- KSampler (Base): สร้าง Latents ที่ 1024×1024 (หรือเป้าหมายของคุณ) บันทึก Latents หรือ Decoded Images
- Optional Refiner: โหลด Checkpoint SDXL Refiner และเรียกใช้ KSampler Pass เพิ่มเติมโดยมีเงื่อนไขตาม Base Output จากนั้นถอดรหัสด้วย VAE
กระบวนการสองขั้นตอนนี้สามารถปรับปรุงรายละเอียดและความสอดคล้องได้อย่างมากที่ความละเอียดสูงขึ้น
ลงมือปฏิบัติ: สร้างกราฟ ComfyUI แรกของคุณ
- เริ่มต้นจากเทมเพลต: ในแถบด้านข้าง โหลดตัวอย่าง Text-to-Image ในตัว
- แทนที่ Checkpoint: เลือกโมเดล SDXL หรือ SD 1.5 ของคุณ
- เขียน Prompt ของคุณ: ใช้ Nodes Positive และ Negative CLIP ตัวอย่าง:
- Positive: “ภาพบุคคลแบบภาพยนตร์ แสงสตูดิโอที่นุ่มนวล เลนส์ 85 มม. รายละเอียดสูง เกรนฟิล์ม”
- Negative: “เบลอ ความละเอียดต่ำ ผิดรูป นิ้วพิเศษ ลายน้ำ”
- Steps: 20–35 เพื่อความสมดุลของความเร็ว/คุณภาพ
- Sampler: DPM++ 2M Karras (เชื่อถือได้) หรือ Euler a (รวดเร็ว)
- CFG: 4.5–7.5 (สูงกว่าจะผลักดัน Prompt ให้แรงขึ้น แต่สามารถทำให้สีอิ่มตัวมากเกินไปได้)
- Seed: แก้ไขเพื่อความสามารถในการทำซ้ำ เปลี่ยนแปลงเพื่อการสำรวจ
- Resolution: สำหรับ SD 1.5 ให้เริ่มต้นที่ 512×512 หรือ 768×768 สำหรับ SDXL 1024×1024 ทำงานได้ดี
- Decode and Save: เพิ่ม VAE Decode → Save Image คลิก Queue Prompt เพื่อสร้าง
ทำความเข้าใจกับ Key Nodes (ในภาษาที่เข้าใจง่าย)
- Checkpoint Loader: โหลด Diffusion Model (UNet), Text Encoder(s) (CLIP) และ VAE ของคุณ คิดว่ามันเป็น "Engine + Language Brain + Image Translator"
- CLIP Text Encode: แปลง Prompt ของคุณเป็น Numerical Embeddings ที่โมเดลเข้าใจ ใช้ทั้ง Positive และ Negative Text Encoders
- KSampler: หัวใจของการสังเคราะห์ภาพ มัน Denoises Latent Noise ที่ Guided โดย Prompt และ Sampler Method ของคุณในหลายขั้นตอน
- VAE Decode: แปลง Final Latents เป็น Viewable Image การสลับ VAEs จะเปลี่ยนความเที่ยงตรงของสี/คอนทราสต์
- Save Image: เขียน Output ลงดิสก์พร้อม Metadata เพื่อให้คุณสามารถสร้างผลลัพธ์ใหม่ได้ในภายหลัง
สำหรับข้อมูลเชิงลึกเพิ่มเติมเกี่ยวกับ Building Blocks เหล่านี้ โปรดดู Beginner-Friendly Breakdowns และ Node Explainers
Power‑Ups: LoRA, ControlNet และ Image‑to‑Image
ใช้ LoRA สำหรับ Style หรือ Subject Control
- เพิ่ม Node LoRA Loader และเชื่อมต่อกับ Model Branch ของคุณ
- Strength: เริ่มต้นที่ประมาณ 0.6–0.8 ปรับตามความเข้มของ Style หรือ Overfitting
- Multiple LoRAs: Chain หรือ Merge แต่ระวัง Conflicts ลด Strength ลงเมื่อ Stacking
เพิ่ม ControlNet สำหรับ Precise Composition
- ControlNet Nodes ช่วยให้คุณ Steering Composition โดยใช้ Input Map (Canny, Depth, OpenPose ฯลฯ)
- Typical Flow: โหลด Model ControlNet → Preprocess Guide Image ของคุณ (เช่น Canny Edge) → ป้อน ControlNet Conditioning ลงใน KSampler พร้อมกับ Text Conditioning ของคุณ
- Weight: 0.5–1.2 เป็นจุดเริ่มต้นที่ดี สูงเกินไปอาจ Overpower Prompt ของคุณ
Image‑to‑Image หรือ Inpainting
- แทนที่ Initial Noise ด้วย Image Latent ผ่าน VAE Encode
- ปรับ Denoise Strength ใน KSampler เพื่อควบคุมปริมาณของ Original Image ที่ยังคงอยู่
- สำหรับการ Inpainting ให้ใช้ Mask Input และ Inpaint‑Aware Sampler Pipeline
Quality Tuning: Prompts, CFG, Samplers และ Seeds
- Prompt Engineering: ใช้ Concise Descriptors ไม่ใช่ Paragraphs Order มีความสำคัญน้อยกว่า Clarity แต่ให้ Critical Attributes อยู่ด้านหน้า
- Low (3–5): มีความคิดสร้างสรรค์มากขึ้น การยึด Prompt น้อยลง
- High (9–12): การยึดมั่นที่แข็งแกร่ง สามารถสร้าง Artifacts ได้
- DPM++ 2M Karras: สะอาด เชื่อถือได้
- Euler a: รวดเร็วและสื่อความหมาย เหมาะสำหรับการ Preview
- UniPC / Heun / DDIM: คุ้มค่าที่จะทดสอบ ผลลัพธ์แตกต่างกันไปตาม Model
- Fixed Seed = Reproducible Results
- Vary Seed = Explore Diversity
Performance Tips สำหรับ Smooth Renders
- VRAM Budgeting: ลด Resolution, Steps หรือ Batch Size หากคุณ Hit OOM SDXL ที่ 1024×1024 สามารถต้องการ 8–12 GB VRAM ขึ้นอยู่กับ Nodes
- Half Precision: เปิดใช้งาน fp16 ในที่ที่รองรับเพื่อประหยัด Memory ได้มากโดยมีการสูญเสียคุณภาพเล็กน้อย
- Tiling and Latent Upscalers: สร้างให้เล็กลง จากนั้น Upscale ผ่าน Latent Upscaler Node หรือ Image Upscaler Model เพื่อประหยัด VRAM
- Caching: นำ CLIP Encodings และ Decoded VAEs กลับมาใช้ใหม่ในการ Runs เมื่อ Prompts ไม่เปลี่ยนแปลง
- หลีกเลี่ยง Unnecessary Branches: Extra Disconnected Nodes ยังคง Consume Memory เมื่อ Execute ใน Queue เดียวกัน
Organizing Workflows Like a Pro
- Group Nodes: ใช้ Frames/Labels เพื่อจัดระเบียบ Sections (Prompt, Model, Sampler, Output ฯลฯ)
- Parameter Panels: สร้าง “Control” Nodes (เช่น Empty Prompt Boxes, Sliders) ที่ด้านบนเพื่อให้ง่ายต่อการ Tuning
- Save/Share: Export Workflow JSON ของคุณและเก็บ Note
Models Used ไว้เพื่อ Reproducibility
- Versioning: เก็บ Graphs แยกต่างหากสำหรับ SD 1.5, SDXL และ Specialty Pipelines (Anime, Photoreal, Depth-to-Image ฯลฯ)
Troubleshooting Common Issues
- Wrong VAE หรือ Missing VAE Decode
- Denoise ต่ำเกินไป (เช่น <0.2 ใน img2img)
- ลอง VAE อื่น VAEs บางตัวปรับปรุง Contrast อย่างเห็นได้ชัด
- Lower CFG หรือ Change Sampler
- Nothing Changes Across Runs:
- Seed Is Fixed เปิดใช้งาน Randomize หรือตั้งค่า Seed ใหม่
- Reduce Resolution, Steps หรือ Batch Size สลับไปที่ fp16
- Close Other GPU Apps ลดความซับซ้อนของ ControlNet/LoRA Stacks
- Model Not Found / Red Node:
- Verify File Paths และ Model Folders ยืนยัน File Extensions
Learn Faster With Pre‑Built Workflows
Video Walkthroughs และ Beginner Series สามารถ Accelerate Learning Curve ของคุณด้วย Ready-to-Run Graphs ที่คุณสามารถ Pause และ Dissect ได้ Written Tutorials และ Wikis ให้ Node Explanations และ Updated Installation Steps เพื่อให้คุณทันสมัย
Advanced: Modularizing and Extending Your Graphs
- API/External Nodes: Tutorials บางส่วนครอบคลุมการ Connecting ComfyUI ไปยัง External AI Services ผ่าน Special Nodes ทำให้ Hybrid Pipelines และ Offloading Heavy Tasks เป็นไปได้
- Node Libraries and Extensions: สำรวจ Community Nodes สำหรับ Schedulers, Upscalers และ Preprocessing (Pose, Depth, Segmentation) ตรวจสอบ Compatibility กับ ComfyUI Version ของคุณเสมอ
- SDXL Refiners and Chained Samplers: เรียกใช้ Staged Denoising (Base → Refiner) หรือแม้แต่ Multiple Samplers สำหรับ Stylistic Blending
Worth Noting: Speeding Up Prompting With Sider.AI
หากคุณ Frequently Iterate บน Prompts, References หรือ Descriptions คุณอาจต้องการ Sidekick เพื่อ Brainstorm และ Refine Variations By the way, Sider.AI สามารถช่วยคุณ Draft Structured Prompts, Generate Negative Prompt Lists และ Summarize Workflow Experiments ของคุณได้อย่างรวดเร็ว เพื่อให้คุณไม่ Lose Track ระหว่าง Runs คุณสามารถลองได้ที่นี่: A Simple SDXL Starter Workflow (Copy This Pattern)
- Checkpoint Loader (SDXL Base)
- CLIP Text Encode (Positive) — “Ultra-Detailed Product Photo, Softbox Lighting, 50mm Lens, Reflective Surface”
- CLIP Text Encode (Negative) — “Low-Res, Motion Blur, Watermark, Background Clutter”
- KSampler: 1024×1024, 28 Steps, DPM++ 2M Karras, CFG 5.5, Fixed Seed
Optional Add-Ons:
- Refiner Pass With SDXL Refiner Checkpoint ที่ 10–15 Steps
- ControlNet (Depth) With a Simple Object Silhouette สำหรับ Layout
- LoRA ที่ 0.6 สำหรับ Specific Brand หรือ Art Style
Key Takeaways
- Power ของ ComfyUI มาจาก Transparency สร้าง Pipeline ของคุณ Node By Node
- Core Text‑to‑Image Chain นั้น Simple: Checkpoint → CLIP (pos/neg) → KSampler → VAE Decode → Save
- SDXL Benefits จาก Dual Encoders และ Optional Refiner Pass สำหรับ Detail
- LoRAs และ ControlNet ให้ Style Control และ Composition Precision แก่คุณ
- Tune CFG, Sampler และ Seed เพื่อ Quality และ Consistency จัดการ VRAM ด้วย fp16 และ Sensible Resolutions
- Organize Workflows และ Version พวกมันเพื่อ Painless Iteration
Next Steps
- Install ComfyUI โดยทำตาม Repo/Wiki Instructions และ Launch Sample Workflow
- Rebuild Minimal Chain จาก Scratch เพื่อ Cement Basics
- Add ControlNet และ LoRA จากนั้น A/B Test Sampler และ CFG Settings
- Save และ Share Workflow JSON ของคุณพร้อม Notes เกี่ยวกับ Models, Seeds และ Parameters
Happy Generating—และ Welcome สู่ Calm, Controllable World ของ ComfyUI
FAQ
Q1:How do I install and run ComfyUI on Windows, macOS, or Linux?
Follow the official repo and the community wiki for platform-specific steps, model folder locations, and dependencies. After installation, launch the local server and open ComfyUI in your browser to start wiring nodes.,.
Q2:What’s the simplest ComfyUI workflow for text-to-image?
Load a checkpoint, encode positive and negative prompts with CLIP, run a KSampler, decode with VAE, then save the image. This chain is the foundation for how to use ComfyUI effectively for most generations.,.
Q3:How do I use SDXL in ComfyUI?
Use an SDXL checkpoint with dual text encoders, then optionally add a refiner pass for better detail. Run at 1024×1024 with balanced CFG (around 5–7) and an efficient sampler like DPM++ 2M Karras..
Q4:Can I add ControlNet and LoRA in the same ComfyUI workflow?
Yes. Load your LoRA and ControlNet nodes, connect them to the model and KSampler conditionings, and tune weights (e.g., 0.6–0.8 for LoRA, ~0.5–1.2 for ControlNet). Watch VRAM usage and reduce resolution or steps if you hit OOM.
Q5:Why are my ComfyUI images low‑contrast or washed out?
Try a different VAE, lower CFG, or switch samplers. Some VAEs produce more faithful color and contrast; small adjustments can fix washed-out results quickly.