实例
数据集
笔记本
笔记本
Homework_MMagic
暂无摘要
笔记本内容
一、安装 MMagic #
1. 安装 Pytorch #
!pip3 install install torch==1.10.1+cu113 torchvision==0.11.2+cu113 torchaudio==0.10.1+cu113 -f https://download.pytorch.org/whl/cu113/torch_stable.html
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Looking in links: https://download.pytorch.org/whl/cu113/torch_stable.html Collecting install Downloading https://pypi.tuna.tsinghua.edu.cn/packages/4d/c8/8cbca135f9e167810756ea2bc34b028501936675fcbd7dadccf752fa4622/install-1.3.5-py3-none-any.whl (3.2 kB) Collecting torch==1.10.1+cu113 Downloading https://download.pytorch.org/whl/cu113/torch-1.10.1%2Bcu113-cp37-cp37m-linux_x86_64.whl (1821.5 MB) [K |█████████████████████████▏ | 1430.9 MB 83.9 MB/s eta 0:00:05 |████▋ | 263.5 MB 60.0 MB/s eta 0:00:26 |████▉ | 274.7 MB 60.0 MB/s eta 0:00:26 |█████ | 281.5 MB 60.0 MB/s eta 0:00:26 |██████████████ | 802.6 MB 88.6 MB/s eta 0:00:12 |██████████████████ | 1029.4 MB 84.8 MB/s eta 0:00:10
IOPub data rate exceeded. The Jupyter server will temporarily stop sending output to the client in order to avoid crashing it. To change this limit, set the config variable `--ServerApp.iopub_data_rate_limit`. Current values: ServerApp.iopub_data_rate_limit=1000000.0 (bytes/sec) ServerApp.rate_limit_window=3.0 (secs)
[K |██████████████████████████████ | 1710.5 MB 90.6 MB/s eta 0:00:02
IOPub data rate exceeded. The Jupyter server will temporarily stop sending output to the client in order to avoid crashing it. To change this limit, set the config variable `--ServerApp.iopub_data_rate_limit`. Current values: ServerApp.iopub_data_rate_limit=1000000.0 (bytes/sec) ServerApp.rate_limit_window=3.0 (secs)
[K |████████████████████████████████| 1821.5 MB 92.6 MB/s eta 0:00:01 [?25hCollecting torchvision==0.11.2+cu113 Downloading https://download.pytorch.org/whl/cu113/torchvision-0.11.2%2Bcu113-cp37-cp37m-linux_x86_64.whl (24.6 MB) [K |████████████████████████████████| 24.6 MB 54.3 MB/s eta 0:00:01 [?25hCollecting torchaudio==0.10.1+cu113 Downloading https://download.pytorch.org/whl/cu113/torchaudio-0.10.1%2Bcu113-cp37-cp37m-linux_x86_64.whl (2.9 MB) [K |████████████████████████████████| 2.9 MB 53.5 MB/s eta 0:00:01 [?25hRequirement already satisfied: typing-extensions in /environment/miniconda3/lib/python3.7/site-packages (from torch==1.10.1+cu113) (4.0.1) Requirement already satisfied: numpy in /environment/miniconda3/lib/python3.7/site-packages (from torchvision==0.11.2+cu113) (1.21.4) Requirement already satisfied: pillow!=8.3.0,>=5.3.0 in /environment/miniconda3/lib/python3.7/site-packages (from torchvision==0.11.2+cu113) (8.4.0) Installing collected packages: torch, torchvision, torchaudio, install Attempting uninstall: torch Found existing installation: torch 1.10.0+cu113 Uninstalling torch-1.10.0+cu113: Successfully uninstalled torch-1.10.0+cu113 Attempting uninstall: torchvision Found existing installation: torchvision 0.11.1+cu113 Uninstalling torchvision-0.11.1+cu113: Successfully uninstalled torchvision-0.11.1+cu113 Attempting uninstall: torchaudio Found existing installation: torchaudio 0.10.0+cu113 Uninstalling torchaudio-0.10.0+cu113: Successfully uninstalled torchaudio-0.10.0+cu113 Successfully installed install-1.3.5 torch-1.10.1+cu113 torchaudio-0.10.1+cu113 torchvision-0.11.2+cu113
2. 安装 MMCV 和 MMEngine 环境 #
!pip3 install openmim
!mim install 'mmcv>=2.0.0'
!mim install 'mmengine'
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Collecting openmim Downloading https://pypi.tuna.tsinghua.edu.cn/packages/b9/19/f7436e610163f65ff83de5a768180e73765e54bdaee5f5f37983aa3171b9/openmim-0.3.7-py2.py3-none-any.whl (51 kB) [K |████████████████████████████████| 51 kB 3.7 MB/s eta 0:00:01 [?25hRequirement already satisfied: requests in /environment/miniconda3/lib/python3.7/site-packages (from openmim) (2.24.0) Requirement already satisfied: colorama in /environment/miniconda3/lib/python3.7/site-packages (from openmim) (0.4.4) Requirement already satisfied: Click in /environment/miniconda3/lib/python3.7/site-packages (from openmim) (7.1.2) Requirement already satisfied: pandas in /environment/miniconda3/lib/python3.7/site-packages (from openmim) (1.3.4) Requirement already satisfied: pip>=19.3 in /environment/miniconda3/lib/python3.7/site-packages (from openmim) (21.1.3) Collecting rich Downloading https://pypi.tuna.tsinghua.edu.cn/packages/fc/1e/482e5eec0b89b593e81d78f819a9412849814e22225842b598908e7ac560/rich-13.4.2-py3-none-any.whl (239 kB) [K |████████████████████████████████| 239 kB 70.0 MB/s eta 0:00:01 [?25hCollecting model-index Downloading https://pypi.tuna.tsinghua.edu.cn/packages/0f/a6/4d4cbbef704f186d143e2859296a610a355992e4eae71582bd598093b36a/model_index-0.1.11-py3-none-any.whl (34 kB) Requirement already satisfied: tabulate in /environment/miniconda3/lib/python3.7/site-packages (from openmim) (0.8.7) Requirement already satisfied: markdown in /environment/miniconda3/lib/python3.7/site-packages (from model-index->openmim) (3.3.6) Requirement already satisfied: pyyaml in /environment/miniconda3/lib/python3.7/site-packages (from model-index->openmim) (6.0) Collecting ordered-set Downloading https://pypi.tuna.tsinghua.edu.cn/packages/33/55/af02708f230eb77084a299d7b08175cff006dea4f2721074b92cdb0296c0/ordered_set-4.1.0-py3-none-any.whl (7.6 kB) Requirement already satisfied: importlib-metadata>=4.4 in /environment/miniconda3/lib/python3.7/site-packages (from markdown->model-index->openmim) (4.8.2) Requirement already satisfied: typing-extensions>=3.6.4 in /environment/miniconda3/lib/python3.7/site-packages (from importlib-metadata>=4.4->markdown->model-index->openmim) (4.0.1) Requirement already satisfied: zipp>=0.5 in /environment/miniconda3/lib/python3.7/site-packages (from importlib-metadata>=4.4->markdown->model-index->openmim) (3.6.0) Requirement already satisfied: pytz>=2017.3 in /environment/miniconda3/lib/python3.7/site-packages (from pandas->openmim) (2021.3) Requirement already satisfied: numpy>=1.17.3 in /environment/miniconda3/lib/python3.7/site-packages (from pandas->openmim) (1.21.4) Requirement already satisfied: python-dateutil>=2.7.3 in /environment/miniconda3/lib/python3.7/site-packages (from pandas->openmim) (2.8.2) Requirement already satisfied: six>=1.5 in /environment/miniconda3/lib/python3.7/site-packages (from python-dateutil>=2.7.3->pandas->openmim) (1.16.0) Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /environment/miniconda3/lib/python3.7/site-packages (from requests->openmim) (1.25.11) Requirement already satisfied: chardet<4,>=3.0.2 in /environment/miniconda3/lib/python3.7/site-packages (from requests->openmim) (3.0.4) Requirement already satisfied: certifi>=2017.4.17 in /environment/miniconda3/lib/python3.7/site-packages (from requests->openmim) (2021.5.30) Requirement already satisfied: idna<3,>=2.5 in /environment/miniconda3/lib/python3.7/site-packages (from requests->openmim) (2.10) Collecting markdown-it-py>=2.2.0 Downloading https://pypi.tuna.tsinghua.edu.cn/packages/bf/25/2d88e8feee8e055d015343f9b86e370a1ccbec546f2865c98397aaef24af/markdown_it_py-2.2.0-py3-none-any.whl (84 kB) [K |████████████████████████████████| 84 kB 42.4 MB/s eta 0:00:01 [?25hCollecting pygments<3.0.0,>=2.13.0 Downloading https://pypi.tuna.tsinghua.edu.cn/packages/34/a7/37c8d68532ba71549db4212cb036dbd6161b40e463aba336770e80c72f84/Pygments-2.15.1-py3-none-any.whl (1.1 MB) [K |████████████████████████████████| 1.1 MB 59.5 MB/s eta 0:00:01 [?25hCollecting mdurl~=0.1 Downloading https://pypi.tuna.tsinghua.edu.cn/packages/b3/38/89ba8ad64ae25be8de66a6d463314cf1eb366222074cfda9ee839c56a4b4/mdurl-0.1.2-py3-none-any.whl (10.0 kB) Installing collected packages: mdurl, pygments, ordered-set, markdown-it-py, rich, model-index, openmim Attempting uninstall: pygments Found existing installation: Pygments 2.10.0 Uninstalling Pygments-2.10.0: Successfully uninstalled Pygments-2.10.0 Successfully installed markdown-it-py-2.2.0 mdurl-0.1.2 model-index-0.1.11 openmim-0.3.7 ordered-set-4.1.0 pygments-2.15.1 rich-13.4.2 Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Looking in links: https://download.openmmlab.com/mmcv/dist/cu113/torch1.10.0/index.html Collecting mmcv>=2.0.0 Downloading https://download.openmmlab.com/mmcv/dist/cu113/torch1.10.0/mmcv-2.0.0-cp37-cp37m-manylinux1_x86_64.whl (86.2 MB) [K |████████████████████████████████| 86.2 MB 5.6 MB/s eta 0:00:011 |▎ | 788 kB 1.1 MB/s eta 0:01:17 |█▏ | 3.2 MB 1.1 MB/s eta 0:01:15 |██▋ | 6.9 MB 1.1 MB/s eta 0:01:12 |██▉ | 7.5 MB 17.8 MB/s eta 0:00:05 |███▊ | 10.0 MB 17.8 MB/s eta 0:00:05 |████▋ | 12.4 MB 17.8 MB/s eta 0:00:05 |█████ | 13.6 MB 17.8 MB/s eta 0:00:05 |██████ | 16.1 MB 17.8 MB/s eta 0:00:04 |████████▋ | 23.2 MB 5.5 MB/s eta 0:00:12 |████████▊ | 23.6 MB 5.5 MB/s eta 0:00:12 |█████████▊ | 26.2 MB 5.5 MB/s eta 0:00:11 |█████████▉ | 26.5 MB 5.5 MB/s eta 0:00:11 |███████████████████████████▏ | 73.2 MB 22.2 MB/s eta 0:00:01 |██████████████████████████████▉ | 83.1 MB 5.6 MB/s eta 0:00:01 [?25hRequirement already satisfied: Pillow in /environment/miniconda3/lib/python3.7/site-packages (from mmcv>=2.0.0) (8.4.0) Collecting addict Downloading https://pypi.tuna.tsinghua.edu.cn/packages/6a/00/b08f23b7d7e1e14ce01419a467b583edbb93c6cdb8654e54a9cc579cd61f/addict-2.4.0-py3-none-any.whl (3.8 kB) Requirement already satisfied: pyyaml in /environment/miniconda3/lib/python3.7/site-packages (from mmcv>=2.0.0) (6.0) Requirement already satisfied: numpy in /environment/miniconda3/lib/python3.7/site-packages (from mmcv>=2.0.0) (1.21.4) Requirement already satisfied: packaging in /environment/miniconda3/lib/python3.7/site-packages (from mmcv>=2.0.0) (21.3) Requirement already satisfied: opencv-python>=3 in /environment/miniconda3/lib/python3.7/site-packages (from mmcv>=2.0.0) (4.5.4.60) Collecting mmengine>=0.2.0 Downloading https://pypi.tuna.tsinghua.edu.cn/packages/11/f4/714c5fa78885c459a4d75957764367c195c937b56f5325898ea514c5a04e/mmengine-0.7.4-py3-none-any.whl (374 kB) [K |████████████████████████████████| 374 kB 56.7 MB/s eta 0:00:01 [?25hRequirement already satisfied: yapf in /environment/miniconda3/lib/python3.7/site-packages (from mmcv>=2.0.0) (0.31.0) Requirement already satisfied: matplotlib in /environment/miniconda3/lib/python3.7/site-packages (from mmengine>=0.2.0->mmcv>=2.0.0) (3.5.0) Requirement already satisfied: rich in /environment/miniconda3/lib/python3.7/site-packages (from mmengine>=0.2.0->mmcv>=2.0.0) (13.4.2) Requirement already satisfied: termcolor in /environment/miniconda3/lib/python3.7/site-packages (from mmengine>=0.2.0->mmcv>=2.0.0) (1.1.0) Requirement already satisfied: setuptools-scm>=4 in /environment/miniconda3/lib/python3.7/site-packages (from matplotlib->mmengine>=0.2.0->mmcv>=2.0.0) (6.3.2) Requirement already satisfied: python-dateutil>=2.7 in /environment/miniconda3/lib/python3.7/site-packages (from matplotlib->mmengine>=0.2.0->mmcv>=2.0.0) (2.8.2) Requirement already satisfied: kiwisolver>=1.0.1 in /environment/miniconda3/lib/python3.7/site-packages (from matplotlib->mmengine>=0.2.0->mmcv>=2.0.0) (1.3.2) Requirement already satisfied: pyparsing>=2.2.1 in /environment/miniconda3/lib/python3.7/site-packages (from matplotlib->mmengine>=0.2.0->mmcv>=2.0.0) (3.0.6) Requirement already satisfied: cycler>=0.10 in /environment/miniconda3/lib/python3.7/site-packages (from matplotlib->mmengine>=0.2.0->mmcv>=2.0.0) (0.11.0) Requirement already satisfied: fonttools>=4.22.0 in /environment/miniconda3/lib/python3.7/site-packages (from matplotlib->mmengine>=0.2.0->mmcv>=2.0.0) (4.28.3) Requirement already satisfied: six>=1.5 in /environment/miniconda3/lib/python3.7/site-packages (from python-dateutil>=2.7->matplotlib->mmengine>=0.2.0->mmcv>=2.0.0) (1.16.0) Requirement already satisfied: tomli>=1.0.0 in /environment/miniconda3/lib/python3.7/site-packages (from setuptools-scm>=4->matplotlib->mmengine>=0.2.0->mmcv>=2.0.0) (1.2.2) Requirement already satisfied: setuptools in /environment/miniconda3/lib/python3.7/site-packages (from setuptools-scm>=4->matplotlib->mmengine>=0.2.0->mmcv>=2.0.0) (52.0.0.post20210125) Requirement already satisfied: markdown-it-py>=2.2.0 in /environment/miniconda3/lib/python3.7/site-packages (from rich->mmengine>=0.2.0->mmcv>=2.0.0) (2.2.0) Requirement already satisfied: typing-extensions<5.0,>=4.0.0 in /environment/miniconda3/lib/python3.7/site-packages (from rich->mmengine>=0.2.0->mmcv>=2.0.0) (4.0.1) Requirement already satisfied: pygments<3.0.0,>=2.13.0 in /environment/miniconda3/lib/python3.7/site-packages (from rich->mmengine>=0.2.0->mmcv>=2.0.0) (2.15.1) Requirement already satisfied: mdurl~=0.1 in /environment/miniconda3/lib/python3.7/site-packages (from markdown-it-py>=2.2.0->rich->mmengine>=0.2.0->mmcv>=2.0.0) (0.1.2) Installing collected packages: addict, mmengine, mmcv Successfully installed addict-2.4.0 mmcv-2.0.0 mmengine-0.7.4 Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Looking in links: https://download.openmmlab.com/mmcv/dist/cu113/torch1.10.0/index.html Requirement already satisfied: mmengine in /environment/miniconda3/lib/python3.7/site-packages (0.7.4) Requirement already satisfied: opencv-python>=3 in /environment/miniconda3/lib/python3.7/site-packages (from mmengine) (4.5.4.60) Requirement already satisfied: numpy in /environment/miniconda3/lib/python3.7/site-packages (from mmengine) (1.21.4) Requirement already satisfied: yapf in /environment/miniconda3/lib/python3.7/site-packages (from mmengine) (0.31.0) Requirement already satisfied: pyyaml in /environment/miniconda3/lib/python3.7/site-packages (from mmengine) (6.0) Requirement already satisfied: termcolor in /environment/miniconda3/lib/python3.7/site-packages (from mmengine) (1.1.0) Requirement already satisfied: addict in /environment/miniconda3/lib/python3.7/site-packages (from mmengine) (2.4.0) Requirement already satisfied: rich in /environment/miniconda3/lib/python3.7/site-packages (from mmengine) (13.4.2) Requirement already satisfied: matplotlib in /environment/miniconda3/lib/python3.7/site-packages (from mmengine) (3.5.0) Requirement already satisfied: pyparsing>=2.2.1 in /environment/miniconda3/lib/python3.7/site-packages (from matplotlib->mmengine) (3.0.6) Requirement already satisfied: fonttools>=4.22.0 in /environment/miniconda3/lib/python3.7/site-packages (from matplotlib->mmengine) (4.28.3) Requirement already satisfied: kiwisolver>=1.0.1 in /environment/miniconda3/lib/python3.7/site-packages (from matplotlib->mmengine) (1.3.2) Requirement already satisfied: setuptools-scm>=4 in /environment/miniconda3/lib/python3.7/site-packages (from matplotlib->mmengine) (6.3.2) Requirement already satisfied: packaging>=20.0 in /environment/miniconda3/lib/python3.7/site-packages (from matplotlib->mmengine) (21.3) Requirement already satisfied: cycler>=0.10 in /environment/miniconda3/lib/python3.7/site-packages (from matplotlib->mmengine) (0.11.0) Requirement already satisfied: pillow>=6.2.0 in /environment/miniconda3/lib/python3.7/site-packages (from matplotlib->mmengine) (8.4.0) Requirement already satisfied: python-dateutil>=2.7 in /environment/miniconda3/lib/python3.7/site-packages (from matplotlib->mmengine) (2.8.2) Requirement already satisfied: six>=1.5 in /environment/miniconda3/lib/python3.7/site-packages (from python-dateutil>=2.7->matplotlib->mmengine) (1.16.0) Requirement already satisfied: tomli>=1.0.0 in /environment/miniconda3/lib/python3.7/site-packages (from setuptools-scm>=4->matplotlib->mmengine) (1.2.2) Requirement already satisfied: setuptools in /environment/miniconda3/lib/python3.7/site-packages (from setuptools-scm>=4->matplotlib->mmengine) (52.0.0.post20210125) Requirement already satisfied: typing-extensions<5.0,>=4.0.0 in /environment/miniconda3/lib/python3.7/site-packages (from rich->mmengine) (4.0.1) Requirement already satisfied: pygments<3.0.0,>=2.13.0 in /environment/miniconda3/lib/python3.7/site-packages (from rich->mmengine) (2.15.1) Requirement already satisfied: markdown-it-py>=2.2.0 in /environment/miniconda3/lib/python3.7/site-packages (from rich->mmengine) (2.2.0) Requirement already satisfied: mdurl~=0.1 in /environment/miniconda3/lib/python3.7/site-packages (from markdown-it-py>=2.2.0->rich->mmengine) (0.1.2)
3. 安装 MMagic(源码方式) #
!rm -rf mmagic # 删除原有的 mmagic 文件夹(如有)
!git clone https://github.com/open-mmlab/mmagic.git # 下载 mmagic 源代码
正克隆到 'mmagic'... remote: Enumerating objects: 25648, done.[K remote: Counting objects: 100% (3612/3612), done.[K remote: Compressing objects: 100% (1571/1571), done.[K remote: Total 25648 (delta 2023), reused 3216 (delta 1988), pack-reused 22036[K 接收对象中: 100% (25648/25648), 21.60 MiB | 17.05 MiB/s, 完成. 处理 delta 中: 100% (17181/17181), 完成.
import os
os.chdir('mmagic')
!pip3 install -e .
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Obtaining file:///home/featurize/data/mmagic Collecting av Downloading https://pypi.tuna.tsinghua.edu.cn/packages/ac/9b/ace0ec1630646d9698eb4862f6d839558c6073449406e5b02f20bd17f81a/av-10.0.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (30.7 MB) [K |████████████████████████████████| 30.7 MB 69.9 MB/s eta 0:00:01 [?25hRequirement already satisfied: click in /environment/miniconda3/lib/python3.7/site-packages (from mmagic==1.0.2.dev0) (7.1.2) Collecting controlnet_aux Downloading https://pypi.tuna.tsinghua.edu.cn/packages/2f/9d/25f18e79a4f0de092e2f93bebc556291270af444bb9cd6395b4adb1906e3/controlnet_aux-0.0.5-py3-none-any.whl (231 kB) [K |████████████████████████████████| 231 kB 68.0 MB/s eta 0:00:01 [?25hCollecting diffusers>=0.12.0 Downloading https://pypi.tuna.tsinghua.edu.cn/packages/8b/a5/999e54be5ba410733e6e4b0f572dbe1006d40dc832c8aad1634e4ace4a29/diffusers-0.17.1-py3-none-any.whl (1.1 MB) [K |████████████████████████████████| 1.1 MB 74.9 MB/s eta 0:00:01 [?25hCollecting einops Downloading https://pypi.tuna.tsinghua.edu.cn/packages/68/24/b05452c986e8eff11f47e123a40798ae693f2fa1ed2f9546094997d2f6be/einops-0.6.1-py3-none-any.whl (42 kB) [K |████████████████████████████████| 42 kB 28.7 MB/s eta 0:00:01 [?25hCollecting face-alignment<=1.3.4 Downloading https://pypi.tuna.tsinghua.edu.cn/packages/c2/be/f4cbc7b2191e73415d869462178dce7e9b6c31fd7d8faec9594ce93f7d3b/face_alignment-1.3.4.tar.gz (26 kB) Collecting facexlib Downloading https://pypi.tuna.tsinghua.edu.cn/packages/36/7b/2147339dafe1c4800514c9c21ee4444f8b419ce51dfc7695220a8e0069a6/facexlib-0.3.0-py3-none-any.whl (59 kB) [K |████████████████████████████████| 59 kB 46.4 MB/s eta 0:00:01 [?25hCollecting lmdb Downloading https://pypi.tuna.tsinghua.edu.cn/packages/02/ba/e8dea9783b0fae7002d796da4e631cfe7bf0ffe113f340bddd461115547d/lmdb-1.4.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (294 kB) [K |████████████████████████████████| 294 kB 65.3 MB/s eta 0:00:01 [?25hCollecting lpips Downloading https://pypi.tuna.tsinghua.edu.cn/packages/9b/13/1df50c7925d9d2746702719f40e864f51ed66f307b20ad32392f1ad2bb87/lpips-0.1.4-py3-none-any.whl (53 kB) [K |████████████████████████████████| 53 kB 38.7 MB/s eta 0:00:01 [?25hCollecting mediapipe Downloading https://pypi.tuna.tsinghua.edu.cn/packages/e7/8f/ae3ee6f53a6a991627c1a3576ad2981f542b109a57943ef8b2f655877fbd/mediapipe-0.9.0.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (33.0 MB) [K |████████████████████████████████| 33.0 MB 58.1 MB/s eta 0:00:01 [?25hRequirement already satisfied: numpy in /environment/miniconda3/lib/python3.7/site-packages (from mmagic==1.0.2.dev0) (1.21.4) Requirement already satisfied: opencv-python!=4.5.5.62,!=4.5.5.64 in /environment/miniconda3/lib/python3.7/site-packages (from mmagic==1.0.2.dev0) (4.5.4.60) Requirement already satisfied: pandas in /environment/miniconda3/lib/python3.7/site-packages (from mmagic==1.0.2.dev0) (1.3.4) Requirement already satisfied: Pillow in /environment/miniconda3/lib/python3.7/site-packages (from mmagic==1.0.2.dev0) (8.4.0) Collecting resize_right Downloading https://pypi.tuna.tsinghua.edu.cn/packages/1d/08/c5c0640a08d7b373f1175c536462862054ee32145dae457c89916cd568d2/resize_right-0.0.2-py3-none-any.whl (8.9 kB) Requirement already satisfied: tensorboard in /environment/miniconda3/lib/python3.7/site-packages (from mmagic==1.0.2.dev0) (2.7.0) Collecting transformers>=4.27.4 Downloading https://pypi.tuna.tsinghua.edu.cn/packages/5b/0b/e45d26ccd28568013523e04f325432ea88a442b4e3020b757cf4361f0120/transformers-4.30.2-py3-none-any.whl (7.2 MB) [K |████████████████████████████████| 7.2 MB 79.3 MB/s eta 0:00:01 [?25hRequirement already satisfied: importlib-metadata in /environment/miniconda3/lib/python3.7/site-packages (from diffusers>=0.12.0->mmagic==1.0.2.dev0) (4.8.2) Collecting huggingface-hub>=0.13.2 Downloading https://pypi.tuna.tsinghua.edu.cn/packages/62/a2/8a416d167216403ceeef3aaf8c22b0c61b1ae571644473d67eb7fecbb69e/huggingface_hub-0.15.1-py3-none-any.whl (236 kB) [K |████████████████████████████████| 236 kB 78.7 MB/s eta 0:00:01 [?25hRequirement already satisfied: requests in /environment/miniconda3/lib/python3.7/site-packages (from diffusers>=0.12.0->mmagic==1.0.2.dev0) (2.24.0) Collecting regex!=2019.12.17 Downloading https://pypi.tuna.tsinghua.edu.cn/packages/9d/1e/8eb13233ac58edecdd58aa7de0d5b68fc04f7141891c1934036b0b34890a/regex-2023.6.3-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (755 kB) [K |████████████████████████████████| 755 kB 76.3 MB/s eta 0:00:01 [?25hCollecting filelock Downloading https://pypi.tuna.tsinghua.edu.cn/packages/00/45/ec3407adf6f6b5bf867a4462b2b0af27597a26bd3cd6e2534cb6ab029938/filelock-3.12.2-py3-none-any.whl (10 kB) Requirement already satisfied: torch in /environment/miniconda3/lib/python3.7/site-packages (from face-alignment<=1.3.4->mmagic==1.0.2.dev0) (1.10.1+cu113) Requirement already satisfied: scipy>=0.17 in /environment/miniconda3/lib/python3.7/site-packages (from face-alignment<=1.3.4->mmagic==1.0.2.dev0) (1.7.3) Requirement already satisfied: scikit-image in /environment/miniconda3/lib/python3.7/site-packages (from face-alignment<=1.3.4->mmagic==1.0.2.dev0) (0.19.0) Requirement already satisfied: tqdm in /environment/miniconda3/lib/python3.7/site-packages (from face-alignment<=1.3.4->mmagic==1.0.2.dev0) (4.61.2) Collecting numba Downloading https://pypi.tuna.tsinghua.edu.cn/packages/6b/b5/b0a0af320c43f2925c699e8613382d3669829b585717ef2d795a06187564/numba-0.56.4-cp37-cp37m-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (3.5 MB) [K |████████████████████████████████| 3.5 MB 77.5 MB/s eta 0:00:01 [?25hRequirement already satisfied: packaging>=20.9 in /environment/miniconda3/lib/python3.7/site-packages (from huggingface-hub>=0.13.2->diffusers>=0.12.0->mmagic==1.0.2.dev0) (21.3) Requirement already satisfied: pyyaml>=5.1 in /environment/miniconda3/lib/python3.7/site-packages (from huggingface-hub>=0.13.2->diffusers>=0.12.0->mmagic==1.0.2.dev0) (6.0) Requirement already satisfied: typing-extensions>=3.7.4.3 in /environment/miniconda3/lib/python3.7/site-packages (from huggingface-hub>=0.13.2->diffusers>=0.12.0->mmagic==1.0.2.dev0) (4.0.1) Collecting fsspec Downloading https://pypi.tuna.tsinghua.edu.cn/packages/bd/64/f0d369ede0ca54fdd520bdee5086dbaf0af81dac53a2ce847bd1ec6e0bf1/fsspec-2023.1.0-py3-none-any.whl (143 kB) [K |████████████████████████████████| 143 kB 82.7 MB/s eta 0:00:01 [?25hRequirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in /environment/miniconda3/lib/python3.7/site-packages (from packaging>=20.9->huggingface-hub>=0.13.2->diffusers>=0.12.0->mmagic==1.0.2.dev0) (3.0.6) Collecting tokenizers!=0.11.3,<0.14,>=0.11.1 Downloading https://pypi.tuna.tsinghua.edu.cn/packages/4d/40/ab3c3c705e0a8cbbe760c49302b407190201d96fe7dfeea37ccafa004da3/tokenizers-0.13.3-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.8 MB) [K |████████████████████████████████| 7.8 MB 68.1 MB/s eta 0:00:01 [?25hCollecting safetensors>=0.3.1 Downloading https://pypi.tuna.tsinghua.edu.cn/packages/7c/34/54c2207f5b4eaf9b455ab679d7aa9a1c0c13e159fc09a491507933b02ad1/safetensors-0.3.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB) [K |████████████████████████████████| 1.3 MB 77.9 MB/s eta 0:00:01 [?25hRequirement already satisfied: torchvision in /environment/miniconda3/lib/python3.7/site-packages (from controlnet_aux->mmagic==1.0.2.dev0) (0.11.2+cu113) Collecting timm Downloading https://pypi.tuna.tsinghua.edu.cn/packages/29/90/94f5deb8d76e24a89813aef95e8809ca8fd7414490428480eda19b133d4a/timm-0.9.2-py3-none-any.whl (2.2 MB) [K |████████████████████████████████| 2.2 MB 76.2 MB/s eta 0:00:01 [?25hCollecting filterpy Downloading https://pypi.tuna.tsinghua.edu.cn/packages/f6/1d/ac8914360460fafa1990890259b7fa5ef7ba4cd59014e782e4ab3ab144d8/filterpy-1.4.5.zip (177 kB) [K |████████████████████████████████| 177 kB 76.7 MB/s eta 0:00:01 [?25hRequirement already satisfied: matplotlib in /environment/miniconda3/lib/python3.7/site-packages (from filterpy->facexlib->mmagic==1.0.2.dev0) (3.5.0) Requirement already satisfied: zipp>=0.5 in /environment/miniconda3/lib/python3.7/site-packages (from importlib-metadata->diffusers>=0.12.0->mmagic==1.0.2.dev0) (3.6.0) Requirement already satisfied: python-dateutil>=2.7 in /environment/miniconda3/lib/python3.7/site-packages (from matplotlib->filterpy->facexlib->mmagic==1.0.2.dev0) (2.8.2) Requirement already satisfied: kiwisolver>=1.0.1 in /environment/miniconda3/lib/python3.7/site-packages (from matplotlib->filterpy->facexlib->mmagic==1.0.2.dev0) (1.3.2) Requirement already satisfied: cycler>=0.10 in /environment/miniconda3/lib/python3.7/site-packages (from matplotlib->filterpy->facexlib->mmagic==1.0.2.dev0) (0.11.0) Requirement already satisfied: fonttools>=4.22.0 in /environment/miniconda3/lib/python3.7/site-packages (from matplotlib->filterpy->facexlib->mmagic==1.0.2.dev0) (4.28.3) Requirement already satisfied: setuptools-scm>=4 in /environment/miniconda3/lib/python3.7/site-packages (from matplotlib->filterpy->facexlib->mmagic==1.0.2.dev0) (6.3.2) Requirement already satisfied: six>=1.5 in /environment/miniconda3/lib/python3.7/site-packages (from python-dateutil>=2.7->matplotlib->filterpy->facexlib->mmagic==1.0.2.dev0) (1.16.0) Requirement already satisfied: setuptools in /environment/miniconda3/lib/python3.7/site-packages (from setuptools-scm>=4->matplotlib->filterpy->facexlib->mmagic==1.0.2.dev0) (52.0.0.post20210125) Requirement already satisfied: tomli>=1.0.0 in /environment/miniconda3/lib/python3.7/site-packages (from setuptools-scm>=4->matplotlib->filterpy->facexlib->mmagic==1.0.2.dev0) (1.2.2) Requirement already satisfied: attrs>=19.1.0 in /environment/miniconda3/lib/python3.7/site-packages (from mediapipe->mmagic==1.0.2.dev0) (21.2.0) Collecting opencv-contrib-python Downloading https://pypi.tuna.tsinghua.edu.cn/packages/fb/89/8370c6864e518be9ca1b54a19b5daf398f4943041e1283ffa7ba0c66c0bd/opencv_contrib_python-4.7.0.72-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (67.9 MB) [K |████████████████████████████████| 67.9 MB 68.4 MB/s eta 0:00:01 [?25hRequirement already satisfied: protobuf<4,>=3.11 in /environment/miniconda3/lib/python3.7/site-packages (from mediapipe->mmagic==1.0.2.dev0) (3.19.1) Requirement already satisfied: absl-py in /environment/miniconda3/lib/python3.7/site-packages (from mediapipe->mmagic==1.0.2.dev0) (1.0.0) Requirement already satisfied: flatbuffers>=2.0 in /environment/miniconda3/lib/python3.7/site-packages (from mediapipe->mmagic==1.0.2.dev0) (2.0) Collecting llvmlite<0.40,>=0.39.0dev0 Downloading https://pypi.tuna.tsinghua.edu.cn/packages/6f/78/15e11f84531c3e4e078ed2faa4e6e078ef2a0c06c6275020bc10c3865e9c/llvmlite-0.39.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (34.6 MB) [K |████████████████████████████████| 34.6 MB 70.7 MB/s eta 0:00:01 [?25hRequirement already satisfied: pytz>=2017.3 in /environment/miniconda3/lib/python3.7/site-packages (from pandas->mmagic==1.0.2.dev0) (2021.3) Requirement already satisfied: chardet<4,>=3.0.2 in /environment/miniconda3/lib/python3.7/site-packages (from requests->diffusers>=0.12.0->mmagic==1.0.2.dev0) (3.0.4) Requirement already satisfied: certifi>=2017.4.17 in /environment/miniconda3/lib/python3.7/site-packages (from requests->diffusers>=0.12.0->mmagic==1.0.2.dev0) (2021.5.30) Requirement already satisfied: idna<3,>=2.5 in /environment/miniconda3/lib/python3.7/site-packages (from requests->diffusers>=0.12.0->mmagic==1.0.2.dev0) (2.10) Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /environment/miniconda3/lib/python3.7/site-packages (from requests->diffusers>=0.12.0->mmagic==1.0.2.dev0) (1.25.11) Requirement already satisfied: networkx>=2.2 in /environment/miniconda3/lib/python3.7/site-packages (from scikit-image->face-alignment<=1.3.4->mmagic==1.0.2.dev0) (2.6.3) Requirement already satisfied: PyWavelets>=1.1.1 in /environment/miniconda3/lib/python3.7/site-packages (from scikit-image->face-alignment<=1.3.4->mmagic==1.0.2.dev0) (1.2.0) Requirement already satisfied: imageio>=2.4.1 in /environment/miniconda3/lib/python3.7/site-packages (from scikit-image->face-alignment<=1.3.4->mmagic==1.0.2.dev0) (2.13.3) Requirement already satisfied: tifffile>=2019.7.26 in /environment/miniconda3/lib/python3.7/site-packages (from scikit-image->face-alignment<=1.3.4->mmagic==1.0.2.dev0) (2021.11.2) Requirement already satisfied: werkzeug>=0.11.15 in /environment/miniconda3/lib/python3.7/site-packages (from tensorboard->mmagic==1.0.2.dev0) (2.0.2) Requirement already satisfied: wheel>=0.26 in /environment/miniconda3/lib/python3.7/site-packages (from tensorboard->mmagic==1.0.2.dev0) (0.36.2) Requirement already satisfied: tensorboard-plugin-wit>=1.6.0 in /environment/miniconda3/lib/python3.7/site-packages (from tensorboard->mmagic==1.0.2.dev0) (1.8.0) Requirement already satisfied: google-auth-oauthlib<0.5,>=0.4.1 in /environment/miniconda3/lib/python3.7/site-packages (from tensorboard->mmagic==1.0.2.dev0) (0.4.6) Requirement already satisfied: grpcio>=1.24.3 in /environment/miniconda3/lib/python3.7/site-packages (from tensorboard->mmagic==1.0.2.dev0) (1.42.0) Requirement already satisfied: markdown>=2.6.8 in /environment/miniconda3/lib/python3.7/site-packages (from tensorboard->mmagic==1.0.2.dev0) (3.3.6) Requirement already satisfied: tensorboard-data-server<0.7.0,>=0.6.0 in /environment/miniconda3/lib/python3.7/site-packages (from tensorboard->mmagic==1.0.2.dev0) (0.6.1) Requirement already satisfied: google-auth<3,>=1.6.3 in /environment/miniconda3/lib/python3.7/site-packages (from tensorboard->mmagic==1.0.2.dev0) (2.3.3) Requirement already satisfied: pyasn1-modules>=0.2.1 in /environment/miniconda3/lib/python3.7/site-packages (from google-auth<3,>=1.6.3->tensorboard->mmagic==1.0.2.dev0) (0.2.8) Requirement already satisfied: cachetools<5.0,>=2.0.0 in /environment/miniconda3/lib/python3.7/site-packages (from google-auth<3,>=1.6.3->tensorboard->mmagic==1.0.2.dev0) (4.2.4) Requirement already satisfied: rsa<5,>=3.1.4 in /environment/miniconda3/lib/python3.7/site-packages (from google-auth<3,>=1.6.3->tensorboard->mmagic==1.0.2.dev0) (4.8) Requirement already satisfied: requests-oauthlib>=0.7.0 in /environment/miniconda3/lib/python3.7/site-packages (from google-auth-oauthlib<0.5,>=0.4.1->tensorboard->mmagic==1.0.2.dev0) (1.3.0) Requirement already satisfied: pyasn1<0.5.0,>=0.4.6 in /environment/miniconda3/lib/python3.7/site-packages (from pyasn1-modules>=0.2.1->google-auth<3,>=1.6.3->tensorboard->mmagic==1.0.2.dev0) (0.4.8) Requirement already satisfied: oauthlib>=3.0.0 in /environment/miniconda3/lib/python3.7/site-packages (from requests-oauthlib>=0.7.0->google-auth-oauthlib<0.5,>=0.4.1->tensorboard->mmagic==1.0.2.dev0) (3.1.1) Building wheels for collected packages: face-alignment, filterpy Building wheel for face-alignment (setup.py) ... [?25ldone [?25h Created wheel for face-alignment: filename=face_alignment-1.3.4-py2.py3-none-any.whl size=27859 sha256=c540944bc1cf9be756c498f015cf511d3dd7604c166b4faf5276f2c158c5ccc5 Stored in directory: /home/featurize/.cache/pip/wheels/96/80/48/dfa7cf9223b966830b04042ebbc4def4056077fdbd992ddd2b Building wheel for filterpy (setup.py) ... [?25ldone [?25h Created wheel for filterpy: filename=filterpy-1.4.5-py3-none-any.whl size=110451 sha256=ddb871aa4520bfa03fb8d0590f188e691552de2b2d6841d10cc7ac932268d433 Stored in directory: /home/featurize/.cache/pip/wheels/60/79/e4/a6df5e482863f893b95d3e95627d744cb2e57b26b44ec20b22 Successfully built face-alignment filterpy Installing collected packages: fsspec, filelock, safetensors, llvmlite, huggingface-hub, tokenizers, timm, regex, opencv-contrib-python, numba, filterpy, einops, transformers, resize-right, mediapipe, lpips, lmdb, facexlib, face-alignment, diffusers, controlnet-aux, av, mmagic Running setup.py develop for mmagic Successfully installed av-10.0.0 controlnet-aux-0.0.5 diffusers-0.17.1 einops-0.6.1 face-alignment-1.3.4 facexlib-0.3.0 filelock-3.12.2 filterpy-1.4.5 fsspec-2023.1.0 huggingface-hub-0.15.1 llvmlite-0.39.1 lmdb-1.4.1 lpips-0.1.4 mediapipe-0.9.0.1 mmagic-1.0.2.dev0 numba-0.56.4 opencv-contrib-python-4.7.0.72 regex-2023.6.3 resize-right-0.0.2 safetensors-0.3.1 timm-0.9.2 tokenizers-0.13.3 transformers-4.30.2
4. 检查安装 #
# 检查时报错:
# AttributeError: module 'cv2' has no attribute 'gapi_wip_gst_GStreamerPipeline'
# 解决如下:
!pip install opencv-python==4.6.0.66
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Requirement already satisfied: opencv-python==4.6.0.66 in /environment/miniconda3/lib/python3.7/site-packages (4.6.0.66) Requirement already satisfied: numpy>=1.14.5 in /environment/miniconda3/lib/python3.7/site-packages (from opencv-python==4.6.0.66) (1.21.4)
print('=======Pytorch=======')
# 检查 Pytorch
import torch, torchvision
print('Pytorch 版本', torch.__version__)
print('CUDA 是否可用',torch.cuda.is_available())
print('========MMCV=========')
# 检查 mmcv
import mmcv
from mmcv.ops import get_compiling_cuda_version, get_compiler_version
print('MMCV版本', mmcv.__version__)
print('CUDA版本', get_compiling_cuda_version())
print('编译器版本', get_compiler_version())
print('========MMagic=========')
# 检查 mmagic
import mmagic
print('MMagic版本', mmagic.__version__)
=======Pytorch======= Pytorch 版本 1.10.1+cu113 CUDA 是否可用 True ========MMCV========= MMCV版本 2.0.0 CUDA版本 11.3 编译器版本 GCC 9.3 ========MMagic========= MMagic版本 1.0.2dev0
5. 安装其他工具 #
!pip install opencv-python pillow matplotlib seaborn tqdm -i https://pypi.tuna.tsinghua.edu.cn/simple
!pip install clip transformers gradio 'httpx[socks]' diffusers==0.14.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
!mim install 'mmdet>=3.0.0'
# 载入模型的步骤中提示安装:
!pip install accelerate
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Requirement already satisfied: opencv-python in /environment/miniconda3/lib/python3.7/site-packages (4.6.0.66) Requirement already satisfied: pillow in /environment/miniconda3/lib/python3.7/site-packages (8.4.0) Requirement already satisfied: matplotlib in /environment/miniconda3/lib/python3.7/site-packages (3.5.0) Collecting seaborn Downloading https://pypi.tuna.tsinghua.edu.cn/packages/8f/2e/17bbb83fbf102687bb2aa3d808add39da820a7698159302a1a69bb82e01c/seaborn-0.12.2-py3-none-any.whl (293 kB) [K |████████████████████████████████| 293 kB 59.8 MB/s eta 0:00:01 [?25hRequirement already satisfied: tqdm in /environment/miniconda3/lib/python3.7/site-packages (4.61.2) Requirement already satisfied: numpy>=1.14.5 in /environment/miniconda3/lib/python3.7/site-packages (from opencv-python) (1.21.4) Requirement already satisfied: fonttools>=4.22.0 in /environment/miniconda3/lib/python3.7/site-packages (from matplotlib) (4.28.3) Requirement already satisfied: cycler>=0.10 in /environment/miniconda3/lib/python3.7/site-packages (from matplotlib) (0.11.0) Requirement already satisfied: kiwisolver>=1.0.1 in /environment/miniconda3/lib/python3.7/site-packages (from matplotlib) (1.3.2) Requirement already satisfied: setuptools-scm>=4 in /environment/miniconda3/lib/python3.7/site-packages (from matplotlib) (6.3.2) Requirement already satisfied: pyparsing>=2.2.1 in /environment/miniconda3/lib/python3.7/site-packages (from matplotlib) (3.0.6) Requirement already satisfied: packaging>=20.0 in /environment/miniconda3/lib/python3.7/site-packages (from matplotlib) (21.3) Requirement already satisfied: python-dateutil>=2.7 in /environment/miniconda3/lib/python3.7/site-packages (from matplotlib) (2.8.2) Requirement already satisfied: six>=1.5 in /environment/miniconda3/lib/python3.7/site-packages (from python-dateutil>=2.7->matplotlib) (1.16.0) Requirement already satisfied: tomli>=1.0.0 in /environment/miniconda3/lib/python3.7/site-packages (from setuptools-scm>=4->matplotlib) (1.2.2) Requirement already satisfied: setuptools in /environment/miniconda3/lib/python3.7/site-packages (from setuptools-scm>=4->matplotlib) (52.0.0.post20210125) Requirement already satisfied: typing_extensions in /environment/miniconda3/lib/python3.7/site-packages (from seaborn) (4.0.1) Requirement already satisfied: pandas>=0.25 in /environment/miniconda3/lib/python3.7/site-packages (from seaborn) (1.3.4) Requirement already satisfied: pytz>=2017.3 in /environment/miniconda3/lib/python3.7/site-packages (from pandas>=0.25->seaborn) (2021.3) Installing collected packages: seaborn Successfully installed seaborn-0.12.2 Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Collecting clip Downloading https://pypi.tuna.tsinghua.edu.cn/packages/58/dc/12bf8888635ade4de57565dca75909a809d1da6ec341eacd546028a73ab9/clip-0.2.0.tar.gz (5.5 kB) Requirement already satisfied: transformers in /environment/miniconda3/lib/python3.7/site-packages (4.30.2) Collecting gradio Downloading https://pypi.tuna.tsinghua.edu.cn/packages/29/e9/592634ca97719735608b0cf92b05e5061cfaaa0e77d0c1ed24017273b525/gradio-3.34.0-py3-none-any.whl (20.0 MB) [K |████████████████████████████████| 20.0 MB 64.1 MB/s eta 0:00:01 [?25hCollecting httpx[socks] Downloading https://pypi.tuna.tsinghua.edu.cn/packages/ec/91/e41f64f03d2a13aee7e8c819d82ee3aa7cdc484d18c0ae859742597d5aa0/httpx-0.24.1-py3-none-any.whl (75 kB) [K |████████████████████████████████| 75 kB 60.0 MB/s eta 0:00:01 [?25hCollecting diffusers==0.14.0 Downloading https://pypi.tuna.tsinghua.edu.cn/packages/eb/b4/5f719d41ebd5dc1c75a992e875cf7a8d402fb4acfe373eb04e4b7d805123/diffusers-0.14.0-py3-none-any.whl (737 kB) [K |████████████████████████████████| 737 kB 74.7 MB/s eta 0:00:01 [?25hRequirement already satisfied: importlib-metadata in /environment/miniconda3/lib/python3.7/site-packages (from diffusers==0.14.0) (4.8.2) Requirement already satisfied: requests in /environment/miniconda3/lib/python3.7/site-packages (from diffusers==0.14.0) (2.24.0) Requirement already satisfied: numpy in /environment/miniconda3/lib/python3.7/site-packages (from diffusers==0.14.0) (1.21.4) Requirement already satisfied: huggingface-hub>=0.10.0 in /environment/miniconda3/lib/python3.7/site-packages (from diffusers==0.14.0) (0.15.1) Requirement already satisfied: regex!=2019.12.17 in /environment/miniconda3/lib/python3.7/site-packages (from diffusers==0.14.0) (2023.6.3) Requirement already satisfied: filelock in /environment/miniconda3/lib/python3.7/site-packages (from diffusers==0.14.0) (3.12.2) Requirement already satisfied: Pillow in /environment/miniconda3/lib/python3.7/site-packages (from diffusers==0.14.0) (8.4.0) Requirement already satisfied: fsspec in /environment/miniconda3/lib/python3.7/site-packages (from huggingface-hub>=0.10.0->diffusers==0.14.0) (2023.1.0) Requirement already satisfied: pyyaml>=5.1 in /environment/miniconda3/lib/python3.7/site-packages (from huggingface-hub>=0.10.0->diffusers==0.14.0) (6.0) Requirement already satisfied: packaging>=20.9 in /environment/miniconda3/lib/python3.7/site-packages (from huggingface-hub>=0.10.0->diffusers==0.14.0) (21.3) Requirement already satisfied: tqdm>=4.42.1 in /environment/miniconda3/lib/python3.7/site-packages (from huggingface-hub>=0.10.0->diffusers==0.14.0) (4.61.2) Requirement already satisfied: typing-extensions>=3.7.4.3 in /environment/miniconda3/lib/python3.7/site-packages (from huggingface-hub>=0.10.0->diffusers==0.14.0) (4.0.1) Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in /environment/miniconda3/lib/python3.7/site-packages (from packaging>=20.9->huggingface-hub>=0.10.0->diffusers==0.14.0) (3.0.6) Requirement already satisfied: safetensors>=0.3.1 in /environment/miniconda3/lib/python3.7/site-packages (from transformers) (0.3.1) Requirement already satisfied: tokenizers!=0.11.3,<0.14,>=0.11.1 in /environment/miniconda3/lib/python3.7/site-packages (from transformers) (0.13.3) Collecting altair>=4.2.0 Downloading https://pypi.tuna.tsinghua.edu.cn/packages/b2/20/5c3b89d6f8d9938325a9330793438389e0dc94c34d921f6da35ec62095f3/altair-5.0.1-py3-none-any.whl (471 kB) [K |████████████████████████████████| 471 kB 59.1 MB/s eta 0:00:01 [?25hRequirement already satisfied: markupsafe in /environment/miniconda3/lib/python3.7/site-packages (from gradio) (2.0.1) Collecting semantic-version Downloading https://pypi.tuna.tsinghua.edu.cn/packages/6a/23/8146aad7d88f4fcb3a6218f41a60f6c2d4e3a72de72da1825dc7c8f7877c/semantic_version-2.10.0-py2.py3-none-any.whl (15 kB) Requirement already satisfied: matplotlib in /environment/miniconda3/lib/python3.7/site-packages (from gradio) (3.5.0) Collecting ffmpy Downloading https://pypi.tuna.tsinghua.edu.cn/packages/bf/e2/947df4b3d666bfdd2b0c6355d215c45d2d40f929451cb29a8a2995b29788/ffmpy-0.3.0.tar.gz (4.8 kB) Collecting mdit-py-plugins<=0.3.3 Downloading https://pypi.tuna.tsinghua.edu.cn/packages/33/eb/c358112e8265f827cf8228eda36cf2a720ad933f5ca66f47f808edf4bb34/mdit_py_plugins-0.3.3-py3-none-any.whl (50 kB) [K |████████████████████████████████| 50 kB 41.9 MB/s eta 0:00:01 [?25hCollecting gradio-client>=0.2.6 Downloading https://pypi.tuna.tsinghua.edu.cn/packages/0b/bf/888e47724dda69febd2690a95dedbe8ee09023009786492c13837f63c56e/gradio_client-0.2.6-py3-none-any.whl (288 kB) [K |████████████████████████████████| 288 kB 55.3 MB/s eta 0:00:01 [?25hRequirement already satisfied: markdown-it-py[linkify]>=2.0.0 in /environment/miniconda3/lib/python3.7/site-packages (from gradio) (2.2.0) Requirement already satisfied: aiohttp in /environment/miniconda3/lib/python3.7/site-packages (from gradio) (3.7.4) Collecting aiofiles Downloading https://pypi.tuna.tsinghua.edu.cn/packages/a8/76/635aa4f210d46ca105bfedd42d41f649b91d3e58422912726fc5e7965442/aiofiles-23.1.0-py3-none-any.whl (14 kB) Requirement already satisfied: pandas in /environment/miniconda3/lib/python3.7/site-packages (from gradio) (1.3.4) Collecting pydantic Downloading https://pypi.tuna.tsinghua.edu.cn/packages/0e/7a/6d5d0cd7155a9625a78860698b2efe992eb9539eeddbeca099e34b0b0bb5/pydantic-1.10.9-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.1 MB) [K |████████████████████████████████| 3.1 MB 62.0 MB/s eta 0:00:01 [?25hCollecting pydub Downloading https://pypi.tuna.tsinghua.edu.cn/packages/a6/53/d78dc063216e62fc55f6b2eebb447f6a4b0a59f55c8406376f76bf959b08/pydub-0.25.1-py2.py3-none-any.whl (32 kB) Collecting websockets>=10.0 Downloading https://pypi.tuna.tsinghua.edu.cn/packages/36/19/0da435afb26a6c47c0c045a82e414912aa2ac10de5721276a342bd9fdfee/websockets-11.0.3-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (129 kB) [K |████████████████████████████████| 129 kB 45.2 MB/s eta 0:00:01 [?25hCollecting fastapi Downloading https://pypi.tuna.tsinghua.edu.cn/packages/04/af/1749185fe149662b1f0af3bea74ab0620294752366306cd6098fdb52eafa/fastapi-0.97.0-py3-none-any.whl (56 kB) [K |████████████████████████████████| 56 kB 57.4 MB/s eta 0:00:01 [?25hCollecting orjson Downloading https://pypi.tuna.tsinghua.edu.cn/packages/43/e6/21a8e4701aa5cb00ca70c9b2e10080ca7d52c83ee918ad8f2476ae092cbb/orjson-3.9.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (136 kB) [K |████████████████████████████████| 136 kB 60.3 MB/s eta 0:00:01 [?25hRequirement already satisfied: pygments>=2.12.0 in /environment/miniconda3/lib/python3.7/site-packages (from gradio) (2.15.1) Collecting uvicorn>=0.14.0 Downloading https://pypi.tuna.tsinghua.edu.cn/packages/ad/bd/d47ee02312640fcf26c7e1c807402d5c5eab468571153a94ec8f7ada0e46/uvicorn-0.22.0-py3-none-any.whl (58 kB) [K |████████████████████████████████| 58 kB 68.2 MB/s eta 0:00:01 [?25hRequirement already satisfied: jinja2 in /environment/miniconda3/lib/python3.7/site-packages (from gradio) (3.0.3) Collecting python-multipart Downloading https://pypi.tuna.tsinghua.edu.cn/packages/b4/ff/b1e11d8bffb5e0e1b6d27f402eeedbeb9be6df2cdbc09356a1ae49806dbf/python_multipart-0.0.6-py3-none-any.whl (45 kB) [K |████████████████████████████████| 45 kB 48.7 MB/s eta 0:00:01 [?25hRequirement already satisfied: jsonschema>=3.0 in /environment/miniconda3/lib/python3.7/site-packages (from altair>=4.2.0->gradio) (4.2.1) Collecting toolz Downloading https://pypi.tuna.tsinghua.edu.cn/packages/7f/5c/922a3508f5bda2892be3df86c74f9cf1e01217c2b1f8a0ac4841d903e3e9/toolz-0.12.0-py3-none-any.whl (55 kB) [K |████████████████████████████████| 55 kB 53.8 MB/s eta 0:00:01 [?25hRequirement already satisfied: attrs>=17.4.0 in /environment/miniconda3/lib/python3.7/site-packages (from jsonschema>=3.0->altair>=4.2.0->gradio) (21.2.0) Requirement already satisfied: pyrsistent!=0.17.0,!=0.17.1,!=0.17.2,>=0.14.0 in /environment/miniconda3/lib/python3.7/site-packages (from jsonschema>=3.0->altair>=4.2.0->gradio) (0.18.0) Requirement already satisfied: importlib-resources>=1.4.0 in /environment/miniconda3/lib/python3.7/site-packages (from jsonschema>=3.0->altair>=4.2.0->gradio) (5.4.0) Requirement already satisfied: zipp>=3.1.0 in /environment/miniconda3/lib/python3.7/site-packages (from importlib-resources>=1.4.0->jsonschema>=3.0->altair>=4.2.0->gradio) (3.6.0) Requirement already satisfied: mdurl~=0.1 in /environment/miniconda3/lib/python3.7/site-packages (from markdown-it-py[linkify]>=2.0.0->gradio) (0.1.2) Collecting linkify-it-py<3,>=1 Downloading https://pypi.tuna.tsinghua.edu.cn/packages/1f/1a/16b0d2f66601ba3081f1d4177087c79fd1f11d17706ee01d373e4ba8e00d/linkify_it_py-2.0.2-py3-none-any.whl (19 kB) Collecting uc-micro-py Downloading https://pypi.tuna.tsinghua.edu.cn/packages/d1/1c/5aeb94aa980da111e4fd0c0fbe5ad95ed5bf9bd957f8e2a6178b85ff4da8/uc_micro_py-1.0.2-py3-none-any.whl (6.2 kB) Requirement already satisfied: pytz>=2017.3 in /environment/miniconda3/lib/python3.7/site-packages (from pandas->gradio) (2021.3) Requirement already satisfied: python-dateutil>=2.7.3 in /environment/miniconda3/lib/python3.7/site-packages (from pandas->gradio) (2.8.2) Requirement already satisfied: six>=1.5 in /environment/miniconda3/lib/python3.7/site-packages (from python-dateutil>=2.7.3->pandas->gradio) (1.16.0) Requirement already satisfied: click>=7.0 in /environment/miniconda3/lib/python3.7/site-packages (from uvicorn>=0.14.0->gradio) (7.1.2) Collecting h11>=0.8 Downloading https://pypi.tuna.tsinghua.edu.cn/packages/95/04/ff642e65ad6b90db43e668d70ffb6736436c7ce41fcc549f4e9472234127/h11-0.14.0-py3-none-any.whl (58 kB) [K |████████████████████████████████| 58 kB 55.2 MB/s eta 0:00:01 [?25hRequirement already satisfied: sniffio in /environment/miniconda3/lib/python3.7/site-packages (from httpx[socks]) (1.2.0) Requirement already satisfied: certifi in /environment/miniconda3/lib/python3.7/site-packages (from httpx[socks]) (2021.5.30) Requirement already satisfied: idna in /environment/miniconda3/lib/python3.7/site-packages (from httpx[socks]) (2.10) Collecting httpcore<0.18.0,>=0.15.0 Downloading https://pypi.tuna.tsinghua.edu.cn/packages/4d/32/b908f673ccef12b6425b848a541264ee3d95f5f571f18f6ab0d8c311442e/httpcore-0.17.2-py3-none-any.whl (72 kB) [K |████████████████████████████████| 72 kB 28.8 MB/s eta 0:00:01 [?25hRequirement already satisfied: anyio<5.0,>=3.0 in /environment/miniconda3/lib/python3.7/site-packages (from httpcore<0.18.0,>=0.15.0->httpx[socks]) (3.4.0) Requirement already satisfied: async-timeout<4.0,>=3.0 in /environment/miniconda3/lib/python3.7/site-packages (from aiohttp->gradio) (3.0.1) Requirement already satisfied: yarl<2.0,>=1.0 in /environment/miniconda3/lib/python3.7/site-packages (from aiohttp->gradio) (1.7.2) Requirement already satisfied: multidict<7.0,>=4.5 in /environment/miniconda3/lib/python3.7/site-packages (from aiohttp->gradio) (5.2.0) Requirement already satisfied: chardet<4.0,>=2.0 in /environment/miniconda3/lib/python3.7/site-packages (from aiohttp->gradio) (3.0.4) Collecting starlette<0.28.0,>=0.27.0 Downloading https://pypi.tuna.tsinghua.edu.cn/packages/58/f8/e2cca22387965584a409795913b774235752be4176d276714e15e1a58884/starlette-0.27.0-py3-none-any.whl (66 kB) [K |████████████████████████████████| 66 kB 45.3 MB/s eta 0:00:01 [?25hCollecting typing-extensions>=3.7.4.3 Downloading https://pypi.tuna.tsinghua.edu.cn/packages/5f/86/d9b1518d8e75b346a33eb59fa31bdbbee11459a7e2cc5be502fa779e96c5/typing_extensions-4.6.3-py3-none-any.whl (31 kB) Collecting socksio==1.* Downloading https://pypi.tuna.tsinghua.edu.cn/packages/37/c3/6eeb6034408dac0fa653d126c9204ade96b819c936e136c5e8a6897eee9c/socksio-1.0.0-py3-none-any.whl (12 kB) Requirement already satisfied: setuptools-scm>=4 in /environment/miniconda3/lib/python3.7/site-packages (from matplotlib->gradio) (6.3.2) Requirement already satisfied: kiwisolver>=1.0.1 in /environment/miniconda3/lib/python3.7/site-packages (from matplotlib->gradio) (1.3.2) Requirement already satisfied: cycler>=0.10 in /environment/miniconda3/lib/python3.7/site-packages (from matplotlib->gradio) (0.11.0) Requirement already satisfied: fonttools>=4.22.0 in /environment/miniconda3/lib/python3.7/site-packages (from matplotlib->gradio) (4.28.3) Requirement already satisfied: tomli>=1.0.0 in /environment/miniconda3/lib/python3.7/site-packages (from setuptools-scm>=4->matplotlib->gradio) (1.2.2) Requirement already satisfied: setuptools in /environment/miniconda3/lib/python3.7/site-packages (from setuptools-scm>=4->matplotlib->gradio) (52.0.0.post20210125) Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /environment/miniconda3/lib/python3.7/site-packages (from requests->diffusers==0.14.0) (1.25.11) Building wheels for collected packages: clip, ffmpy Building wheel for clip (setup.py) ... [?25ldone [?25h Created wheel for clip: filename=clip-0.2.0-py3-none-any.whl size=7032 sha256=00b887369073d3a815f97e6615a089daae4b9cee198f880123f852e7413ea5ac Stored in directory: /home/featurize/.cache/pip/wheels/a5/6a/47/8bb23e290d517b150d0fd7cf35724bbdd91f8f641b225e32f9 Building wheel for ffmpy (setup.py) ... [?25ldone [?25h Created wheel for ffmpy: filename=ffmpy-0.3.0-py3-none-any.whl size=4709 sha256=3f740881f65219460ec20b5bc170b27bb84ad8b5d5b222a8ce87df547de5f16b Stored in directory: /home/featurize/.cache/pip/wheels/62/7c/42/a687fe08441fbec0347563a6d0dcbbd32b34eb67ce39d5aaab Successfully built clip ffmpy Installing collected packages: typing-extensions, h11, uc-micro-py, httpcore, websockets, toolz, starlette, pydantic, linkify-it-py, httpx, uvicorn, socksio, semantic-version, python-multipart, pydub, orjson, mdit-py-plugins, gradio-client, ffmpy, fastapi, altair, aiofiles, gradio, diffusers, clip Attempting uninstall: typing-extensions Found existing installation: typing-extensions 4.0.1 Uninstalling typing-extensions-4.0.1: Successfully uninstalled typing-extensions-4.0.1 Attempting uninstall: diffusers Found existing installation: diffusers 0.17.1 Uninstalling diffusers-0.17.1: Successfully uninstalled diffusers-0.17.1 Successfully installed aiofiles-23.1.0 altair-5.0.1 clip-0.2.0 diffusers-0.14.0 fastapi-0.97.0 ffmpy-0.3.0 gradio-3.34.0 gradio-client-0.2.6 h11-0.14.0 httpcore-0.17.2 httpx-0.24.1 linkify-it-py-2.0.2 mdit-py-plugins-0.3.3 orjson-3.9.1 pydantic-1.10.9 pydub-0.25.1 python-multipart-0.0.6 semantic-version-2.10.0 socksio-1.0.0 starlette-0.27.0 toolz-0.12.0 typing-extensions-4.6.3 uc-micro-py-1.0.2 uvicorn-0.22.0 websockets-11.0.3 Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Looking in links: https://download.openmmlab.com/mmcv/dist/cu113/torch1.10.0/index.html Collecting mmdet>=3.0.0 Downloading https://pypi.tuna.tsinghua.edu.cn/packages/2d/6a/1f97b0f476f64ed46dedc6b235ba51a5ef4c32db65702bf04d7a7de4ad51/mmdet-3.0.0-py3-none-any.whl (1.7 MB) [K |████████████████████████████████| 1.7 MB 61.8 MB/s eta 0:00:01 [?25hRequirement already satisfied: scipy in /environment/miniconda3/lib/python3.7/site-packages (from mmdet>=3.0.0) (1.7.3) Requirement already satisfied: numpy in /environment/miniconda3/lib/python3.7/site-packages (from mmdet>=3.0.0) (1.21.4) Requirement already satisfied: matplotlib in /environment/miniconda3/lib/python3.7/site-packages (from mmdet>=3.0.0) (3.5.0) Collecting shapely Downloading https://pypi.tuna.tsinghua.edu.cn/packages/1d/a4/931d0780f31f3ea8c4f9ef6464a2825137c5241e6707a5fb03bef760a7eb/shapely-2.0.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.3 MB) [K |████████████████████████████████| 2.3 MB 60.7 MB/s eta 0:00:01 [?25hRequirement already satisfied: six in /environment/miniconda3/lib/python3.7/site-packages (from mmdet>=3.0.0) (1.16.0) Collecting terminaltables Downloading https://pypi.tuna.tsinghua.edu.cn/packages/c4/fb/ea621e0a19733e01fe4005d46087d383693c0f4a8f824b47d8d4122c87e0/terminaltables-3.1.10-py2.py3-none-any.whl (15 kB) Collecting pycocotools Downloading https://pypi.tuna.tsinghua.edu.cn/packages/ef/c6/90220be3b39fbc4cbd203775ca47dd8dc97fae06fbd2b500637395621b7c/pycocotools-2.0.6.tar.gz (24 kB) Installing build dependencies ... [?25ldone [?25h Getting requirements to build wheel ... [?25ldone [?25h Preparing wheel metadata ... [?25ldone [?25hRequirement already satisfied: mmengine<1.0.0,>=0.7.1 in /environment/miniconda3/lib/python3.7/site-packages (from mmdet>=3.0.0) (0.7.4) Requirement already satisfied: mmcv<2.1.0,>=2.0.0rc4 in /environment/miniconda3/lib/python3.7/site-packages (from mmdet>=3.0.0) (2.0.0) Requirement already satisfied: pyyaml in /environment/miniconda3/lib/python3.7/site-packages (from mmcv<2.1.0,>=2.0.0rc4->mmdet>=3.0.0) (6.0) Requirement already satisfied: yapf in /environment/miniconda3/lib/python3.7/site-packages (from mmcv<2.1.0,>=2.0.0rc4->mmdet>=3.0.0) (0.31.0) Requirement already satisfied: addict in /environment/miniconda3/lib/python3.7/site-packages (from mmcv<2.1.0,>=2.0.0rc4->mmdet>=3.0.0) (2.4.0) Requirement already satisfied: Pillow in /environment/miniconda3/lib/python3.7/site-packages (from mmcv<2.1.0,>=2.0.0rc4->mmdet>=3.0.0) (8.4.0) Requirement already satisfied: packaging in /environment/miniconda3/lib/python3.7/site-packages (from mmcv<2.1.0,>=2.0.0rc4->mmdet>=3.0.0) (21.3) Requirement already satisfied: opencv-python>=3 in /environment/miniconda3/lib/python3.7/site-packages (from mmcv<2.1.0,>=2.0.0rc4->mmdet>=3.0.0) (4.6.0.66) Requirement already satisfied: termcolor in /environment/miniconda3/lib/python3.7/site-packages (from mmengine<1.0.0,>=0.7.1->mmdet>=3.0.0) (1.1.0) Requirement already satisfied: rich in /environment/miniconda3/lib/python3.7/site-packages (from mmengine<1.0.0,>=0.7.1->mmdet>=3.0.0) (13.4.2) Requirement already satisfied: pyparsing>=2.2.1 in /environment/miniconda3/lib/python3.7/site-packages (from matplotlib->mmdet>=3.0.0) (3.0.6) Requirement already satisfied: fonttools>=4.22.0 in /environment/miniconda3/lib/python3.7/site-packages (from matplotlib->mmdet>=3.0.0) (4.28.3) Requirement already satisfied: setuptools-scm>=4 in /environment/miniconda3/lib/python3.7/site-packages (from matplotlib->mmdet>=3.0.0) (6.3.2) Requirement already satisfied: cycler>=0.10 in /environment/miniconda3/lib/python3.7/site-packages (from matplotlib->mmdet>=3.0.0) (0.11.0) Requirement already satisfied: python-dateutil>=2.7 in /environment/miniconda3/lib/python3.7/site-packages (from matplotlib->mmdet>=3.0.0) (2.8.2) Requirement already satisfied: kiwisolver>=1.0.1 in /environment/miniconda3/lib/python3.7/site-packages (from matplotlib->mmdet>=3.0.0) (1.3.2) Requirement already satisfied: setuptools in /environment/miniconda3/lib/python3.7/site-packages (from setuptools-scm>=4->matplotlib->mmdet>=3.0.0) (52.0.0.post20210125) Requirement already satisfied: tomli>=1.0.0 in /environment/miniconda3/lib/python3.7/site-packages (from setuptools-scm>=4->matplotlib->mmdet>=3.0.0) (1.2.2) Requirement already satisfied: typing-extensions<5.0,>=4.0.0 in /environment/miniconda3/lib/python3.7/site-packages (from rich->mmengine<1.0.0,>=0.7.1->mmdet>=3.0.0) (4.6.3) Requirement already satisfied: markdown-it-py>=2.2.0 in /environment/miniconda3/lib/python3.7/site-packages (from rich->mmengine<1.0.0,>=0.7.1->mmdet>=3.0.0) (2.2.0) Requirement already satisfied: pygments<3.0.0,>=2.13.0 in /environment/miniconda3/lib/python3.7/site-packages (from rich->mmengine<1.0.0,>=0.7.1->mmdet>=3.0.0) (2.15.1) Requirement already satisfied: mdurl~=0.1 in /environment/miniconda3/lib/python3.7/site-packages (from markdown-it-py>=2.2.0->rich->mmengine<1.0.0,>=0.7.1->mmdet>=3.0.0) (0.1.2) Building wheels for collected packages: pycocotools Building wheel for pycocotools (PEP 517) ... [?25ldone [?25h Created wheel for pycocotools: filename=pycocotools-2.0.6-cp37-cp37m-linux_x86_64.whl size=374083 sha256=07b6c0a843c38bba169a63ea576a10dc70eb0af9ba0a9aa1b260a95a5c7d7551 Stored in directory: /home/featurize/.cache/pip/wheels/f8/94/70/046149e666bd5812b7de6b87a28dcef238f7162f4108e0b3d8 Successfully built pycocotools Installing collected packages: terminaltables, shapely, pycocotools, mmdet Successfully installed mmdet-3.0.0 pycocotools-2.0.6 shapely-2.0.1 terminaltables-3.1.10
二、图生图-ControlNet-Canny #
1. 进入目录 #
import os
os.chdir('mmagic')
os.getcwd()
'/home/featurize/data/mmagic'
2. 载入ControlNet模型 #
# 导入工具包
import cv2
import numpy as np
import mmcv
from mmengine import Config
from PIL import Image
from mmagic.registry import MODELS
from mmagic.utils import register_all_modules
register_all_modules()
# 载入模型
cfg = Config.fromfile('configs/controlnet/controlnet-canny.py')
controlnet = MODELS.build(cfg.model).cuda()
06/18 15:08:41 - mmengine - [4m[37mINFO[0m - Set model dtype to 'torch.float32'. 06/18 15:08:47 - mmengine - [4m[37mINFO[0m - Creating runwayml/stable-diffusion-v1-5 by 'HuggingFace' Do not support Xformers. Please install Xformers first. The program will run without Xformers. 06/18 15:08:49 - mmengine - [4m[37mINFO[0m - Set model dtype to 'torch.float32'. Do not support Xformers. Please install Xformers first. The program will run without Xformers.
3. 准备边缘图及 Prompt #
# 导入原始图片
import matplotlib.pyplot as plt
%matplotlib inline
img_path = '00.jpg'
control_img = mmcv.imread(img_path)
plt.imshow(control_img[:, :, ::-1])
plt.show()
# 生成边缘图
control = cv2.Canny(control_img, 100, 200)
control = control[:, :, None]
control = np.concatenate([control] * 3, axis=2)
control = Image.fromarray(control)
plt.imshow(control)
plt.show()
使用 ChatGPT 生成提示词:
Q: 列举四种典型的interior design style,用英文输出。
A: Sure! Here are four typical interior design styles:
- Scandinavian: This style is characterized by simplicity, minimalism, and functionality. It often features light colors, natural materials, and clean lines.
- Industrial: Industrial design is inspired by old factories and warehouses. It incorporates raw materials like exposed brick, metal, and concrete. It often includes open spaces, high ceilings, and a combination of vintage and modern elements.
- Bohemian: Bohemian or boho style is eclectic and free-spirited. It embraces a mix of colors, patterns, and textures. It often includes vintage furniture, plants, and cultural influences from around the world.
- Mid-Century Modern: This style emerged in the mid-20th century and is characterized by clean lines, organic shapes, and a focus on functionality. It often features bold colors, geometric patterns, and furniture with tapered legs.
I hope this helps! Let me know if you have any other questions.
# 提示词
prompt = ['The office is designed in Scandinavian style, This style is characterized by simplicity, minimalism, and functionality. It often features light colors, natural materials, and clean lines.',
'The office is designed in Industrial style, Industrial design is inspired by old factories and warehouses. It incorporates raw materials like exposed brick, metal, and concrete. It often includes open spaces, high ceilings, and a combination of vintage and modern elements.',
'The office is designed in Bohemian style, Bohemian or boho style is eclectic and free-spirited. It embraces a mix of colors, patterns, and textures. It often includes vintage furniture, plants, and cultural influences from around the world.',
'The office is designed in Mid-Century Modern style, This style emerged in the mid-20th century and is characterized by clean lines, organic shapes, and a focus on functionality. It often features bold colors, geometric patterns, and furniture with tapered legs.'
]
4. 生成图片 #
因为显存不够,没有修改模型生成图片的宽高,导致生成的图片尺寸与原图不一致。
import matplotlib.pyplot as plt
fig, axes = plt.subplots(6, 4, figsize=(24, 36))
for n in range(4):
img_path = f'{n}.jpg'
control_img = mmcv.imread(img_path)
control = cv2.Canny(control_img, 100, 200)
control = control[:, :, None]
control = np.concatenate([control] * 3, axis=2)
control = Image.fromarray(control)
axes[0, n].imshow(control_img[:, :, ::-1])
axes[1, n].imshow(control)
axes[0, n].axis('off')
axes[1, n].axis('off')
axes[0, n].set_title(f'Sample_{n+1}')
for i in range(len(prompt)):
output_dict = controlnet.infer(prompt[i], control=control)
samples = output_dict['samples']
for idx, sample in enumerate(samples):
axes[i+2, n].imshow(sample)
axes[i+2, n].axis('off')
axes[0, 0].set_ylabel(f'Origin')
axes[1, 0].set_ylabel(f'Canny')
axes[2, 0].set_ylabel('Style: Scandinavian')
axes[3, 0].set_ylabel('Style: Industrial')
axes[4, 0].set_ylabel('Style: Bohemian')
axes[5, 0].set_ylabel('Style: Mid-Century Modern')
plt.tight_layout()
plt.show()
100%|██████████| 20/20 [00:07<00:00, 2.60it/s] 100%|██████████| 20/20 [00:07<00:00, 2.59it/s] 100%|██████████| 20/20 [00:07<00:00, 2.58it/s] 100%|██████████| 20/20 [00:07<00:00, 2.60it/s] 100%|██████████| 20/20 [00:07<00:00, 2.60it/s] 100%|██████████| 20/20 [00:07<00:00, 2.59it/s] 100%|██████████| 20/20 [00:07<00:00, 2.59it/s] 100%|██████████| 20/20 [00:07<00:00, 2.59it/s] 100%|██████████| 20/20 [00:07<00:00, 2.58it/s] 100%|██████████| 20/20 [00:07<00:00, 2.58it/s] 100%|██████████| 20/20 [00:07<00:00, 2.58it/s] 100%|██████████| 20/20 [00:07<00:00, 2.58it/s] 100%|██████████| 20/20 [00:07<00:00, 2.58it/s] 100%|██████████| 20/20 [00:07<00:00, 2.58it/s] 100%|██████████| 20/20 [00:07<00:00, 2.58it/s] 100%|██████████| 20/20 [00:07<00:00, 2.58it/s]
评论(0条)