Tạo ảnh fantasy bằng Stable Diffusion trên Windows 10

Bài viết này giới thiệu cách tạo ảnh fantasy bằng Stable Diffusion trên Windows 10. Việc tạo ảnh có độ khó trung bình, người có kiến thức tốt về phần cứng & lập trình là làm được.

Yêu cầu phần cứng tối thiểu

  • Hệ điều hành: Windows 10
  • RAM: tối thiếu 16GB
  • GPU: NVIDIA có VRAM 12GB trở lên

Nếu phần cứng không đủ vẫn có thể chạy được bằng cách tinh chỉnh lại phần mềm hoặc sử dụng Colab. Bài viết này chỉ hướng dẫn cách chạy local trên PC.

Tổng quan các bước thực hiện

  • Cài đặt phần mềm cần thiết
  • Cài đặt Stable Diffusion
  • Download các model
  • Viết prompt tạo ảnh

Bước 1: cài đặt phần mềm cần thiết

Bước 2: cài đặt Stable Diffusion

Clone repo tại link: https://github.com/AUTOMATIC1111/stable-diffusion-webui.git

Sau đó chạy file webui-user.bat. File này sẽ cài lib torch và các packages cần thiết khác. Nếu cài thành công bạn có thể truy cập bằng browser ở đường link http://127.0.0.1:7860

Mở brower nhập 127.0.0.1:7860 hoặc localhost:7860 sẽ hiện ra giao diện như bên dưới

Bước 3: download các checkpoint

Có nhiều checkpoint tuy nhiên qua thử nghiệm thì mình thấy chỉ có 2 checkpoint cho kết quả tốt mà thôi:

  1. Chillout Mix: tạo ảnh người châu Á, hơi có nét fantastic 1 chút
  2. URPM: tạo ảnh siêu thực, nhìn giống người thật hơn

Download về bỏ vào folder stable-diffusion-webui\models\Stable-diffusion. Sau đó reload checkpoint để lựa chọn checkpoint bạn muốn. Các checkpoint khác các bạn có thể tự tìm hiểu và trải nghiệm.

Bước 4: tạo ảnh

Các bạn chỉ cần 2 prompt, 1 prompt chứa nội dung bạn mong muốn (prompt) và 1 prompt chứa nội dung bạn muốn loại bỏ (negative prompt). Prompt như sau:

Prompt

{{{masterpiece}}}, {{best quality, super fine illustration , beautiful and delicate water,The finest grass}}. ((beautiful eyes)),{ very delicate light, perfect and delicate limbs}, {nature, painting, water spray},{{ fine luminescence ,very fine 8K CG wallpaper}},Lavender eyes, pink pupils, whole body, white hair, bright eyes,( (an extremely delicate and beautiful girl)), ((1 girl)), medium bust, dynamic angle, (white dress with gold decoration), (long hair flowing with the wind, beautiful hair ornaments, delicate wet skirt, nsfw, breeze, long bangs between eyes), wrinkled skirt, (staring blankly, lovely big eyes),messy_hair,payot,Lateral braid,(Tulle lace white skirt),flowers and grass meadow, near the water edge, (sunset, starry sky in a circle), randomly distributed clouds, (((river))), splashing water, falling petals

Negative prompt

(((simple background))),monochrome ,lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry, ugly, pregnant,vore,duplicate,morbid,mut ilated,tran nsexual, hermaphrodite,long neck,mutated hands,poorly drawn hands,poorly drawn face,mutation,deformed, (((missing arms))),(((missing legs))), (((extra arms))),(((extra legs))),pubic hair, plump,bad legs,error legs, bad feet, loli, little girl

Các tham số:

  • Sampling method: DPM++ SDE Karras
  • Width: 512
  • Height: 768
  • CFG Scale: 7
  • Seed: -1 (random)

Kết quả như hình dưới, chúc các bạn thành công!