私的AI研究会 > AI_Program4

生成 AI プログラミング4 == 編集中 ==

image_050_1_m.jpg

 これまで検証してきた結果をもとに、Python で生成 AI プログラムを書く

▲ 目 次
※ 最終更新:2025/07/31 

diffusersではじめめる Stable Diffusion (応用編3)

 画像生成のプログラムを書く

概要

動作環境

Step 50:顔の崩れを修正する

  1. プログラムを実行する(実行時間:約 2秒 RTX 4070 Ti 12GB)
     python sd_050.py
    (sd_test) PS > python sd_050.py
    
    Stable Diffusion with diffusers(050)  Ver 0.06: Starting application...
    
     --result_image             :   results/image_050.png
     --cpu                      :   False
     --log                      :   3
     --model_dir                :   /StabilityMatrix/Data/Models/StableDiffusion
     --model_path               :   SD1.5/beautifulRealistic_brav5.safetensors
     --image_path               :   images/sd_050_test.jpg
     --max_size                 :   0
     --prompt                   :   masterpiece, high quality, very_high_resolution, large_filesize, full color, an extremely cute face, woman, symmetrical, HDR, real, realistic
     --seed                     :   12345678
     --width                    :   512
     --height                   :   512
     --step                     :   20
     --scale                    :   8.5
     --strength                 :   0.4
     --neg_prompt               :   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, artist name, multiple legs, malformation
    
    Fetching 11 files: 100%|███████████████████████████████| 11/11 [00:00<?, ?it/s]
    Loading pipeline components...: 100%|████████████| 6/6 [00:00<00:00, 19.56it/s]
    100%|██████████████████████████████████████████| 20/20 [00:02<00:00,  9.50it/s]
    result_file: results/image_050.png
    
    Finished.
  2. 画像ファイル「image_050.png」が生成される

  3. 実行例
    元画像顔の抽出顔の修正修正画像
    sd_050_test1_src_m.jpg image_050_testa_1_m.jpg image_050_testb_1_m.jpg image_050_1_m.jpg
    sd_050_test2_src_m.jpg image_050_testa_2_m.jpg image_050_testb_2_m.jpg image_050_2_m.jpg
    sd_050_test3_src_m.jpg image_050_testa_3_m.jpg image_050_testb_3_m.jpg image_050_3_m.jpg
    sd_050_test4_src_m.jpg image_050_testa_4_m.jpg image_050_testb_4_m.jpg image_050_4_m.jpg
 

忘備録

 

更新履歴

 

参考資料