SiamCafe.net Blog
Technology

stable diffusion 3 demo

stable diffusion 3 demo
stable diffusion 3 demo | SiamCafe Blog
2025-09-02· อ. บอม — SiamCafe.net· 9,605 คำ

Stable Diffusion 3

Stable Diffusion 3 AI Text-to-Image MMDiT CLIP T5 Text Rendering Prompt Engineering ComfyUI Diffusers API Local GPU

ModelParamsVRAMQualitySpeed
SD3 Medium2B8GB+ (FP16)สูงเร็ว (5-10s)
SD3 Large8B16GB+ (FP16)สูงมากปานกลาง (15-30s)
SDXL 1.06.6B8GB+สูงปานกลาง
SD 1.50.9B4GB+ปานกลางเร็วมาก
Midjourney V6UnknownCloud onlyสูงมากเร็ว (Cloud)

วิธีใช้งาน

# === Stable Diffusion 3 Usage Methods ===

# Method 1: Stability AI API
# import requests
# response = requests.post(
#     "https://api.stability.ai/v2beta/stable-image/generate/sd3",
#     headers={"Authorization": f"Bearer {API_KEY}"},
#     files={"none": ""},
#     data={
#         "prompt": "A beautiful sunset over mountains, photorealistic, 8k",
#         "negative_prompt": "blurry, low quality, deformed",
#         "model": "sd3-medium",
#         "output_format": "png",
#         "aspect_ratio": "16:9",
#     }
# )
# with open("output.png", "wb") as f:
#     f.write(response.content)

# Method 2: Hugging Face Diffusers
# pip install diffusers transformers accelerate torch
# from diffusers import StableDiffusion3Pipeline
# import torch
#
# pipe = StableDiffusion3Pipeline.from_pretrained(
#     "stabilityai/stable-diffusion-3-medium-diffusers",
#     torch_dtype=torch.float16
# ).to("cuda")
#
# image = pipe(
#     prompt="A cat wearing a tiny hat, studio photo, soft lighting",
#     negative_prompt="blurry, deformed",
#     num_inference_steps=28,
#     guidance_scale=5.0,
#     width=1024, height=1024,
# ).images[0]
# image.save("cat_hat.png")

from dataclasses import dataclass

@dataclass
class UsageMethod:
    method: str
    setup: str
    difficulty: str
    cost: str
    customization: str

methods = [
    UsageMethod("Stability AI API",
        "สมัคร API Key ที่ platform.stability.ai",
        "ง่ายมาก (HTTP Request)",
        "$0.03-0.09 per image",
        "ต่ำ (API Parameters only)"),
    UsageMethod("Hugging Face Diffusers",
        "pip install diffusers + Download Model",
        "ปานกลาง (Python Code)",
        "ฟรี (ใช้ GPU ตัวเอง)",
        "สูง (Code-level Control)"),
    UsageMethod("ComfyUI",
        "ติดตั้ง ComfyUI + Download SD3 Checkpoint",
        "ปานกลาง (Node-based UI)",
        "ฟรี (Local GPU)",
        "สูงมาก (Node Workflow)"),
    UsageMethod("Automatic1111 WebUI",
        "ติดตั้ง sd-webui + Download Checkpoint",
        "ง่าย (Web Interface)",
        "ฟรี (Local GPU)",
        "สูง (Extensions LoRA ControlNet)"),
]

print("=== Usage Methods ===")
for m in methods:
    print(f"\n  [{m.method}]")
    print(f"    Setup: {m.setup}")
    print(f"    Difficulty: {m.difficulty}")
    print(f"    Cost: {m.cost}")
    print(f"    Custom: {m.customization}")

Prompt Engineering

# === SD3 Prompt Engineering Guide ===

@dataclass
class PromptTemplate:
    category: str
    template: str
    example: str
    cfg_scale: float
    steps: int

templates = [
    PromptTemplate("Photorealistic Portrait",
        "[Subject], [Action], [Setting], photorealistic, "
        "studio lighting, sharp focus, 8k uhd",
        "A young woman reading a book in a cozy cafe, "
        "warm lighting, bokeh background, photorealistic, 8k",
        5.0, 28),
    PromptTemplate("Landscape",
        "[Scene], [Time of day], [Weather], cinematic, "
        "wide angle, dramatic lighting",
        "Mountain lake at golden hour, misty atmosphere, "
        "snow-capped peaks, cinematic wide angle, 8k",
        4.5, 25),
    PromptTemplate("Anime / Illustration",
        "[Character], [Action], [Style], anime style, "
        "detailed, vibrant colors",
        "A warrior princess with flowing red hair, "
        "holding a glowing sword, anime style, detailed",
        5.0, 28),
    PromptTemplate("Text in Image",
        'A [object] with text "[YOUR TEXT]" written on it',
        'A wooden sign with text "Welcome to Thailand" '
        'written on it, forest background, photorealistic',
        5.5, 30),
    PromptTemplate("Product Photography",
        "[Product] on [Surface], studio lighting, "
        "product photography, white background",
        "A luxury watch on a marble surface, "
        "studio lighting, product photography, 8k",
        5.0, 28),
]

print("=== Prompt Templates ===")
for p in templates:
    print(f"\n  [{p.category}]")
    print(f"    Template: {p.template}")
    print(f"    Example: {p.example}")
    print(f"    CFG: {p.cfg_scale} | Steps: {p.steps}")

Installation Guide

# === Local Installation ===

@dataclass
class InstallGuide:
    platform: str
    requirements: str
    install_command: str
    model_download: str
    first_run: str

guides = [
    InstallGuide("Diffusers (Python)",
        "Python 3.10+, NVIDIA GPU 8GB+, CUDA 11.8+",
        "pip install diffusers transformers accelerate torch",
        "Auto-download from HuggingFace (requires login)",
        "python generate.py --prompt 'your prompt'"),
    InstallGuide("ComfyUI",
        "Python 3.10+, NVIDIA GPU 8GB+, Git",
        "git clone https://github.com/comfyanonymous/ComfyUI\n"
        "pip install -r requirements.txt",
        "Download SD3 .safetensors → models/checkpoints/",
        "python main.py → Open http://127.0.0.1:8188"),
    InstallGuide("Automatic1111 WebUI",
        "Python 3.10+, NVIDIA GPU 8GB+, Git",
        "git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui\n"
        "webui-user.bat (Windows) / webui.sh (Linux)",
        "Download SD3 .safetensors → models/Stable-diffusion/",
        "เปิด Browser http://127.0.0.1:7860"),
]

print("=== Installation Guides ===")
for g in guides:
    print(f"\n  [{g.platform}]")
    print(f"    Requirements: {g.requirements}")
    print(f"    Install: {g.install_command}")
    print(f"    Model: {g.model_download}")
    print(f"    First Run: {g.first_run}")

เคล็ดลับ

การประยุกต์ใช้ AI ในงานจริง ปี 2026

เทคโนโลยี AI ในปี 2026 ก้าวหน้าไปมากจนสามารถนำไปใช้งานจริงได้หลากหลาย ตั้งแต่ Customer Service ด้วย AI Chatbot ที่เข้าใจบริบทและตอบคำถามได้แม่นยำ Content Generation ที่ช่วยสร้างบทความ รูปภาพ และวิดีโอ ไปจนถึง Predictive Analytics ที่วิเคราะห์ข้อมูลทำนายแนวโน้มธุรกิจ

สำหรับนักพัฒนา การเรียนรู้ AI Framework เป็นสิ่งจำเป็น TensorFlow และ PyTorch ยังคงเป็นตัวเลือกหลัก Hugging Face ทำให้การใช้ Pre-trained Model ง่ายขึ้น LangChain ช่วยสร้าง AI Application ที่ซับซ้อน และ OpenAI API ให้เข้าถึงโมเดลระดับ GPT-4 ได้สะดวก

ข้อควรระวังในการใช้ AI คือ ต้องตรวจสอบผลลัพธ์เสมอเพราะ AI อาจให้ข้อมูลผิดได้ เรื่อง Data Privacy ต้องระวังไม่ส่งข้อมูลลับไปยัง AI Service ภายนอก และเรื่อง Bias ใน AI Model ที่อาจเกิดจากข้อมูลฝึกสอนที่ไม่สมดุล องค์กรควรมี AI Governance Policy กำกับดูแลการใช้งาน

Stable Diffusion 3 คืออะไร

AI Text-to-Image Stability AI MMDiT CLIP T5 Text Rendering 2B 8B params Open Weight Local GPU API ComfyUI Diffusers

ใช้งานอย่างไร

API Stability AI Diffusers Python ComfyUI Node WebUI Automatic1111 GPU 8GB+ VRAM FP16 Checkpoint Download HuggingFace

Prompt Engineering อย่างไร

ภาษาธรรมชาติ Subject Action Setting Lighting Style Quality Negative Prompt CFG 3-7 Steps 20-30 Text ในเครื่องหมายคำพูด

เปรียบเทียบกับรุ่นก่อนอย่างไร

SD3 ดีกว่า SD 1.5 SDXL Text Rendering Prompt Following เทียบ Midjourney V6 DALL-E 3 SD3 Open Weight ฟรี Local Customizable

สรุป

Stable Diffusion 3 MMDiT Text Rendering Prompt Engineering ComfyUI Diffusers API CFG 3-7 GPU 8GB+ FP16 Open Weight AI Image

📖 บทความที่เกี่ยวข้อง

Stable Diffusion ComfyUI Troubleshooting แก้ปัญหาอ่านบทความ → Stable Diffusion ComfyUI Compliance Automationอ่านบทความ → stable diffusion installอ่านบทความ → Stable Diffusion ComfyUI Message Queue Designอ่านบทความ → Stable Diffusion ComfyUI Multi-cloud Strategyอ่านบทความ →

📚 ดูบทความทั้งหมด →