Skip to content

Instantly share code, notes, and snippets.

@xiaozhu2007
Created December 26, 2022 04:59
Show Gist options
  • Save xiaozhu2007/7827f95090ce83104959382bb8888bdb to your computer and use it in GitHub Desktop.
Save xiaozhu2007/7827f95090ce83104959382bb8888bdb to your computer and use it in GitHub Desktop.
novelaileak
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": [],
"collapsed_sections": [
"9qrpRUJpno7L"
],
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
},
"accelerator": "GPU",
"gpuClass": "standard"
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/xiaozhu2007/7827f95090ce83104959382bb8888bdb/novelaileak.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "markdown",
"source": [
"Adapted from: https://colab.research.google.com/drive/1AfAmwLMd_Vx33O9IwY2TmO9wKZ8ABRRa"
],
"metadata": {
"id": "gfKvWAVnz8OB"
}
},
{
"cell_type": "markdown",
"source": [
"首先,按下F12打开开发人员工具,将如下代码贴入Console并执行,可以防止colab每小时关闭一次你的进程\n",
"```\n",
"function ConnectButton(){\n",
" console.log(\"Connect pushed\"); \n",
" document.querySelector(\"#top-toolbar > colab-connect-button\").shadowRoot.querySelector(\"#connect\").click() \n",
"}\n",
"\n",
"setInterval(ConnectButton,60000);\n",
"```\n",
"\n"
],
"metadata": {
"id": "LwzIM8VSAIPv"
}
},
{
"cell_type": "markdown",
"source": [],
"metadata": {
"id": "D35TN5iZAB_y"
}
},
{
"cell_type": "code",
"source": [
"import os\n",
"os.kill(os.getpid(), 9) # This will crash Colab (required, everything will still be intact so dont worry)"
],
"metadata": {
"id": "p8FI40sFj9tU"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"1.从官方存储库克隆最新版代码"
],
"metadata": {
"id": "OHCtG9MT0jLq"
}
},
{
"cell_type": "code",
"source": [
"!git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui\n",
"%cd stable-diffusion-webui"
],
"metadata": {
"id": "sBbcB4vwj_jm"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"从灰机云下载novelai的泄露版模型,这里使用了animefull-final-pruned版本"
],
"metadata": {
"id": "F0EINk5M0s-w"
}
},
{
"cell_type": "code",
"source": [
"#@title 下载novelai的animfull-final-pruned模型\n",
"!wget https://www.anscc.net/d/%E5%9B%BE%E7%89%87%E6%9C%AC%E5%AD%90%E9%9F%B3%E4%B9%90%E6%9D%82%E9%A1%B9/%E6%9D%82%E9%A1%B9/novelai/novelaileak/stableckpt/animefull-final-pruned/model.ckpt -O /content/stable-diffusion-webui/model.ckpt"
],
"metadata": {
"id": "CT_J9L7oqLxG"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"#@title 下载novelai的ave\n",
"!wget https://www.anscc.net/d/%E5%9B%BE%E7%89%87%E6%9C%AC%E5%AD%90%E9%9F%B3%E4%B9%90%E6%9D%82%E9%A1%B9/%E6%9D%82%E9%A1%B9/novelai/novelaileak/stableckpt/animevae.pt -O /content/stable-diffusion-webui/model.vae.ckpt"
],
"metadata": {
"id": "nupfQ6a_EqLc"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"#@title 下载hypernetwork文件\n",
"!mkdir /content/stable-diffusion-webui/models/hypernetworks\n",
"!wget https://www.anscc.net/d/%E5%9B%BE%E7%89%87%E6%9C%AC%E5%AD%90%E9%9F%B3%E4%B9%90%E6%9D%82%E9%A1%B9/%E6%9D%82%E9%A1%B9/novelai/novelaileak/stableckpt/modules/modules/anime.pt -O /content/stable-diffusion-webui/models/hypernetworks/anime.pt"
],
"metadata": {
"id": "RwcPbWGFFHPV"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"#@title 下载优化配置文件config\n",
"!wget https://www.anscc.net/d/%E5%9B%BE%E7%89%87%E6%9C%AC%E5%AD%90%E9%9F%B3%E4%B9%90%E6%9D%82%E9%A1%B9/%E6%9D%82%E9%A1%B9/novelai/config.json /content/stable-diffusion-webui/config.json\n",
"!wget https://www.anscc.net/d/%E5%9B%BE%E7%89%87%E6%9C%AC%E5%AD%90%E9%9F%B3%E4%B9%90%E6%9D%82%E9%A1%B9/%E6%9D%82%E9%A1%B9/novelai/ui-config.json /content/stable-diffusion-webui/ui-config.json"
],
"metadata": {
"id": "LALUT9_sv9Xd"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"这行命令将安装其他所需要的依赖项目"
],
"metadata": {
"id": "v2kY0Z05DwIN"
}
},
{
"cell_type": "code",
"source": [
"#@title 安装依赖项目\n",
"!COMMANDLINE_ARGS=\"--exit\" REQS_FILE=\"requirements.txt\" python launch.py"
],
"metadata": {
"id": "IB19TzabDtYF"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"启动网页UI。 启动后你将会得到一个 nnn.gradio.app格式的链接,点击它就可以开始使用了\n",
"\n",
"使用的命令行参数:\n",
" - `--share` - 创建一个 gradio.app 链接\n",
" - `--gradio-debug` - 打印运行输出到终端\n",
" - `--gradio-auth me:qwerty` - 设置访问网页UI时使用的用户名和密码,这里设置为用户名:me,密码:qwerty"
],
"metadata": {
"id": "xt8lbdmC04ox"
}
},
{
"cell_type": "code",
"source": [
"!COMMANDLINE_ARGS=\"--share --gradio-debug --gradio-auth me:qwerty\" REQS_FILE=\"requirements.txt\" python launch.py"
],
"metadata": {
"id": "R-xAdMA5wxXd"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"当你在这里 ***运行完成*** 这份代码之后可以做的事情\n",
"============================================================================"
],
"metadata": {
"id": "9qrpRUJpno7L"
}
},
{
"cell_type": "markdown",
"source": [
"打包已经生成的图片 (在左边单击文件夹图标,就是{x}图标下面的那个)"
],
"metadata": {
"id": "zB-L8JpElKp-"
}
},
{
"cell_type": "code",
"source": [
"!zip -r /content/stable-diffusion-webui /content/stable-diffusion-webui/outputs "
],
"metadata": {
"id": "gBt5g_Dn0NFo"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"将图像保存到 Google Drive **警告:这将导致 google 扫描你的所有数据,所以如果你担心被扫描,可能需要创建一个专门为 colab 准备的干净帐户上然后存储它**"
],
"metadata": {
"id": "odNn2KF5lFmb"
}
},
{
"cell_type": "code",
"source": [
"from google.colab import drive # type: ignore\n",
"\n",
"try:\n",
" drive_path = \"/content/drive\"\n",
" drive.mount(drive_path,force_remount=False)\n",
"except:\n",
" print(\"...error mounting drive or with drive path variables\")\n",
"\n",
"!cp -r \"/content/stable-diffusion-webui/outputs\" \"/content/drive/MyDrive\""
],
"metadata": {
"id": "zNEgJfbhDwI6"
},
"execution_count": null,
"outputs": []
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment