★★★ 本文源自AlStudio社区精品项目,【点击此处】查看更多精品内容 >>>

[有手就行]点几下开始画出写实的小姐姐

更新功能列表

  • 修复了一些问题

  • 同时使用多个 lora

  • 支持控制网络(ControlNet)

  • 增加了超分类型 可以选择 无 和 高清修复 两种

  • 移植了隔壁大佬项目的[高清修复v2]版,如果喜欢[高清修复]或[高清修复v2]的话请去支持一下,! 文生图LoRA 融合版

  • 增加切片大小控制,影响推理时的注意力切片大小,切片越小越省显存推理速度越慢,切片越大推理越快显存消耗越多

  • 整体Fork的@天堂进制 的[多loRA,ControlNet预处理,高清v2,中文TAG]文生图v9.8版为基础修改,可以去支持下

  • 感谢 @风飏 开发者开发的UI界面!

  • 感谢 [文生图LoRA 融合版]项目,的高清修复方案,本想的高清修复均采用此项目实现.

  • 感谢 [PPDiffusers:支持ControlNet和多LoRA融合,不定期更新]的图片骨骼算法,本项目控制网络预处理动作骨骼抽取采用此项目算法.

一、点“运行一下”,稍后,再点“启动环境”,选合适的GPU点开始"确定"!

点击“运行一下”稍等(Fork项目),再点击“启动环境",点击选择合适的GPU后即可进入项目。
AI Studio每天自动赠送 8 小时的GPU算力,显存更大的GPU能够生成尺寸更大的图片哦。

二、点下面"点击运行"小按钮,稍后,再点上面"重启内核"小按钮

到了BML CodeLabe的main.ipynb界面,点击下边的框里左上角的“点击运行”小按钮(或者点进下面的框内用快捷键 Ctrl + Enter)。

提示:下面安装环境的代码,只需要在你第一次进入本项目时运行!

等到显示“加载完毕, 请重启内核”后,请重启内核。

#点左边的"点击运行"小按钮(或者点进下面的框内用快捷键 Ctrl + Enter),稍后,重启内核
! pip install pip ppdiffusers paddlenlp safetensors OmegaConf numpy --upgrade --user
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Requirement already satisfied: pip in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (22.1.2)
Collecting pip
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/07/51/2c0959c5adf988c44d9e1e0d940f5b074516ecc87e96b1af25f59de9ba38/pip-23.0.1-py3-none-any.whl (2.1 MB)
[2K     [90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━[0m [32m2.1/2.1 MB[0m [31m32.4 MB/s[0m eta [36m0:00:00[0ma [36m0:00:01[0m
[?25hCollecting ppdiffusers
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/05/f0/f311fcaa874b1238edd332030680aace7790abe29d8ec3581d4953476475/ppdiffusers-0.14.0-py3-none-any.whl (909 kB)
[2K     [90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━[0m [32m909.7/909.7 kB[0m [31m22.4 MB/s[0m eta [36m0:00:00[0m00:01[0m
[?25hRequirement already satisfied: paddlenlp in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (2.4.2)
Collecting paddlenlp
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/e4/67/f97788181e3a49afcdf8ffa162a335c21d18a55387bae85be24b01383165/paddlenlp-2.5.2-py3-none-any.whl (2.3 MB)
[2K     [90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━[0m [32m2.3/2.3 MB[0m [31m31.1 MB/s[0m eta [36m0:00:00[0m00:01[0m00:01[0m
[?25hCollecting safetensors
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/6f/f6/8acad7de48a710a49a089346221ce5cb9ef9aa8f1f8e5ae7b210f81c4eae/safetensors-0.3.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB)
[2K     [90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━[0m [32m1.2/1.2 MB[0m [31m22.5 MB/s[0m eta [36m0:00:00[0ma [36m0:00:01[0m
[?25hCollecting OmegaConf
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/e3/94/1843518e420fa3ed6919835845df698c7e27e183cb997394e4a670973a65/omegaconf-2.3.0-py3-none-any.whl (79 kB)
[2K     [90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━[0m [32m79.5/79.5 kB[0m [31m15.7 MB/s[0m eta [36m0:00:00[0m
[?25hRequirement already satisfied: numpy in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (1.19.5)
Collecting numpy
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/6d/ad/ff3b21ebfe79a4d25b4a4f8e5cf9fd44a204adb6b33c09010f566f51027a/numpy-1.21.6-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (15.7 MB)
[2K     [90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━[0m [32m15.7/15.7 MB[0m [31m27.7 MB/s[0m eta [36m0:00:00[0m00:01[0m00:01[0m
[?25hCollecting regex
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/42/d8/8a7131e7d0bf237f7bcd3191541a4bf21863c253fe6bee0796900a1a9a29/regex-2022.10.31-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (757 kB)
[2K     [90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━[0m [32m757.1/757.1 kB[0m [31m43.2 MB/s[0m eta [36m0:00:00[0m
[?25hCollecting ftfy
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/e1/1e/bf736f9576a8979752b826b75cbd83663ff86634ea3055a766e2d8ad3ee5/ftfy-6.1.1-py3-none-any.whl (53 kB)
[2K     [90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━[0m [32m53.1/53.1 kB[0m [31m10.1 MB/s[0m eta [36m0:00:00[0m
[?25hRequirement already satisfied: Pillow in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from ppdiffusers) (8.2.0)
Requirement already satisfied: visualdl in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlenlp) (2.4.0)
Requirement already satisfied: jieba in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlenlp) (0.42.1)
Collecting huggingface-hub>=0.11.1
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/df/90/5ad98abead047169f4f86bc67e99020c841d71c9c6bd202e04af71e70e53/huggingface_hub-0.13.4-py3-none-any.whl (200 kB)
[2K     [90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━[0m [32m200.1/200.1 kB[0m [31m31.1 MB/s[0m eta [36m0:00:00[0m
[?25hRequirement already satisfied: rich in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlenlp) (12.6.0)
Requirement already satisfied: colorlog in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlenlp) (4.1.0)
Requirement already satisfied: tqdm in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlenlp) (4.64.1)
Requirement already satisfied: sentencepiece in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlenlp) (0.1.96)
Requirement already satisfied: seqeval in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlenlp) (1.2.2)
Requirement already satisfied: Flask-Babel<3.0.0 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlenlp) (1.0.0)
Requirement already satisfied: datasets>=2.0.0 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlenlp) (2.7.0)
Requirement already satisfied: paddlefsl in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlenlp) (1.1.0)
Requirement already satisfied: multiprocess<=0.70.12.2 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlenlp) (0.70.11.1)
Requirement already satisfied: paddle2onnx in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlenlp) (1.0.0)
Collecting typer
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/0d/44/56c3f48d2bb83d76f5c970aef8e2c3ebd6a832f09e3621c5395371fe6999/typer-0.7.0-py3-none-any.whl (38 kB)
Requirement already satisfied: fastapi in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlenlp) (0.95.0)
Requirement already satisfied: colorama in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlenlp) (0.4.4)
Requirement already satisfied: uvicorn in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlenlp) (0.21.1)
Requirement already satisfied: dill<0.3.5 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlenlp) (0.3.3)
Collecting antlr4-python3-runtime==4.9.*
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/3e/38/7859ff46355f76f8d19459005ca000b6e7012f2f1ca597746cbcd1fbfe5e/antlr4-python3-runtime-4.9.3.tar.gz (117 kB)
[2K     [90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━[0m [32m117.0/117.0 kB[0m [31m20.5 MB/s[0m eta [36m0:00:00[0m
[?25h  Preparing metadata (setup.py) ... [?25ldone
[?25hRequirement already satisfied: PyYAML>=5.1.0 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from OmegaConf) (5.1.2)
Requirement already satisfied: aiohttp in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from datasets>=2.0.0->paddlenlp) (3.8.3)
Requirement already satisfied: pandas in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from datasets>=2.0.0->paddlenlp) (1.1.5)
Requirement already satisfied: xxhash in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from datasets>=2.0.0->paddlenlp) (3.1.0)
Requirement already satisfied: pyarrow>=6.0.0 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from datasets>=2.0.0->paddlenlp) (10.0.0)
Requirement already satisfied: responses<0.19 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from datasets>=2.0.0->paddlenlp) (0.18.0)
Requirement already satisfied: fsspec[http]>=2021.11.1 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from datasets>=2.0.0->paddlenlp) (2022.11.0)
Requirement already satisfied: packaging in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from datasets>=2.0.0->paddlenlp) (21.3)
Requirement already satisfied: requests>=2.19.0 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from datasets>=2.0.0->paddlenlp) (2.24.0)
Requirement already satisfied: importlib-metadata in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from datasets>=2.0.0->paddlenlp) (4.2.0)
Requirement already satisfied: Jinja2>=2.5 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from Flask-Babel<3.0.0->paddlenlp) (3.0.0)
Requirement already satisfied: Flask in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from Flask-Babel<3.0.0->paddlenlp) (1.1.1)
Requirement already satisfied: Babel>=2.3 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from Flask-Babel<3.0.0->paddlenlp) (2.8.0)
Requirement already satisfied: pytz in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from Flask-Babel<3.0.0->paddlenlp) (2019.3)
Requirement already satisfied: typing-extensions>=3.7.4.3 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from huggingface-hub>=0.11.1->paddlenlp) (4.3.0)
Requirement already satisfied: filelock in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from huggingface-hub>=0.11.1->paddlenlp) (3.0.12)
Requirement already satisfied: starlette<0.27.0,>=0.26.1 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from fastapi->paddlenlp) (0.26.1)
Requirement already satisfied: pydantic!=1.7,!=1.7.1,!=1.7.2,!=1.7.3,!=1.8,!=1.8.1,<2.0.0,>=1.6.2 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from fastapi->paddlenlp) (1.10.6)
Collecting wcwidth>=0.2.5
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/20/f4/c0584a25144ce20bfcf1aecd041768b8c762c1eb0aa77502a3f0baa83f11/wcwidth-0.2.6-py2.py3-none-any.whl (29 kB)
Requirement already satisfied: commonmark<0.10.0,>=0.9.0 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from rich->paddlenlp) (0.9.1)
Requirement already satisfied: pygments<3.0.0,>=2.6.0 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from rich->paddlenlp) (2.13.0)
Requirement already satisfied: scikit-learn>=0.21.3 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from seqeval->paddlenlp) (0.24.2)
Requirement already satisfied: click<9.0.0,>=7.1.1 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from typer->paddlenlp) (8.0.4)
Requirement already satisfied: h11>=0.8 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from uvicorn->paddlenlp) (0.14.0)
Requirement already satisfied: six>=1.14.0 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from visualdl->paddlenlp) (1.16.0)
Requirement already satisfied: protobuf>=3.11.0 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from visualdl->paddlenlp) (3.20.0)
Requirement already satisfied: matplotlib in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from visualdl->paddlenlp) (2.2.3)
Requirement already satisfied: bce-python-sdk in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from visualdl->paddlenlp) (0.8.53)
Requirement already satisfied: Werkzeug>=0.15 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from Flask->Flask-Babel<3.0.0->paddlenlp) (0.16.0)
Requirement already satisfied: itsdangerous>=0.24 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from Flask->Flask-Babel<3.0.0->paddlenlp) (1.1.0)
Requirement already satisfied: aiosignal>=1.1.2 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from aiohttp->datasets>=2.0.0->paddlenlp) (1.2.0)
Requirement already satisfied: asynctest==0.13.0 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from aiohttp->datasets>=2.0.0->paddlenlp) (0.13.0)
Requirement already satisfied: frozenlist>=1.1.1 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from aiohttp->datasets>=2.0.0->paddlenlp) (1.3.0)
Requirement already satisfied: charset-normalizer<3.0,>=2.0 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from aiohttp->datasets>=2.0.0->paddlenlp) (2.1.1)
Requirement already satisfied: attrs>=17.3.0 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from aiohttp->datasets>=2.0.0->paddlenlp) (22.1.0)
Requirement already satisfied: async-timeout<5.0,>=4.0.0a3 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from aiohttp->datasets>=2.0.0->paddlenlp) (4.0.2)
Requirement already satisfied: multidict<7.0,>=4.5 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from aiohttp->datasets>=2.0.0->paddlenlp) (6.0.2)
Requirement already satisfied: yarl<2.0,>=1.0 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from aiohttp->datasets>=2.0.0->paddlenlp) (1.7.2)
Requirement already satisfied: MarkupSafe>=2.0.0rc2 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from Jinja2>=2.5->Flask-Babel<3.0.0->paddlenlp) (2.0.1)
Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from packaging->datasets>=2.0.0->paddlenlp) (3.0.9)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from requests>=2.19.0->datasets>=2.0.0->paddlenlp) (1.25.11)
Requirement already satisfied: idna<3,>=2.5 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from requests>=2.19.0->datasets>=2.0.0->paddlenlp) (2.8)
Requirement already satisfied: certifi>=2017.4.17 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from requests>=2.19.0->datasets>=2.0.0->paddlenlp) (2019.9.11)
Requirement already satisfied: chardet<4,>=3.0.2 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from requests>=2.19.0->datasets>=2.0.0->paddlenlp) (3.0.4)
Requirement already satisfied: scipy>=0.19.1 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from scikit-learn>=0.21.3->seqeval->paddlenlp) (1.6.3)
Requirement already satisfied: joblib>=0.11 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from scikit-learn>=0.21.3->seqeval->paddlenlp) (0.14.1)
Requirement already satisfied: threadpoolctl>=2.0.0 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from scikit-learn>=0.21.3->seqeval->paddlenlp) (2.1.0)
Requirement already satisfied: anyio<5,>=3.4.0 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from starlette<0.27.0,>=0.26.1->fastapi->paddlenlp) (3.6.1)
Requirement already satisfied: future>=0.6.0 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from bce-python-sdk->visualdl->paddlenlp) (0.18.0)
Requirement already satisfied: pycryptodome>=3.8.0 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from bce-python-sdk->visualdl->paddlenlp) (3.9.9)
Requirement already satisfied: zipp>=0.5 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from importlib-metadata->datasets>=2.0.0->paddlenlp) (3.8.1)
Requirement already satisfied: kiwisolver>=1.0.1 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from matplotlib->visualdl->paddlenlp) (1.1.0)
Requirement already satisfied: cycler>=0.10 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from matplotlib->visualdl->paddlenlp) (0.10.0)
Requirement already satisfied: python-dateutil>=2.1 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from matplotlib->visualdl->paddlenlp) (2.8.2)
Requirement already satisfied: sniffio>=1.1 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from anyio<5,>=3.4.0->starlette<0.27.0,>=0.26.1->fastapi->paddlenlp) (1.3.0)
Requirement already satisfied: setuptools in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from kiwisolver>=1.0.1->matplotlib->visualdl->paddlenlp) (56.2.0)
Building wheels for collected packages: antlr4-python3-runtime
  Building wheel for antlr4-python3-runtime (setup.py) ... [?25ldone
[?25h  Created wheel for antlr4-python3-runtime: filename=antlr4_python3_runtime-4.9.3-py3-none-any.whl size=144573 sha256=ec71ac1020ee1126064ab644b921960493166330ce34f22d92a67c77296c4793
  Stored in directory: /home/aistudio/.cache/pip/wheels/f0/95/ef/f6e0562ab90f488f118c9b3a257ada03231324672351312f2e
Successfully built antlr4-python3-runtime
Installing collected packages: wcwidth, safetensors, antlr4-python3-runtime, regex, pip, OmegaConf, numpy, ftfy, huggingface-hub, typer, paddlenlp, ppdiffusers
[31mERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
parl 1.4.1 requires pyzmq==18.1.1, but you have pyzmq 23.2.1 which is incompatible.[0m[31m
[0mSuccessfully installed OmegaConf-2.3.0 antlr4-python3-runtime-4.9.3 ftfy-6.1.1 huggingface-hub-0.13.4 numpy-1.21.6 paddlenlp-2.5.2 pip-23.0.1 ppdiffusers-0.14.0 regex-2022.10.31 safetensors-0.3.0 typer-0.7.0 wcwidth-0.2.6

[1m[[0m[34;49mnotice[0m[1;39;49m][0m[39;49m A new release of pip available: [0m[31;49m22.1.2[0m[39;49m -> [0m[32;49m23.0.1[0m
[1m[[0m[34;49mnotice[0m[1;39;49m][0m[39;49m To update, run: [0m[32;49mpython -m pip install --upgrade pip[0m
#如果出现错误请重启内核后再次执行此操作,执行成功后需要重启内核
from IPython.display import clear_output
from ui.utils import diffusers_auto_update
diffusers_auto_update()
clear_output() # 清理很长的内容
print('加载完毕, 请重启内核')
加载完毕, 请重启内核

三、一切就绪,开始画

1、文生图的地方

  • 重要提示:有喜欢的图片记得点 [收藏图片] 不然重启后图片会消失
  • 收藏图片:会生成[FavoratesLibrary.html]图书馆文件
  • 生成图片:会临时保存到左侧的 data 文件夹里的 txt2img 文件夹里
  • 生成图片:会生成[txt2imgLibrary.html]图书馆文件
  • lora 文件在 data/lora目录中,描述中用 <lora:{文件名(不带扩展名)}:{权重}> 来使用
  • 二次元:模型名称改为 import/anything_v4 即可
  • 换回写实:模型名称改为 import/chilloutmix 即可
  • 例如 lora文件为"ABC.safetensors" 则提示写为<lora:ABC:1> ,支持同时使用多个 lora,注意文件名中不可以包含 “<>:”
  • 网络模型文件在data/models/import目录中
  • 支持 4096x4096 大图,32g 建议不要超过1600x1600 可能回爆炸
  • 图像放大已经修复,可以用
  • 支持控制网络(ControlNet),支持预处理支持使用普通图片即可完成引导,另外控制网络需要更多的显存,引导图请填写完整图片路径
  • 增加了超分类型 可以选择 无 和 高清修复 两种
  • 移植了隔壁大佬项目的[高清修复v2]版,如果喜欢[高清修复]或[高清修复v2]的话请去支持一下,! 文生图LoRA 融合版
  • 增加高清修复强度控制,影响高清修复添加噪声强度和修复步数
  • 增加切片大小控制,影响推理时的注意力切片大小,切片越小越省显存推理速度越慢,切片越大推理越快显存消耗越多
from ui import gui_txt2img # 点左边的"运行一下"图标,等界面出来,点“生成图片”,第一次解压Lora模型和加载网络模型慢点,后面出图就快了
display(gui_txt2img.gui) # 生成喜欢的记得点击“收藏图片”,下次启动还会有
# 使用ctrl模型功能,选择模型种类,然后请在左侧文件夹上传图片,然后复制完整路径,粘贴到“引导图”,设置ctrl强度即可
# 左边文件根目录里的FavoratesLibrary.html和txt2imgLibrary.html里面有图片的生成描述和参数,可以试着换Lora、描述和参数调整
Box(children=(HTML(value='<style>\n@media (max-width:576px) {\n    .StableDiffusionUI_txt2img6E29 {\n        m…

2、图生图的地方

  • 重要提示:有喜欢的图片记得点 [收藏图片] 不然重启后图片会消失
  • 收藏图片:会生成[FavoratesLibrary.html]图书馆文件
  • 生成图片:会临时保存到左侧的 data 文件夹里的 img2img 文件夹里
  • 生成图片:会生成[img2imgLibrary.html]图书馆文件
from ui import gui_img2img # 点左边的"运行一下"图标,等界面出来,点“生成图片”
display(gui_img2img.gui) # 生成的图片自动保存到左侧的 data/img2img 的文件夹里
# 不要用本界面里的上传图片,在左侧文件夹上传图片,然后复制完整路径,粘贴到 "输入图片",点"导入",再去右边点“生成图片”
# 生成喜欢的记得点击“收藏图片”,下次启动还会有
Box(children=(HTML(value="<style>\n@media (max-width:576px) {\n    .StableDiffusionUI_img2img7CBD {\n        m…

3、超分UI使用

from ui import gui_superres # 超分 (图片放大一倍), 在左侧“文件”目录上传图片, 然后修改 "需要超分的图片路径"
display(gui_superres.gui) # 生成的图片自动保存到左侧的 outputs/highres 的文件夹里

4、 定制化训练(高阶)

  • 让模型认识新的物体或学习到新的风格
  • 除了直接调用外,PaddleNLP还提供好用的二次开发能力
  • 可以参照下方PaddleNLP仓库的教程,只需要几张图片,就可以定制属于自己的文图生成模型。

在下面GIF例子中,我们进行了如下操作,更多信息可进入PaddleNLP examples中查看更多例子。

(1) 输入了代表该人物的新单词:<Alice>,新词用<>括起来,主要是为了避免与已有的单词混淆;

(2) 指定了与该人物比较接近的单词girl, 该单词作为先验(已知)知识,可以帮助模型快速理解新单词,从而加快模型训练;

(3) 提供了含有下面6张图片的文件夹地址:resources/Alices,在这里我们指定了resources目录下的Alices文件夹。


text_inversion 训练

from ui import gui_train_text_inversion # 训练
display(gui_train_text_inversion.gui) # 训练结果会保存到 outputs/textual_inversion 的文件夹
# 二次元:需要训练的模型名称改为 import/anything_v4
# 写实的:需要训练的模型名称改为 import/chilloutmix
Box(children=(Box(children=(Dropdown(description='训练目标', description_tooltip='训练目标是什么?风格还是实体?', index=1, layou…

LoRA 训练

  • 注意:训练图片文件夹中需要参与训练的每个图片必须有 一个同名的txt文件,里面是相关的提示词,否则运行会报错.
from ui import gui_text_to_image_lora #训练lora
display(gui_text_to_image_lora.gui) 
Box(children=(Box(children=(Dropdown(description='训练目标', description_tooltip='训练目标是什么?风格还是实体?', index=1, layou…

模型训练完成之后,可以使用新模型预测了!

现在模型已经认识 <Alice> 这个object(人物、物体,everything…)了。

比如输入Prompt:<Alice> at the lake,就可以生成一张站在湖边的 <Alice> 图像了。

from ui import gui_train_text_inversion # 使用训练好的权重进行加载预测
display(gui_train_text_inversion.gui) # 生成的图片自动保存到左侧的 outputs/text_inversion_txt2img 的文件夹里
# 输入 <Alice> 相关的Prompt试试吧,例如:<Alice> at the lake,看看模型是否学到了<Alice>这个object。记得删除默认给出的negative_prompt反面描述。

下面是Dreambooth训练部分
可以参考 https://github.com/PaddlePaddle/PaddleNLP/tree/develop/ppdiffusers/examples/dreambooth 配置下面的选项

from ui import gui_dreambooth #训练dreambooth
display(gui_dreambooth.gui) 
Box(children=(Box(children=(Combobox(value='MoososCap/NOVEL-MODEL', description='需要训练的模型名称', layout=Layout(ali…

现在你已经学会了如何让模型认识新的物体,模型不仅可以学习新物体还可以学习新风格。风格的学习与物体的学习方法与流程一致,我们仅需在UI界面中设置学习“style”,开始训练即可。

欢迎各位贡献自己训练好的模型权重到PaddleNLP,比如"xxx艺术家风格的模型",让更多开发者了解、使用自己的作品。欢迎加入交流群,了解如何贡献。

import os
import tarfile
from pathlib import Path
os.environ['PPNLP_HOME']='./data'
print(os.path.basename(
        os.path.dirname('./data/models/import/anything_v4')))#import
print(os.path.basename('./data/models/import/anything_v4'))#anything_v4



def decompression_models(src_models_path,dest_models_path):
    # if os.path.exists(path,os.environ['PPNLP_HOME']+'/models/import') == False:
    #     os.makedirs(path,os.environ['PPNLP_HOME']+'/models/import')
    # if os.path.exists(path,os.environ['PPNLP_HOME']+'/datasets') == False:
    #     os.makedirs(path,os.environ['PPNLP_HOME']+'/datasets')
    # if os.path.exists(path,os.environ['PPNLP_HOME']+'/modules') == False:
    #     os.makedirs(path,os.environ['PPNLP_HOME']+'/modules')
    # if os.path.exists(path,os.environ['PPNLP_HOME']+'/packages') == False:
    #     os.makedirs(path,os.environ['PPNLP_HOME']+'/packages')
    if os.path.exists(src_models_path) == False:
        os.makedirs(src_models_path)
    print('decompression '+src_models_path)
    with os.scandir(src_models_path) as it:
        for i in it:
            if i.is_file() and i.name.endswith('tar.gz') :
                print(i.name+" -> "+ dest_models_path)
                model=tarfile.open(i)
                model.extractall(path=dest_models_path)
                print("     completed")

with os.scandir(os.environ['PPNLP_HOME']+'/') as it:
    for i in it:
        if i.is_dir() and i.name.startswith('data') :
            decompression_models(i.path,os.environ['PPNLP_HOME']+'/models/import')


            

此文章为搬运
原项目链接

Logo

学大模型,用大模型上飞桨星河社区!每天8点V100G算力免费领!免费领取ERNIE 4.0 100w Token >>>

更多推荐