SiamCafe.net Blog
Technology

stable diffusion model download

stable diffusion model download
stable diffusion model download | SiamCafe Blog
2026-04-12· อ. บอม — SiamCafe.net· 1,839 คำ

Stable Diffusion Model Download — คู่มือดาวน์โหลดโมเดล AI สร้างภาพ

Stable Diffusion Models คือไฟล์ weights ที่กำหนดว่า AI จะสร้างภาพแบบไหน การเลือกและดาวน์โหลด model ที่เหมาะสมเป็นขั้นตอนสำคัญที่สุดในการสร้างภาพคุณภาพสูง แหล่งดาวน์โหลดหลักได้แก่ CivitAI, HuggingFace และ GitHub โดยมี models หลายพันตัวให้เลือก ตั้งแต่ realistic photography ไปจนถึง anime และ fantasy art บทความนี้รวบรวมแหล่งดาวน์โหลด วิธีเลือก model และ Python tools สำหรับจัดการ models

แหล่งดาวน์โหลด Model

# download_sources.py — Model download sources
import json

class DownloadSources:
    SOURCES = {
        "civitai": {
            "name": "CivitAI (civitai.com)",
            "description": "แหล่งใหญ่ที่สุด — models, LoRA, embeddings, VAE หลายหมื่นตัว",
            "types": "Checkpoints, LoRA, Textual Inversion, VAE, ControlNet",
            "pros": "Filter ตาม style/base model/rating, sample images, community reviews",
            "cons": "บางไฟล์ต้อง login, NSFW content มีเยอะ",
            "format": ".safetensors (แนะนำ), .ckpt",
        },
        "huggingface": {
            "name": "HuggingFace (huggingface.co)",
            "description": "Official models + community models — ใช้กับ Diffusers library",
            "types": "Official SD models, fine-tuned models, LoRA",
            "pros": "Official releases, Diffusers format, API download",
            "cons": "ค้นหายากกว่า CivitAI, ไม่มี preview gallery",
            "format": "Diffusers format (folder), .safetensors",
        },
        "github": {
            "name": "GitHub Releases",
            "description": "บาง models host บน GitHub — official + community",
            "types": "Checkpoints, ControlNet weights",
            "pros": "Version control, release notes",
            "cons": "Bandwidth จำกัด, ค้นหายาก",
            "format": ".safetensors, .pth",
        },
    }

    TRUSTED_CREATORS = {
        "stabilityai": "Stability AI — Official SD 1.5, SDXL, SD 3.0",
        "runwayml": "RunwayML — Original SD 1.5 release",
        "thebloke": "TheBloke — GGUF/GPTQ quantizations (LLMs)",
        "lykon": "Lykon — DreamShaper, Absolute Reality",
        "sai": "SAI (Stability AI) — Official SDXL models",
    }

    def show_sources(self):
        print("=== Download Sources ===\n")
        for key, src in self.SOURCES.items():
            print(f"[{src['name']}]")
            print(f"  {src['description']}")
            print(f"  Types: {src['types']}")
            print(f"  Format: {src['format']}")
            print()

    def show_creators(self):
        print("=== Trusted Creators ===")
        for creator, desc in self.TRUSTED_CREATORS.items():
            print(f"  [{creator}] {desc}")

sources = DownloadSources()
sources.show_sources()
sources.show_creators()

Popular Models สำหรับดาวน์โหลด

# popular_models.py — Popular models to download
import json

class PopularModels:
    REALISTIC = {
        "realistic_vision": {
            "name": "Realistic Vision V6.0",
            "base": "SD 1.5", "size": "~2 GB (pruned)",
            "style": "Photorealistic — ภาพเหมือนจริงมาก",
            "download": "CivitAI model ID: 4201",
        },
        "juggernaut_xl": {
            "name": "Juggernaut XL V9",
            "base": "SDXL 1.0", "size": "~6.5 GB",
            "style": "Photorealistic — คุณภาพสูงสุดสำหรับ SDXL",
            "download": "CivitAI model ID: 133005",
        },
        "dreamshaper": {
            "name": "DreamShaper V8",
            "base": "SD 1.5", "size": "~2 GB (pruned)",
            "style": "Versatile — realistic + fantasy + digital art",
            "download": "CivitAI model ID: 4384",
        },
    }

    ANIME = {
        "anything_v5": {
            "name": "Anything V5",
            "base": "SD 1.5", "size": "~2 GB",
            "style": "Anime/Manga — คุณภาพสูง",
            "download": "CivitAI model ID: 9409",
        },
        "animagine_xl": {
            "name": "Animagine XL V3.1",
            "base": "SDXL 1.0", "size": "~6.5 GB",
            "style": "Anime — best anime model สำหรับ SDXL",
            "download": "CivitAI / HuggingFace: cagliostrolab/animagine-xl-3.1",
        },
    }

    ESSENTIAL_EXTRAS = {
        "vae": {
            "name": "VAE (Variational Auto-Encoder)",
            "description": "ปรับปรุงสี ลด washed out colors",
            "recommended": "vae-ft-mse-840000-ema-pruned.safetensors",
        },
        "controlnet": {
            "name": "ControlNet Models",
            "description": "ควบคุม pose, depth, edges, composition",
            "recommended": "control_v11p_sd15_openpose, control_v11f1p_sd15_depth",
        },
        "upscaler": {
            "name": "Upscaler Models",
            "description": "เพิ่ม resolution ภาพ 2x-4x",
            "recommended": "4x-UltraSharp, RealESRGAN_x4plus",
        },
    }

    def show_realistic(self):
        print("=== Realistic Models ===\n")
        for key, m in self.REALISTIC.items():
            print(f"[{m['name']}] ({m['base']}, {m['size']})")
            print(f"  Style: {m['style']}")
            print()

    def show_anime(self):
        print("=== Anime Models ===")
        for key, m in self.ANIME.items():
            print(f"[{m['name']}] ({m['base']}, {m['size']})")
            print(f"  Style: {m['style']}")
            print()

    def show_extras(self):
        print("=== Essential Extras ===")
        for key, extra in self.ESSENTIAL_EXTRAS.items():
            print(f"\n[{extra['name']}]")
            print(f"  {extra['description']}")
            print(f"  Recommended: {extra['recommended']}")

models = PopularModels()
models.show_realistic()
models.show_anime()
models.show_extras()

Python Download Manager

# downloader.py — Python model download manager
import json

class ModelDownloader:
    CODE = """
# sd_downloader.py — Download and manage SD models
import requests
import os
import json
import hashlib
from pathlib import Path
from tqdm import tqdm

class SDModelDownloader:
    def __init__(self, models_dir="./models"):
        self.models_dir = Path(models_dir)
        self.dirs = {
            'checkpoints': self.models_dir / 'Stable-diffusion',
            'lora': self.models_dir / 'Lora',
            'vae': self.models_dir / 'VAE',
            'controlnet': self.models_dir / 'ControlNet',
            'upscaler': self.models_dir / 'ESRGAN',
            'embeddings': self.models_dir / 'embeddings',
        }
        for d in self.dirs.values():
            d.mkdir(parents=True, exist_ok=True)
    
    def download_file(self, url, output_path, chunk_size=8192):
        '''Download file with progress bar'''
        resp = requests.get(url, stream=True)
        total = int(resp.headers.get('content-length', 0))
        
        with open(output_path, 'wb') as f:
            with tqdm(total=total, unit='B', unit_scale=True) as pbar:
                for chunk in resp.iter_content(chunk_size=chunk_size):
                    f.write(chunk)
                    pbar.update(len(chunk))
        
        return output_path
    
    def download_from_civitai(self, model_id, model_type='checkpoints'):
        '''Download model from CivitAI'''
        api_url = f"https://civitai.com/api/v1/models/{model_id}"
        resp = requests.get(api_url)
        model = resp.json()
        
        version = model['modelVersions'][0]
        file_info = version['files'][0]
        
        download_url = file_info['downloadUrl']
        filename = file_info['name']
        output_path = self.dirs[model_type] / filename
        
        if output_path.exists():
            print(f"Already exists: {filename}")
            return str(output_path)
        
        print(f"Downloading: {filename} ({file_info['sizeKB']/1024:.1f} MB)")
        self.download_file(download_url, output_path)
        
        return str(output_path)
    
    def download_from_huggingface(self, repo_id, filename, model_type='checkpoints'):
        '''Download from HuggingFace'''
        url = f"https://huggingface.co/{repo_id}/resolve/main/{filename}"
        output_path = self.dirs[model_type] / filename
        
        if output_path.exists():
            print(f"Already exists: {filename}")
            return str(output_path)
        
        print(f"Downloading: {filename}")
        self.download_file(url, output_path)
        
        return str(output_path)
    
    def verify_hash(self, filepath, expected_hash):
        '''Verify file hash'''
        sha256 = hashlib.sha256()
        with open(filepath, 'rb') as f:
            while chunk := f.read(8192):
                sha256.update(chunk)
        
        actual = sha256.hexdigest()[:10]
        return actual == expected_hash[:10]
    
    def list_models(self):
        '''List all downloaded models'''
        inventory = {}
        for model_type, directory in self.dirs.items():
            files = []
            for f in directory.glob('*'):
                if f.suffix in ['.safetensors', '.ckpt', '.pt', '.pth']:
                    files.append({
                        'name': f.stem,
                        'size_mb': round(f.stat().st_size / 1e6, 1),
                        'format': f.suffix,
                    })
            inventory[model_type] = files
        return inventory
    
    def starter_pack(self):
        '''Download recommended starter models'''
        print("=== Downloading Starter Pack ===")
        
        downloads = [
            ('Realistic Vision V6', 4201, 'checkpoints'),
            ('DreamShaper V8', 4384, 'checkpoints'),
        ]
        
        for name, model_id, mtype in downloads:
            print(f"\\n--- {name} ---")
            try:
                self.download_from_civitai(model_id, mtype)
            except Exception as e:
                print(f"Error: {e}")

# downloader = SDModelDownloader("./models")
# downloader.starter_pack()
# print(json.dumps(downloader.list_models(), indent=2))
"""

    def show_code(self):
        print("=== Download Manager ===")
        print(self.CODE[:600])

dl = ModelDownloader()
dl.show_code()

วิธีติดตั้ง Model

# installation.py — How to install models
import json

class ModelInstallation:
    PATHS = {
        "automatic1111": {
            "name": "Automatic1111 / Forge",
            "checkpoints": "stable-diffusion-webui/models/Stable-diffusion/",
            "lora": "stable-diffusion-webui/models/Lora/",
            "vae": "stable-diffusion-webui/models/VAE/",
            "controlnet": "stable-diffusion-webui/extensions/sd-webui-controlnet/models/",
            "embeddings": "stable-diffusion-webui/embeddings/",
            "upscaler": "stable-diffusion-webui/models/ESRGAN/",
        },
        "comfyui": {
            "name": "ComfyUI",
            "checkpoints": "ComfyUI/models/checkpoints/",
            "lora": "ComfyUI/models/loras/",
            "vae": "ComfyUI/models/vae/",
            "controlnet": "ComfyUI/models/controlnet/",
            "embeddings": "ComfyUI/models/embeddings/",
            "upscaler": "ComfyUI/models/upscale_models/",
        },
    }

    STEPS = [
        "1. ดาวน์โหลดไฟล์ .safetensors จาก CivitAI หรือ HuggingFace",
        "2. วางไฟล์ในโฟลเดอร์ที่ถูกต้องตาม UI ที่ใช้",
        "3. Refresh model list ใน UI (กดปุ่ม refresh หรือ restart)",
        "4. เลือก model จาก dropdown menu",
        "5. ทดสอบด้วย prompt ง่ายๆ ก่อน",
    ]

    SECURITY = {
        "safetensors": "✅ ปลอดภัย — ไม่มี arbitrary code execution risk",
        "ckpt": "⚠️ ระวัง — pickle format อาจมี malicious code",
        "recommendation": "ใช้ .safetensors เท่านั้น — ถ้ามี .ckpt ให้แปลงก่อน",
        "convert": "python convert_original_stable_diffusion_to_safetensors.py --checkpoint_path model.ckpt",
    }

    def show_paths(self):
        print("=== Model Folder Paths ===\n")
        for key, ui in self.PATHS.items():
            print(f"[{ui['name']}]")
            for mtype, path in ui.items():
                if mtype != 'name':
                    print(f"  {mtype}: {path}")
            print()

    def show_steps(self):
        print("=== Installation Steps ===")
        for step in self.STEPS:
            print(f"  {step}")

    def show_security(self):
        print(f"\n=== Security ===")
        for key, val in self.SECURITY.items():
            print(f"  [{key}] {val}")

install = ModelInstallation()
install.show_paths()
install.show_steps()
install.show_security()

Model Selection Guide

# selection.py — How to choose the right model
import json

class ModelSelection:
    BY_USE_CASE = {
        "portrait": {
            "name": "Portrait / People",
            "sd15": "Realistic Vision V6, CyberRealistic",
            "sdxl": "Juggernaut XL, RealVisXL",
            "tip": "ใช้ face restoration (CodeFormer/GFPGAN) เสริม",
        },
        "landscape": {
            "name": "Landscape / Nature",
            "sd15": "DreamShaper V8, Deliberate V5",
            "sdxl": "Juggernaut XL, SDXL base + refiner",
            "tip": "Resolution สูง + Hires Fix ให้ภาพชัดขึ้น",
        },
        "anime": {
            "name": "Anime / Manga",
            "sd15": "Anything V5, Counterfeit V3",
            "sdxl": "Animagine XL V3.1, Pony Diffusion",
            "tip": "ใช้ anime-specific negative prompt + LoRA",
        },
        "product": {
            "name": "Product / Commercial",
            "sd15": "Realistic Vision V6 + product LoRA",
            "sdxl": "Juggernaut XL, SDXL base",
            "tip": "ใช้ ControlNet depth สำหรับ consistent angles",
        },
        "concept_art": {
            "name": "Concept Art / Fantasy",
            "sd15": "DreamShaper V8, Deliberate V5",
            "sdxl": "DreamShaper XL, Juggernaut XL",
            "tip": "CFG Scale 7-9, LoRA สำหรับ specific styles",
        },
    }

    BY_HARDWARE = {
        "4gb_vram": {
            "gpu": "4GB VRAM (GTX 1650, RTX 3050)",
            "model": "SD 1.5 pruned + --lowvram",
            "tip": "ใช้ FP16, xFormers, 512x512 max",
        },
        "6gb_vram": {
            "gpu": "6GB VRAM (RTX 2060, RTX 3060 6GB)",
            "model": "SD 1.5 สบายๆ, SDXL ด้วย --medvram",
            "tip": "xFormers + Tiled VAE สำหรับ SDXL",
        },
        "8gb_plus": {
            "gpu": "8GB+ VRAM (RTX 3060 12GB, RTX 4070)",
            "model": "SDXL สบาย, SD 1.5 + ControlNet + LoRA",
            "tip": "ใช้ได้เต็มที่ทุก feature",
        },
    }

    def show_by_use(self):
        print("=== Model by Use Case ===\n")
        for key, uc in self.BY_USE_CASE.items():
            print(f"[{uc['name']}]")
            print(f"  SD 1.5: {uc['sd15']}")
            print(f"  SDXL: {uc['sdxl']}")
            print()

    def show_by_hardware(self):
        print("=== Model by Hardware ===")
        for key, hw in self.BY_HARDWARE.items():
            print(f"\n[{hw['gpu']}]")
            print(f"  Model: {hw['model']}")
            print(f"  Tip: {hw['tip']}")

selection = ModelSelection()
selection.show_by_use()
selection.show_by_hardware()

FAQ - คำถามที่พบบ่อย

Q: ดาวน์โหลด model จากที่ไหนดีที่สุด?

A: CivitAI: ดีที่สุดสำหรับ fine-tuned models — filter ตาม style, rating, base model HuggingFace: ดีสำหรับ official models + Diffusers format วิธี: ดู rating + downloads + sample images ก่อนดาวน์โหลด ใช้ .safetensors เท่านั้น — ปลอดภัยกว่า .ckpt

Q: Model ไหนเหมาะกับมือใหม่?

A: SD 1.5: DreamShaper V8 — versatile ทำได้หลาย style, ไม่ต้อง VRAM เยอะ SDXL: Juggernaut XL — คุณภาพสูง ใช้ง่าย เริ่มจาก model เดียวก่อน → ทดลอง prompts → ค่อยเพิ่ม LoRA + VAE

Q: Pruned กับ Full model ต่างกันอย่างไร?

A: Pruned: เหลือเฉพาะ inference weights → ไฟล์เล็ก (~2GB สำหรับ SD 1.5), สร้างภาพเหมือนกัน Full: มี training data → ไฟล์ใหญ่ (~4GB), ใช้สำหรับ fine-tune/merge สำหรับใช้งาน: ดาวน์โหลด pruned เสมอ — เล็กกว่า โหลดเร็วกว่า output เหมือนกัน

Q: ต้องใช้พื้นที่เก็บเท่าไหร่?

A: ขั้นต่ำ: 1 checkpoint (~2-7GB) + VAE (~300MB) = ~3-8 GB แนะนำ: 3-5 checkpoints + LoRA + VAE + ControlNet = ~20-50 GB หนัก: หลาย checkpoints + SDXL + all extras = 100+ GB ใช้ SSD สำหรับ model storage — โหลดเร็วกว่า HDD มาก

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

Stable Diffusion ComfyUI Observability Stackอ่านบทความ → Stable Diffusion ComfyUI Certification Pathอ่านบทความ → Stable Diffusion ComfyUI Message Queue Designอ่านบทความ → Stable Diffusion ComfyUI DNS Managementอ่านบทความ → stable diffusion ai downloadอ่านบทความ →

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