私的AI研究会 > ProjectEnv1
「画像生成AI Stable-Diffusion」プロジェクトを実行できる環境を新しく作成する手順
$ sudo apt update ... $ sudo apt install -y fonts-noto
$ sudo apt install gnome-tweaks
$ sudo apt install openssh-server
$ sudo apt install net-tools
$ vi ~/.vimrc set nocompatible set backspace=indent,eol,start set expandtab set tabstop=4 set shiftwidth=4 set autoindentsudo 付きで vi を実行した場合は、root の設定が使用されるので、rootの .vimrcを ~/vimrc のシンボリックリンクにする。
$ sudo ln -s ~/.vimrc /root/.vimrc $ sudo ls -la /root 合計 24 drwx------ 4 root root 4096 3月 31 19:07 . drwxr-xr-x 20 root root 4096 3月 31 17:29 .. -rw-r--r-- 1 root root 3106 12月 5 2019 .bashrc drwx------ 2 root root 4096 2月 10 03:51 .cache -rw-r--r-- 1 root root 161 12月 5 2019 .profile lrwxrwxrwx 1 root root 19 3月 31 19:07 .vimrc -> /home/mizutu/.vimrc drwxr-xr-x 3 root root 4096 3月 31 17:33 snap
sudo apt-get install ubuntu-restricted-extras
$ cd ダウンロード $ bash Anaconda3-2022.10-Linux-x86_64.sh Welcome to Anaconda3 2022.10 In order to continue the installation process, please review the license agreement. Please, press ENTER to continue >>> ← Enter入力 : installation finished. Do you wish the installer to initialize Anaconda3 by running conda init? [yes|no] [no] >>> yes ← yes入力 : DataSpell for Anaconda is available at: https://www.anaconda.com/dataspell
(base) $
(base) $ 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) $ conda create -n py38 python=3.8
(base) $ conda info -e # conda environments: # base * /home/XXXXX/anaconda3 py38 /home/XXXXX/anaconda3/envs/py38 (base) $ conda activate py38 (py38) $ ← (py38) に切り替わっていることを確認する
$ conda config --set auto_activate_base False
$ conda info -e # conda environments: # base /home/mizutu/anaconda3 py38 /home/mizutu/anaconda3/envs/py38
$ vi anaconda3_setup_py38.sh #!/bin/sh echo [anaconda3_setup_py38.sh] Anaconda3 environment initialized source ~/anaconda3/etc/profile.d/conda.sh echo "conda activate py38" echo " Exit >> 'conda deactivate'" conda activate py38 export PYTHONPATH=$PYTHONPATH:$HOME/workspace_py37/mylib
$ chmod u+x anaconda3_setup_py38.sh
$ vi .bashrc : # >>> conda initialize >>> # !! Contents within this block are managed by 'conda init' !! __conda_setup="$('/home/mizutu/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)" if [ $? -eq 0 ]; then eval "$__conda_setup" else if [ -f "/home/mizutu/anaconda3/etc/profile.d/conda.sh" ]; then . "/home/mizutu/anaconda3/etc/profile.d/conda.sh" else export PATH="/home/mizutu/anaconda3/bin:$PATH" fi fi unset __conda_setup # <<< conda initialize <<< source $HOME/anaconda3_setup_py38.sh
[anaconda3_setup_py38.sh] Anaconda3 environment initialized conda activate py38 Exit >> 'conda deactivate' (py38) $ which python /home/XXXXX/anaconda3/envs/py38/bin/python (py38) $ which pip /home/XXXXX/anaconda3/envs/py38/bin/pip (py38) $ which conda /home/XXXXX/anaconda3/condabin/conda (py38) $ printenv PYTHONPATH :/home/XXXXX/workspace_py37/mylib
~/ ├─workspace_py37 │ ├─mylib ← python 共有ライブラリ (パスが通っていること) │ └─openvino └─workspace_py38 ← anaconda 環境下のアプリケーション・プロジェクト ├─googletrans └─stable_diffusion
(py38) $ cd ~/workspace_py38/stable_diffusion/ (py38) $ python -m pip install --upgrade pip (py38) $ pip install openvino==2022.1.0 (py38) $ pip install -r requirements.txt
(py38) $ cd ~/workspace_py38/stable_diffusion (py38) $ 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]
(py38) $ 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) $ cd ~/workspace_py38/googletrans (py38) $ 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) $ cd ~/workspace_py38/stable_diffusion (py38) $ 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 ** 834937033 32it [08:23, 15.74s/it] -Output-: result/output_0834937033.png ** end ** 00:09:07
Finished.
(py38) $ cd ~/workspace_py38/stable_diffusion (py38) $ 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 ** 3422673869 32it [08:13, 15.43s/it] ** end ** 00:09:00 Prompt: Street-art painting of Tom Cruise in style of Gogh, photorealism (和訳): ゴッホのスタイルでのトムクルーズのストリートアートペインティング、フォトリアリズム ** start 1 - 0 ** 1695384802 32it [08:17, 15.55s/it] ** end ** 00:08:58 Finished.
(py38) $ python stable_diffusion_make2.py -i input_mk.csv