私的AI研究会 > ProjectEnv
「画像生成AI Stable-Diffusion」プロジェクトを実行できる環境を新しく作成する手順
(base) PS > conda update -n base -c defaults conda Collecting package metadata (current_repodata.json): done Solving environment: done : Proceed ([y]/n)? y ← 'y' を入力する : Executing transaction: done Retrieving notices: ...working... done
(base) PS > echo $env:PYTHONPATH c:\anaconda_win\workspace_py37\mylib
%windir%\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy ByPass -NoExit -Command "& 'C:\ProgramData\Anaconda3\shell\condabin\conda-hook.ps1' ; conda activate 'C:\Users\<User>\anaconda3' "・次のように変更 <User> = ユーザー名 C: = anaconda_winを配置したドライブ
%windir%\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy ByPass -NoExit -Command "& 'C:\ProgramData\Anaconda3\shell\condabin\conda-hook.ps1' ; conda activate 'C:\Users\<User>\anaconda3' ; Set-Location 'c:\anaconda_win' "※ 長すぎて入力できない場合はスペースをとるか、Set-Location 以下を省略するなどの対応をとる
(base) PS > conda create -n py38 python=3.8
(base) PS $ conda info -e # conda environments: # base * C:\Users\XXXXX\anaconda3 py38 C:\Users\XXXXX\anaconda3\envs\py38 (base) PS > conda activate py38 (py38) PS > ← (py38) に切り替わっていることを確認する
c:/anaconda_win ├─workspace_py37 │ ├─mylib ← python 共有ライブラリ (パスが通っていること) │ └─openvino └─workspace_py38 ← anaconda 環境下のアプリケーション・プロジェクト ├─googletrans └─stable_diffusion
(py38) PS > cd c:/anaconda_win/workspace_py38\stable_diffusion (py38) PS > python -m pip install --upgrade pip (py38) PS > pip install openvino==2022.1.0 (py38) PS > pip install -r requirements.txt
(py38) PS > cd c:/anaconda_win/workspace_py38\stable_diffusion (py38) PS > python demo.py --prompt "Street-art painting of Tom Cruise in style of Gogh, photorealism" 32it [22:05, 41.41s/it]↑ -- 1回あたりの演算速度(秒)
Downloading: 100%|██████████████████████████████| 905/905 [00:00<00:00, 668kB/s] Downloading: 100%|████████████████████████████| 939k/939k [00:01<00:00, 867kB/s] Downloading: 100%|████████████████████████████| 512k/512k [00:00<00:00, 626kB/s] Downloading: 100%|██████████████████████████████| 389/389 [00:00<00:00, 402kB/s] Downloading: 100%|█████████████████████████| 2.12M/2.12M [00:01<00:00, 1.42MB/s] Downloading: 100%|████████████████████████████| 464k/464k [00:00<00:00, 548kB/s] Downloading: 100%|███████████████████████████| 492M/492M [00:11<00:00, 42.2MB/s] Downloading: 100%|█████████████████████████| 3.02M/3.02M [00:01<00:00, 1.77MB/s] Downloading: 100%|█████████████████████████| 3.44G/3.44G [02:10<00:00, 26.4MB/s] Downloading: 100%|████████████████████████████| 329k/329k [00:00<00:00, 473kB/s] Downloading: 100%|███████████████████████████| 198M/198M [00:09<00:00, 20.7MB/s] Downloading: 100%|████████████████████████████| 252k/252k [00:00<00:00, 448kB/s] Downloading: 100%|███████████████████████████| 137M/137M [00:05<00:00, 23.3MB/s]※ Windows で管理権限がないとエラーになるとき → ここを参照
(py38) PS > pip install googletrans==4.0.0-rc1 Collecting googletrans==4.0.0-rc1 Downloading googletrans-4.0.0rc1.tar.gz (20 kB) Preparing metadata (setup.py) ... done : Successfully built googletrans Installing collected packages: googletrans Successfully installed googletrans-4.0.0rc1
(py38) PS > cd c:/anaconda_win/workspace_py38/googletrans (py38) PS > python test3.py こんにちは 光が差し込む美しい緑の森 → Beautiful green forest where light shines Beautiful green forest where light shines → 光が輝く美しい緑の森 月見をする黒猫 → Black cat with the moon Black cat with the moon → 月と黒猫 ビルの屋上で夜空を見上げる少女 → A girl looking up at the night sky on the roof of the building A girl looking up at the night sky on the roof of the building → 建物の屋根で夜空を見上げている女の子 中世の小さい街のイラスト → Illustrations of small medieval cities Illustrations of small medieval cities → 中世の小さな都市のイラスト 私はにゃんこを飼っています。 → I have a cat. I have a cat. → 私は猫を飼っています。 私はにゃんこを飼っていますが、最近食べ過ぎて太ってしまい、健康状態が心配です。 → I have a cat, but I'm worried about my health because I have eaten too much recently and get fat. I have a cat, but I'm worried about my health because I have eaten too much recently and get fat. → 私は猫を飼っていますが、私は最近食べすぎて太っているので、 私は自分の健康について心配しています。 道を歩いていたら、気持ちよさそうに毛づくろいしている猫を発見した。 → As I was walking on the road, I found a grooming cat with pleasant hair. As I was walking on the road, I found a grooming cat with pleasant hair. → 道を歩いていたとき、心地よい髪の毛づくろいを見つけました。
(py38) PS > cd /anaconda_win/workspace_py38/stable_diffusion (py38) PS > python stable_diffusion2.py Starting.. [Errno 2] No such file or directory: 'setting.csv' - Program title : Stable Diffusion2 OpenVINO™ Ver 0.02 - OpenVINO engine: 2022.1.0-7019-cdb9bec7210-releases/2022/1 - OpenCV version : 4.5.5 - Log level : 3 - Output dir : result/ - Output header : output_ - model : bes-dev/stable-diffusion-v1-4-openvino - beta_start : 0.00085 - beta_end : 0.012 - beta_schedule : scaled_linear - eta : 0.0 - tokenizer : openai/clip-vit-large-patch14
Prompt: Beautiful green forest where light shines (和訳): 光が輝く美しい緑の森 ** start 0 ** 734437651 32it [19:41, 36.92s/it] -Output-: result/output_0734437651.png ** end ** 00:21:44
Finished.
(py38) PS > cd /anaconda_win/workspace_py38/stable_diffusion (py38) PS > python stable_diffusion_make2.py Starting.. - Program title : Stable Diffusion OpenVINO™ auto making 2 Ver 0.01 - OpenVINO engine: 2022.1.0-7019-cdb9bec7210-releases/2022/1 - OpenCV version : 4.5.5 - Input file : input.csv - Seed reset : y - Log level : 3 - model : bes-dev/stable-diffusion-v1-4-openvino - beta_start : 0.00085 - beta_end : 0.012 - beta_schedule : scaled_linear - eta : 0.0 - tokenizer : openai/clip-vit-large-patch14 Prompt: Street-art painting of Tom Cruise in style of Gogh, photorealism (和訳): ゴッホのスタイルでのトムクルーズのストリートアートペインティング、フォ トリアリズム ** start 0 - 0 ** 1259689998 32it [20:17, 38.05s/it] ** end ** 00:22:22 Prompt: Street-art painting of Tom Cruise in style of Gogh, photorealism (和訳): ゴッホのスタイルでのトムクルーズのストリートアートペインティング、フォ トリアリズム ** start 1 - 0 ** 84977309 32it [21:01, 39.42s/it] ** end ** 00:23:03 Finished.
(py38) PS > python .\stable_diffusion_make2.py -i input_mk.csv
PS C:\anaconda_win\workspace_py38> conda update -n base -c defaults conda Collecting package metadata (current_repodata.json): failed CondaSSLError: OpenSSL appears to be unavailable on this machine. OpenSSL is required to download and install packages. Exception: HTTPSConnectionPool(host='repo.anaconda.com', port=443): Max retries exceeded with url: /pkgs/main/win-64/current_repodata.json (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) PS C:\anaconda_win\workspace_py38>
PS C:\anaconda_win\workspace_py38> conda activate base (base) PS C:\anaconda_win\workspace_py38> conda update -n base -c defaults conda Collecting package metadata (current_repodata.json): done Solving environment: done # All requested packages already installed. (base) PS C:\anaconda_win\workspace_py38>
■ Windows10の場合
■ Windows11の場合
(py38) PS > python .\stable_diffusion2.py Traceback (most recent call last): File ".\stable_diffusion2.py", line 65, in <module> import PySimpleGUI as sg ModuleNotFoundError: No module named 'PySimpleGUI'