金子邦彦研究室人工知能Windows でのインストールと動作確認(人工知能関係)ImaginAIry のインストールと動作確認(画像合成,画像編集,Prompt Based Masking,Image to Image)(Stable Diffusion,InstructPix2Pix,Stable Diffusion 2 Depth,Python を使用)(Windows 上)

ImaginAIry のインストールと動作確認(画像合成,画像編集,Prompt Based Masking,Image to Image)(Stable Diffusion,InstructPix2Pix,Stable Diffusion 2 Depth,Python を使用)(Windows 上)

ImaginAIry は,Python から stable diffusion 画像の生成を扱う機能を持ったソフトウエア.

目次

  1. 前準備
  2. ImaginAIry のインストール(Python,pip を使用)(Windows 上)
  3. 動作確認のため動かしてみる(Windows 上)

    サイト内の関連ページ

    Ubuntu について: 別ページ »で説明

    関連する外部ページ

    ImaginAIry の GitHub のページ: https://github.com/brycedrennan/imaginAIry

前準備

Git のインストール(Windows 上)

Windows での Git のインストール: 別ページ »で説明

関連する外部ページ

Git の公式ページ: https://git-scm.com/

Python のインストール(Windows 上)

Windows での Python 3.10,関連パッケージ,Python 開発環境のインストール: 別ページ »で説明

サイト内の関連ページ

Python のまとめ: 別ページ »にまとめ

関連する外部ページ

Python の公式ページ: https://www.python.org/

Build Tools for Visual Studio 2022,NVIDIA ドライバ,NVIDIA CUDA ツールキット,NVIDIA cuDNN のインストール(Windows 上)

Windows での Build Tools for Visual Studio 2022NVIDIA ドライバNVIDIA CUDA ツールキット 11.8,NVIDIA cuDNN v8.6 のインストールと動作確認: 別ページ »で説明

関連する外部ページ

PyTorch のインストール(Windows 上)

  1. Windows で,コマンドプロンプト管理者として実行

    コマンドプロンプトを管理者として実行: 別ページ »で説明

  2. PyTorch のページを確認

    PyTorch のページ: https://pytorch.org/index.html

  3. 次のようなコマンドを実行(実行するコマンドは,PyTorch のページの表示されるコマンドを使う).

    次のコマンドは, PyTorch 2.0 (NVIDIA CUDA 11.8 用) をインストールする. 事前に NVIDIA CUDA のバージョンを確認しておくこと(ここでは,NVIDIA CUDA ツールキット 11.8 が前もってインストール済みであるとする).

    python -m pip install -U pip
    python -m pip install -U torch torchvision torchaudio numpy numba --index-url https://download.pytorch.org/whl/cu118
    python -c "import torch; print(torch.__version__, torch.cuda.is_available())" 
    

    (途中省略)
    [image]

ImaginAIry のインストール(Python,pip を使用)(Windows 上)

  1. Windows で,コマンドプロンプト管理者として実行

    コマンドプロンプトを管理者として実行: 別ページ »で説明

  2. インストール

    python -m pip install -U imaginairy
    

    [image]
  3. 関連ファイルをダウンロード

    cd %HOMEPATH%
    rmdir /s /q imaginAIry
    git clone --recursive https://github.com/brycedrennan/imaginAIry
    

    [image]

動作確認のため動かしてみる(Windows 上)

https://github.com/brycedrennan/imaginAIry の手順に従う.

テキストからの画像生成(Stable Diffusion を使用)

Windows で,コマンドプロンプト管理者として実行

次を実行することにより,画像ファイルが生成される.画像ファイル名が表示されるので確認.

imagine "海沿いを走る"

[image]

[image]
imagine "a scenic landscape"

[image]

[image]

テキストからの画像生成,Stable Diffusion のバージョンを 2.1 に指定

Windows で,コマンドプロンプト管理者として実行

次を実行することにより,画像ファイルが生成される.画像ファイル名が表示されるので確認.

imagine --model SD-2.1 "海沿いを走る"

[image]

[image]
imagine --model SD-2.1 "a scenic landscape"

[image]

[image]

画像編集(InstructPix2Pix を使用)

InstructPix2Pix を使用している

InstructPix2Pix の GitHub のページ: https://github.com/timothybrooks/instruct-pix2pix

Windows で,コマンドプロンプト管理者として実行

cd %HOMEPATH%
cd imaginAIry
cd assets
aimg edit scenic_landscape_winter.jpg "make a sky sunset"

[image]

元画像

[image]

画像編集の結果

[image]
cd %HOMEPATH%
cd imaginAIry
cd assets
aimg edit 000032_337692011_PLMS40_PS7.5_a_photo_of_a_dog.jpg "make a dog white"

[image]

元画像

[image]

画像編集の結果

[image]
cd %HOMEPATH%
cd imaginAIry
cd assets
aimg edit 000056_293284644_PLMS40_PS7.5_photo_of_a_bowl_of_fruit.jpg "make fruits vegetables"

[image]

元画像

[image]

画像編集の結果

[image]
cd %HOMEPATH%
cd imaginAIry
cd assets
aimg edit spock.jpg "make a man long hair" --prompt-strength 20

[image]

元画像

[image]

画像編集の結果

[image]
cd %HOMEPATH%
cd imaginAIry
cd assets
aimg edit spock.jpg "add glasses"

[image]

元画像

[image]

画像編集の結果

[image]
cd %HOMEPATH%
cd imaginAIry
cd assets
aimg edit spock.jpg "make color tropical"

[image]

元画像

[image]

画像編集の結果

[image]

Prompt Based Masking(clipseg を使用)

clipseg を使用している.

clipseg の GitHub のページ: https://github.com/timojl/clipseg

Windows で,コマンドプロンプト管理者として実行

cd %HOMEPATH%
cd imaginAIry
cd assets
imagine ^
    --init-image girl_with_a_pearl_earring.jpg ^
    --mask-prompt "face AND NOT (bandana OR hair OR blue fabric){*6}" ^
    --mask-mode keep ^
    --init-image-strength .2 ^
    --fix-faces ^
   "a young girl" "an old lady" "white dressed" "fireman"

[image]

元画像

[image]

Prompt Based Masking の結果

[image]

[image]

[image]

[image]
cd %HOMEPATH%
cd imaginAIry
cd assets
imagine ^
    --init-image 000056_293284644_PLMS40_PS7.5_photo_of_a_bowl_of_fruit.jpg ^
     --mask-prompt "fruit OR fruit stem{*6}" ^
    --mask-mode replace ^
    --mask-modify-original ^
    --init-image-strength .1 ^
    "ball" "animal doll" "soup" "rice" "candy" "pencil" 

[image]

元画像

[image]

Prompt Based Masking の結果

[image]

[image]

[image]

[image]

[image]

[image]

Image-to-Image(Stable Diffusion 2 Depth を使用)

Stable Diffusion 2 Depth を使用している.

Windows で,コマンドプロンプト管理者として実行

cd %HOMEPATH%
cd imaginAIry
cd assets
imagine --model SD-2.0-depth --init-image mona-lisa.jpg --init-image-strength 0.05  "professional headshot photo of a woman" -r 4 -w 1024 -h 1024 --steps 50

[image]

[image]

[image]

[image]

[image]

[image]