{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.7.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"## NovelAi stable-diffusion-webui+api(Kaggle云端部署项目,完全免费,无需任何配置!)\n**torch: 1.13.1+cu117 • xformers: 0.0.16rc425**\n\n### (电脑建议Edge浏览器,手机建议Google浏览器并且设置成桌面版网页,否则容易出现不可预知的错误)","metadata":{}},{"cell_type":"markdown","source":"\nKaggle在线部署NovelAi(Webui)的生成演示效果,与本地部署效果几乎一致。模型:AbyssOrange_mix2_nsfw","metadata":{}},{"cell_type":"markdown","source":"Features:\n- **ngrok 可选开启,默认开启 stable-diffusion-webui 自带的穿透**\n- **frp 可选开启,需要提供ini配置文件,是按照樱花rpc的配置方式写的,其他的不知道能不能用**\n- **Webui使用官方最新的版本,与AUTOMATIC1111作者的github同步更新**\n- **默认安装 a1111-sd-webui-tagcomplete tag补全插件,tag翻译文件来源 https://github.com/viyiviyi/sd-configs.git**\n- **默认安装图片浏览插件、汉化包、krita绘图插件,ControlNet,Tag选择器(tag选择器暂时炸了呜呜T_T)等几个插件**\n- **如果需要使用其他插件,将插件地址加入到配置项:*extensions*即可****\n- **如果需要加载额外的模型文件,把模型数据集目录加到配置:*modelDirs*里就行**\n- **如果需要添加Lora、embeddings、hypernetworks文件,同样只需要把目录加到对应配置里就行**\n- **其他更多配置,请查看下面第一个代码块**\n- **修改自https://www.kaggle.com/code/yiyiooo/stable-diffusion-webui-novelai** \n- 交流群632428790\n- 旧版见 https://www.kaggle.com/code/ilovemai/stable-diffusion-webui-novelai-edited-version/notebook","metadata":{}},{"cell_type":"markdown","source":"# 一、部署NovelAi(Webui)教程(新人必看)\n- ### ①先在该页面注册(英文register)一个kaggle账号(如果注册时没有出现验证码,需要科学上网!)\n- ②在文本的右上角,点击Copy&Edit\n\n- ③首次运行,需要验证手机号,同样需要科学上网,在右边的Settings(或者Notebook options)中的最底下找到用横线划着的Get Phone Verfied. 点击然后验证手机号。\n- 验证完毕后在右边栏目的Settings中的ACCELERATOR选项中选择GPU T4 x2作为算力,同时将Internet设置为On\n\n- ④在该页面的顶部点击Run All,然后拉到最底下查看输出日志。等待约5分钟\n\n\n- ⑤等待10分钟左右后,输出日志中会出现Public URL,注意是以gradio.live结尾的链接,我们点进去(如果找不到,可以按F3,搜索gradio)\n\n- ▲建议不要频繁切换模型,kaggle内存很小,容易爆内存!\n- 然后我们就可以尽情玩啦!\n\nKaggle免费提供的Tesla T4显卡速度还是可以的,512x768,28步数仅需7秒。还有15GB大显存!\n\n> ### 以上步骤还是看不懂?直接加群632428790询问管理员!\n\n# 二、部署QQ AI画图机器人方法(若不感兴趣可略过)\n> ### 此kaggle部署的NovelAi Stable Diffusion项目自带Koishi机器人框架,并且Webui默认开启API,可以用于部署QQ部署机器人,*可支持24小时离线挂机运行* (特别感谢yiyiooo大佬写的kaggle安装koishi项目!)\n\n- ①将第一个代码单元格中的useKoishi中的False改为True\n- ②需要frp的内网穿透ini配置文件,推荐樱花frp,frp配置教程如下(如果会弄的就不用看):\n\n > 准备:获取一个樱花内网映射账号,下载樱花映射软件,并实名认证 https://www.natfrp.com\n \n> 第一步,在樱花映射里登录你的账号\n\n> 第二步,创建一个隧道,必须为国外节点,中国连不上,选择TCP隧道,服务器任意,本地端口必须为5140,本地ip默认\n\n> 第三步,然后在网页里的服务>隧道列表>操作>配置文件>下载\n\n> 第四步,在Kaggle上传你的配置到数据集中\n\n> 第五步,将数据集路径写到koishiFrpcConfig这个配置项里\n\n- ③后台部署NovelAi(Webui),在该页面的右上方,点击Save versions,在Advanced settings中选择Run with GPU for all sessions,其它不用动。然后Save(保存)\n\n- ④通过樱花frp隧道进入Koishi控制台,登录方式选择sd-Webui,API地址填http://0.0.0.0:7860 ,然后启动\n- ⑤在adapter-onebot插件中的selfld栏填入机器人的QQ,然后开启自动创建go-cqhttp进程。登录(不能用扫码登录)\n- ⑥我们在有机器人的QQ群中或者机器人好友中发送约稿+tag就能生成图片啦\n\n> ## **支持离线运行,即使页面关掉机器人也会持续开着,除非手动停止**","metadata":{}},{"cell_type":"markdown","source":"# 扩展内容\n发掘更多好玩的事物!\n\n## **如何增加模型,pt文件,lora模型,controlnet模型?**\n1. 先创建数据集,也就是dataset\n2. 创建时需要添加文件,选择自己的模型文件就行.上传好后给改数据集起名\n - 也可以通过下载链接直接上传,免去了下载模型后再上传后的麻烦\n - 如果提示该文件在别处已经上传,请在展开处点Include duplicates,请勿点Skip Dumplicate\n3. 同类型文件放相同的数据集里面,一个数据集也不要太大\n - 可以在dataset搜索其他人上传的模型\n5. 通过右侧的 **Add Data** 按钮选择已经上传的模型文件或者别人上传的模型文件\n - input 下面的列表就是模型文件,可以点击名称后面的复制按钮复制路径\n6. 将模型路径放在配置里的对应配置里即可,写法参考 **modelDirs**\n - 如果目录里还有子目录也是需要加载的,可以用*表示子目录 例子:比如Loras目录下还有角色、画风、涩涩的文件夹,那路径里写成 '/kaggle/input/Loras/*'就可以加载子目录里面的文件了\n - 模型加载使用的文件链接方式,如果你融模型的时候新模型名字和原有模型名字一样,会出现不能修改只读文件的错误\n - 同理,直接对模型做编辑的工具可能也会出现相同的错误\n \n \n- **为了提高启动速度,导致切换模型过程较慢,点击切换模型后进度条大概率会一直存在,但模型在1分半左右基本能加载完。** \n- **受到kaggle内存大小的影响,切换多个模型后大概率爆内存导致停止运行**\n \n**下边的配置项都写了对应配置的作用和使用说明,不理解的话也不用改,用默认的就好**\n\n## 如何下载文件\n#### 方式一\n- 在浏览器直接下 比如你需要下载的文件路径在 /kaggle/stable-diffusion-webui/models/Lora/dow_a.safetensors\n - 比如你需要下载的文件路径在 /kaggle/stable-diffusion-webui/models/Lora/dow_a.safetensors\n - 你的访问地址是 https://123123123.gradio.live\n - 则可以在浏览器输入 https://123123123.gradio.live/file=/kaggle/stable-diffusion-webui/models/Lora/dow_a.safetensors 下载你的文件\n \n#### 方式二\n- 复制到Output目录下载 仅支持使用Run All方式运行的\n - 比如你需要下载的文件路径在 /kaggle/stable-diffusion-webui/models/Lora/dow_a.safetensors\n - 先停止笔记本(不是关机,是停止)\n - 然后新建一个代码块,在里面输入 !cp -f /kaggle/stable-diffusion-webui/models/Lora/dow_a.safetensors /kaggle/working/\n - 就可以在右侧列表的Output目录看见复制出来的文件,点击下载即可\n \n#### 方式三\n- 开启链接输出目录的配置 (配置在第二个代码块,通过搜索**配置文件链接**快速查找)\n - 此方法会把已知的三个训练输出目录链接到Output目录下,直接去下载即可(两种启动方式都可以用)\n - 如果有新的目录需要链接,可以参考着自己写或者联系我\n \n#### 方式四\n- 将安装目录改到输出目录(配置在第二个代码块,通过搜索**安装目录**快速查找)\n - 此方式会把所有文件都放在安装目录,找到并下载即可\n - 如果使用这个方式,右侧的设置里**PERSISTENCE**这个设置项建议选No pensistence。如果选其他项,可能会出现关机特别慢的情况,因为需要上传输出目录的文件。\n\n## *保存生成过的图片*\n#### 方法一\n - 先Cancel Run停止运行,新建一个代码块,输入如下命令,并且运行\n > !tar -cvf /kaggle/working/output.tar $output_path/outputs\n - 在Output中可以看到一个output.tar的文件,将得到的tar文件下载到电脑上,然后解压即可\n \n#### 方法二\n - 点击右上角的Save Version,选择Quick Svave,并且在Advanced settings中选择Always save output when creating a Quick Save,\n - 到刚刚保存的文本上,点开Data,即可在output中看到自己生成过的图片\n \n#### 方法三\n - 在Webui的图库浏览器里一张张保存,但是不推荐这样做,浪费时间\n \n## **一些可能没用的说明**\n- 配置说明 **True或者False**表示布尔值 **True**表示“**是**” **False**表示“**否**” 只有这两个值\n- 配置说明 **[]** 表示数组,里面可以存放内容,每个内容需要用**英语(半角)逗号**隔开\n- 配置说明 **''或者\"\"** 英语(半角)的双引号或者单引号包裹的内容是**字符串**,比如放在数组里面的路径就需要是一个字符串\n- 配置说明 **#** **#** 后面的内容是**注释**,是帮助性内容,对整个代码的执行不会有影响","metadata":{}},{"cell_type":"code","source":"#第一个代码单元格,可以根据自己的需求进行更改\n\n\nuseNgrok=False # 非必填 是否使用ngrok作为公网访问地址\nngrokTokenFile='/kaggle/input/configs/ngrok_token.txt' # 非必填 存放ngrokToken的文件的路径\nuseFrpc=True\nfrpcConfigFile='/kaggle/input/configs/frpc_txt.ini' # 非必填 frp 配置文件\ndisableShared=False # 关闭默认的gradio.live穿透,如果没有配置ngrok或frp不要开启这个选项\n\n# 模型目录 \n# Stable Diffusion模型请放在这里(不用填模型的文件名,只填模型的目录即可)\nmodelDirs = ['/kaggle/input/admodels', '/kaggle/input/abyssoragemix2-nsfwvae',\n '/kaggle/input/nai-pruned', '/kaggle/input/models-pvc-style',\n '/kaggle/input/anythingmix3d','/kaggle/input/bloodorange',\n '/kaggle/input/counterfeit25','/kaggle/input/abyssorange3',\n '/kaggle/input/momoko','/kaggle/input/nicenice','/kaggle/input/moxing'\n ]\n# 启动时默认加载的模型名称 可填全路径或者模型名称,名称建议带上文件名后缀\n# 如果你想加载7G以上的大模型,请填这个来加载,直接在Webui里切换模型容易爆内存\nusedCkpt = 'Counterfeit-V2.5_pruned.safetensors'\n# Hypernetworks超网络模型路径请放在这里:\nhypernetworksModelDirs = ['/kaggle/input/nai-pruned/modules']\n# embeddings(pt文件)请放在这里:\nembeddingsModelDirs = ['/kaggle/input/easynegative2', \n # '/kaggle/input/bestpt/embeddings'\n] \n# Lora模型的数据集路径请写在这里:\nloraModelDirs = ['/kaggle/input/lora-r18','/kaggle/input/lora-r16',\n # '/kaggle/input/aaagen','/kaggle/input/loransfw'\n ] \n# 此配置内的目录下所有文件将加载到wildcards文件夹\nwildcardsFileDirs = ['/kaggle/input/wildcards'] \n\n# ControlNet模型请放在这里:\nControlnet = ['/kaggle/input/controlnet']\n\n# 将Lora模型放在可选附加网络扩展(占用内存高,拖慢启动速度。请注意!!)\nAdditionalNetworks = ['/kaggle/input/chibilora']\n\n# 插件列表: git仓库地址\n# 开启公网访问后将不能在webui界面安装插件,如果有需要安装的插件,把地址加入到下面\n# 不需要的插件在前面加 # ,插件地址之间需要用英语逗号隔开\nextensions = [\n # krita 绘图软件插件\n 'https://github.com/Interpause/auto-sd-paint-ext',\n # 汉化 对新功能没有完全覆盖\n 'https://github.com/2575044704/stable-diffusion-webui-localization-zh_CN', \n # 图片浏览器 不安装不能在webui界面查看图片\n 'https://github.com/yfszzx/stable-diffusion-webui-images-browser', \n # 自动tag补全插件 tag翻译文件在webui_settings这个配置里\n 'https://github.com/DominikDoom/a1111-sd-webui-tagcomplete', \n # 此插件会过滤重复标签和空标签、会将中文的逗号和括号替换成英文的逗号或括号,可能影响tag权重\n 'https://github.com/viyiviyi/filter-empty-prompts.git', \n # 可以使用__加文件名的方式从文件中随机读取一行加入到tag\n 'https://github.com/AUTOMATIC1111/stable-diffusion-webui-wildcards', \n # 提示词变迁插件 没用过 -_-\n 'https://github.com/Kahsolt/stable-diffusion-webui-prompt-travel.git' ,\n #美术风格\n 'https://github.com/AUTOMATIC1111/stable-diffusion-webui-aesthetic-gradients.git',\n # Lora的扩展(占内存,慎用)\n #'https://github.com/kohya-ss/sd-webui-additional-networks',\n # ControlNet\n 'https://github.com/Mikubill/sd-webui-controlnet',\n # OpenPose\n 'https://github.com/fkunn1326/openpose-editor'\n]\n\n# webui的配置文件 因为有比较多的人在用了,而个人喜好又不一样,所以这里可以使用自己的配置文件\n# 需要使用git仓库 需要将对应的文件放在仓库的 dist目录下,dist目录下的全部文件都会被复制到webui的根目录\nwebui_settings = 'https://github.com/2575044704/sd-configs2.git'\n# 设置文件路径 默认使用 webui_settings 里面的config.json 和 ui-config.json文件\nsetting_file = '/kaggle/input/configs/config.json'\nui_config_file = '/kaggle/input/configs/ui-config.json'\notherArgs = '' # '--api-auth=2333:6666 --gradio-auth=2333:6666' # 其他需要加载的webui启动参数\n\n# koishi相关\nuseKoishi = False # 是否开启Koishi机器人\nkoishiPort = 5140 # 使用7860将会占用webui的默认端口\n# 如果这个配置文件与上面的配置文件相同,可能会出问题\nkoishiFrpcConfig = '/kaggle/input/frpc-koishi/frpc_KOISHI.ini'\n# 可以将输出目录的文件下载后上传到数据集,下次启动就不用再配置一次\nkoishiPath = '/kaggle/input/koishiconfig/kaggle/koishi'","metadata":{"execution":{"iopub.status.busy":"2023-02-24T15:14:00.378978Z","iopub.execute_input":"2023-02-24T15:14:00.379501Z","iopub.status.idle":"2023-02-24T15:14:00.442840Z","shell.execute_reply.started":"2023-02-24T15:14:00.379394Z","shell.execute_reply":"2023-02-24T15:14:00.441879Z"},"trusted":true},"execution_count":1,"outputs":[]},{"cell_type":"code","source":"#第二个代码单元格,此处的设置一般不用动\n\n# 手机端界面优化 使用了修改过界面布局顺序的webui,不定期同步到官方版本\nmobileOptimize=False\n# 安装目录 如果安装目录在输出目录(/kaggle/working)下,建议不要开启 Save Version 功能,因为每次结束运行都需要等待上传全部文件\ninstall_path=\"/kaggle\" \n# 输出目录 默认将 图片输出目录和图片收藏目录连接到此目录下 可以在下方 【配置文件链接】 处开启链接其他文件夹(完全没有必要)\noutput_path=\"/kaggle/working\"\n\n# 配置启动参数\nquickStart=True # 快速启动 使用下载好的python环境 开启后启动到可用需要4分钟,不开启需要8分钟\nvaeHalf=False # vae开启半精度,关闭效果更好,对速度没啥影响\nmodelHalf=True # 模型开启半精度,关闭效果更好,但生成速度减半\nconsoleProgressbars=False # 控制台显示进度条,关闭可以减少一些输出内容,查看日志时更快一点\nconsolePrompts=False # 同上 \nenableLoadByCopy=False # 是否使用copy的方式加载文件 启动变慢,且测试后没有提高模型切换速度\n\n# 配置文件链接\nlinkHypernetworksDir=False # 链接 hypernetworks 目录到输出目录 如果需要训练 hypernetworks 时建议开启\nlinkEmbeddingsDir=False # 链接 embeddings 目录到输出目录 如果需要训练 embeddings 时建议开启\nlinkTextual_inversionDir=False # 链接 textual_inversion 目录到输出目录 如果需要保存训练过程的产出文件时建议开启\n\n# 这下面的是用于初始化一些值或者环境变量的,轻易别改\nfrom pathlib import Path\nimport os\nimport time\nimport re\nif not Path(frpcConfigFile).exists(): useFrpc = False\nos.environ['install_path'] = install_path\nos.environ['output_path'] = output_path\nos.environ['webui_settings'] = webui_settings\nos.environ['frpcConfig'] = frpcConfigFile\n\nngrokToken=''\nif Path(ngrokTokenFile).exists():\n with open(ngrokTokenFile,encoding = \"utf-8\") as nkfile:\n ngrokToken = nkfile.readline()","metadata":{"execution":{"iopub.status.busy":"2023-02-24T15:14:00.447665Z","iopub.execute_input":"2023-02-24T15:14:00.448238Z","iopub.status.idle":"2023-02-24T15:14:00.468489Z","shell.execute_reply.started":"2023-02-24T15:14:00.448203Z","shell.execute_reply":"2023-02-24T15:14:00.467598Z"},"trusted":true},"execution_count":2,"outputs":[]},{"cell_type":"code","source":"# 重置变量 用于修改参数后重新安装\nreLoad = True\n# 如果需要重新安装,请注释这一行\nreLoad = False","metadata":{"execution":{"iopub.status.busy":"2023-02-24T15:14:00.474605Z","iopub.execute_input":"2023-02-24T15:14:00.478620Z","iopub.status.idle":"2023-02-24T15:14:00.486133Z","shell.execute_reply.started":"2023-02-24T15:14:00.475204Z","shell.execute_reply":"2023-02-24T15:14:00.484993Z"},"trusted":true},"execution_count":3,"outputs":[]},{"cell_type":"code","source":"# Koishi https://koishi.chat/\ndef installKoishi():\n !echo '安装koishi和相关依赖'\n %cd $install_path\n !mkdir -p koishi\n %cd koishi\n !apt-get update\n !apt-get install chromium-browser -y\n if Path(koishiPath).exists():\n os.system('cp -f -n '+koishiPath+'/* ./')\n else:\n !npm init -y\n !npm i koishi -D\n !npx koishi init\n !npm i @koishijs/plugin-logger @koishijs/plugin-market @koishijs/plugin-console -D\n !npm i @koishijs/plugin-auth @koishijs/plugin-status @koishijs/plugin-insight -D\n !npm i\n \ndef startKoishi():\n %cd $install_path/koishi\n if Path('koishi.config.yml').exists():\n !pm2 del koishi\n !pm2 start npx -n koishi -- koishi start koishi.config.yml\n return\n content = f'''\n# 全局设置\nhost: localhost\n# 端口\nport: {koishiPort}\n# 插件列表\nplugins:\n # group 表示这是一个插件组\n group:console:\n # 波浪线前缀表示一个不启用的插件\n auth: \n console:\n logger:\n status:\n insight:\n market:\n'''\n !mkdir -p $install_path/koishi/\n with open('koishi.config.yml','w') as sh:\n sh.write(content)\n !pm2 del koishi\n !pm2 start npx -n koishi -- koishi start koishi.config.yml\n\ndef startKoishFrpc():\n !pm2 del frpc_koishi\n os.system('pm2 start $install_path/frpc/frpc -n frpc_koishi -- -c '+koishiFrpcConfig)\n \ndef saveKoishi():\n %cd /kaggle/working/\n !tar -cvf koishi.tar --exclude=koishi/node_modules --exclude=koishi/logs $install_path/koishi \n\n# 每10分钟保存一次koishi的数据\ndef autoZipKoishiData():\n %cd $install_path\n content = '''\nsetInterval(() => {\n try {\n const { exec } = require('child_process');\n exec('tar -cvf /kaggle/working/koishi.tar --exclude=koishi/node_modules --exclude=koishi/logs $install_path/koishi');\n console.log('每10分钟保存一次数据');\n } catch (error) {\n console.error('保存数据失败');\n }\n}, 1000 * 60 * 10);\n '''\n with open('autoZipKoishiData.js','w') as sh:\n sh.write(content)\n !pm2 del autoZipKoishiData\n !pm2 start autoZipKoishiData.js -n autoZipKoishiData","metadata":{"execution":{"iopub.status.busy":"2023-02-24T15:14:00.492431Z","iopub.execute_input":"2023-02-24T15:14:00.497206Z","iopub.status.idle":"2023-02-24T15:14:00.845851Z","shell.execute_reply.started":"2023-02-24T15:14:00.495532Z","shell.execute_reply":"2023-02-24T15:14:00.844271Z"},"trusted":true},"execution_count":4,"outputs":[]},{"cell_type":"code","source":"# 功能函数\n# 绕过 os.systen 的限制执行命令\ndef run(shell:str):\n with open('run_cache.sh','w') as sh:\n sh.write(shell)\n !bash run_cache.sh\n\n# 连接多个路径字符串 让路径在shell命令中能正常的执行\ndef pathJoin(*paths:str):\n pathStr = ''\n for p in paths:\n pathStr += '\"'+p+'\"'\n pathStr = '\"*\"'.join(pathStr.split('*'))\n pathStr = '\"$\"'.join(pathStr.split('$'))\n pathStr = '\"(\"'.join(pathStr.split('('))\n pathStr = '\")\"'.join(pathStr.split(')'))\n pathStr = '\"{\"'.join(pathStr.split('{'))\n pathStr = '\"}\"'.join(pathStr.split('}'))\n pathStr = re.sub(r'\"\"','',pathStr)\n pathStr = re.sub(r'\\*{2,}','\"',pathStr)\n pathStr = re.sub(r'/{2,}','/',pathStr)\n pathStr = re.sub(r'/\\./','/',pathStr)\n return pathStr\n\n# 判断路径是不是一个文件或者可能指向一些文件\ndef pathIsFile(path):\n if Path(path).is_file():\n return True\n if re.search(r'\\.(ckpt|safetensors|png|jpg|txt|pt|pth|json|yaml|\\*)$',path):\n return True\n return False\n\ndef installEnv():\n !npm i -g pm2\n\n#安装webui\ndef install():\n %cd $install_path\n if reLoad:\n !rm -rf stable-diffusion-webui\n if Path(\"stable-diffusion-webui\").exists():\n %cd $install_path/stable-diffusion-webui/\n !git checkout .\n !git pull\n else:\n if mobileOptimize:\n !git clone https://github.com/viyiviyi/stable-diffusion-webui.git -b local # 修改了前端界面,手机使用更方便\n else:\n !git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui \n %cd $install_path/stable-diffusion-webui/\n if quickStart:\n !echo \"解压Python环境... unzip venv\"\n !tar -xf /kaggle/input/stable-diffusion-venv/venv.tar.bak -C ./\n\n# 链接输出目录\ndef link_dir():\n # 链接输出目录 因为sd被部署在了stable-diffusion-webui目录,运行结束后为了方便下载就只有outputs目录放在output_path/目录下\n !mkdir -p $output_path/outputs\n !rm -rf $install_path/stable-diffusion-webui/outputs\n !ln -s -r $output_path/outputs $install_path/stable-diffusion-webui/ # 输出目录\n !mkdir -p $output_path/log\n !rm -rf $install_path/stable-diffusion-webui/log\n !ln -s -r $output_path/log $install_path/stable-diffusion-webui/\n # 链接 hypernetworks 目录\n if linkHypernetworksDir:\n !rm -rf $install_path/stable-diffusion-webui/models/hypernetworks\n !mkdir -p $output_path/hypernetworks\n !ln -s -r $output_path/hypernetworks $install_path/stable-diffusion-webui/models/\n # 链接 embeddings 目录\n if linkEmbeddingsDir:\n !rm -rf $install_path/stable-diffusion-webui/embeddings\n !mkdir -p $output_path/embeddings\n !ln -s -r $output_path/embeddings $install_path/stable-diffusion-webui/\n # 链接训练输出目录 文件夹链接会导致功能不能用\n if linkTextual_inversionDir:\n !rm -rf $install_path/stable-diffusion-webui/textual_inversion\n !mkdir -p $output_path/textual_inversion/\n !ln -s -r $output_path/textual_inversion $install_path/stable-diffusion-webui/\n\n# 链接模型文件\n# link models files\ndef link_models():\n print(('复制' if enableLoadByCopy else '链接') + '模型文件')\n if enableLoadByCopy:\n print('如果出现 No such file or directory 错误,可以忽略')\n !mkdir -p $install_path/stable-diffusion-webui/models/Stable-diffusion # 模型和文件目录\n !mkdir -p $install_path/stable-diffusion-webui/models/hypernetworks # 超网络模型目录\n !mkdir -p $install_path/stable-diffusion-webui/embeddings # 画风模型目录\n !mkdir -p $install_path/stable-diffusion-webui/models/Lora # lora 文件目录\n !mkdir -p $install_path/stable-diffusion-webui/extensions/stable-diffusion-webui-wildcards/wildcards # wildcards 文件目录\n !mkdir -p $install_path/stable-diffusion-webui/extensions/sd-webui-controlnet/models/ \n !mkdir -p $install_path/stable-diffusion-webui/extensions/sd-webui-additional-networks/models/lora\n !mkdir -p $install_path/stable-diffusion-webui/extensions/sd-webui-additional-networks/models/lora # lora 文件目录\n \n for path in modelDirs:\n if pathIsFile(path):\n os.system(('cp -n' if enableLoadByCopy else 'ln -s')+' -f '+ pathJoin(path) +' $install_path/stable-diffusion-webui/models/Stable-diffusion')\n continue\n os.system(('cp -n' if enableLoadByCopy else 'ln -s')+' -f '+ pathJoin(path,'/*.ckpt') +' $install_path/stable-diffusion-webui/models/Stable-diffusion/')\n os.system(('cp -n' if enableLoadByCopy else 'ln -s')+' -f '+ pathJoin(path,'/*.safetensors') +' $install_path/stable-diffusion-webui/models/Stable-diffusion/')\n os.system(('cp -n' if enableLoadByCopy else 'ln -s')+' -f '+ pathJoin(path,'/*.png') +' $install_path/stable-diffusion-webui/models/Stable-diffusion/')\n os.system(('cp -n' if enableLoadByCopy else 'ln -s')+' -f '+ pathJoin(path,'/*.jpg') +' $install_path/stable-diffusion-webui/models/Stable-diffusion/')\n os.system(('cp -n' if enableLoadByCopy else 'ln -s')+' -f '+ pathJoin(path,'/*.pt') +' $install_path/stable-diffusion-webui/models/Stable-diffusion/')\n os.system(('cp -n' if enableLoadByCopy else 'ln -s')+' -f '+ pathJoin(path,'/hypernetworks*/*.*') +' $install_path/stable-diffusion-webui/models/hypernetworks/')\n os.system(('cp -n' if enableLoadByCopy else 'ln -s')+' -f '+ pathJoin(path,'/embeddings*/*.*') +' $install_path/stable-diffusion-webui/embeddings/')\n os.system(('cp -n' if enableLoadByCopy else 'ln -s')+' -f '+ pathJoin(path,'/lora*/*.*') +' $install_path/stable-diffusion-webui/models/Lora/')\n os.system(('cp -n' if enableLoadByCopy else 'ln -s')+' -f '+ pathJoin(path,'/wildcards*/*.*') +' $install_path/stable-diffusion-webui/extensions/stable-diffusion-webui-wildcards/wildcards/')\n for path in wildcardsFileDirs:\n if pathIsFile(path):\n os.system(('cp -n' if enableLoadByCopy else 'ln -s')+' -f '+ pathJoin(path) +' $install_path/stable-diffusion-webui/extensions/stable-diffusion-webui-wildcards/wildcards/')\n continue\n os.system(('cp -n' if enableLoadByCopy else 'ln -s')+' -f '+ pathJoin(path,'/*.*') +' $install_path/stable-diffusion-webui/extensions/stable-diffusion-webui-wildcards/wildcards/')\n for path in loraModelDirs: \n if pathIsFile(path):\n os.system(('cp -n' if enableLoadByCopy else 'ln -s')+' -f '+ pathJoin(path) +' $install_path/stable-diffusion-webui/models/Lora/')\n continue\n os.system(('cp -n' if enableLoadByCopy else 'ln -s')+' -f '+ pathJoin(path,'/*.*') +' $install_path/stable-diffusion-webui/models/Lora/')\n for path in embeddingsModelDirs: \n if pathIsFile(path):\n os.system(('cp -n' if enableLoadByCopy else 'ln -s')+' -f '+ pathJoin(path) +' $install_path/stable-diffusion-webui/embeddings/')\n continue\n os.system(('cp -n' if enableLoadByCopy else 'ln -s')+' -f '+ pathJoin(path,'/*.*') +' $install_path/stable-diffusion-webui/embeddings/')\n for path in hypernetworksModelDirs: \n if pathIsFile(path):\n os.system(('cp -n' if enableLoadByCopy else 'ln -s')+' -f '+ pathJoin(path) +' $install_path/stable-diffusion-webui/models/hypernetworks/')\n continue\n os.system(('cp -n' if enableLoadByCopy else 'ln -s')+' -f '+ pathJoin(path,'/*.*') +' $install_path/stable-diffusion-webui/models/hypernetworks/')\n if Path(install_path+'/stable-diffusion-webui/extensions/sd-webui-controlnet').exists():\n for path in Controlnet: \n if pathIsFile(path):\n os.system(('cp -n' if enableLoadByCopy else 'ln -s')+' -f '+ pathJoin(path) +' $install_path/stable-diffusion-webui/extensions/sd-webui-controlnet/models/')\n continue\n os.system(('cp -n' if enableLoadByCopy else 'ln -s')+' -f ' + pathJoin(path,'/*.*') +' $install_path/stable-diffusion-webui/extensions/sd-webui-controlnet/models/')\n if Path(install_path+'/stable-diffusion-webui/extensions/sd-webui-additional-networks').exists():\n for path in AdditionalNetworks: \n if pathIsFile(path):\n os.system(('cp -n' if enableLoadByCopy else 'ln -s')+' -f '+ pathJoin(path) +' $install_path/stable-diffusion-webui/extensions/sd-webui-additional-networks/models/lora/')\n continue\n os.system(('cp -n' if enableLoadByCopy else 'ln -s')+' -f ' + pathJoin(path,'/*.*') +' $install_path/stable-diffusion-webui/extensions/sd-webui-additional-networks/models/lora/')\n \n \n %cd $install_path/stable-diffusion-webui/extensions/sd-webui-controlnet/models/\n !rm -f \\*.* # 删除因为文件夹没有对应文件导致复制了一个'*.*'的文件\n !echo controlnetModel文件列表\n !ls\n\n %cd $install_path/stable-diffusion-webui/models/Stable-diffusion\n !rm -f \\*.* & rm -f \\*.ckpt & rm -f \\*.safetensors & rm -f \\*.png & rm -f \\*.pt & rm -f \\*.jpg # 删除因为文件夹没有对应文件导致复制了一个'*.*'的文件\n !echo 模型文件列表\n !ls\n %cd $install_path/stable-diffusion-webui/models/hypernetworks\n !rm -f \\*.* # 删除因为文件夹没有对应文件导致复制了一个'*.*'的文件\n !echo hypernetworks超网络模型文件列表\n !ls\n %cd $install_path/stable-diffusion-webui/embeddings\n !rm -f \\*.* # 删除因为文件夹没有对应文件导致复制了一个'*.*'的文件\n !echo embedding文件列表\n !ls\n %cd $install_path/stable-diffusion-webui/models/Lora\n !rm -f \\*.* # 删除因为文件夹没有对应文件导致复制了一个'*.*'的文件\n !echo lora文件列表\n !ls\n %cd $install_path/stable-diffusion-webui/extensions/stable-diffusion-webui-wildcards/wildcards\n !rm -f \\*.* # 删除因为文件夹没有对应文件导致复制了一个'*.*'的文件\n !echo wildcards文件列表\n !ls\n \n#安装依赖\ndef install_dependencies():\n %cd $install_path/stable-diffusion-webui\n !python3 -m venv venv\n !source venv/bin/activate\n !COMMANDLINE_ARGS=\"--exit\" REQS_FILE=\"requirements.txt\" venv/bin/python3 launch.py\n\n# 安装插件\ndef install_extensions():\n print('安装插件')\n %cd $install_path/stable-diffusion-webui\n !mkdir -p extensions\n %cd extensions\n !rm -rf sd-webui-additional-networks\n !git clone https://github.com/kohya-ss/sd-webui-additional-networks #安装lora扩展\n for ex in extensions:\n os.system('git clone '+ex)\n #Tag选择器\n !cp -r /kaggle/input/tagextensions/maple-from-fall-and-flower $install_path/stable-diffusion-webui/extensions/maple-from-fall-and-flower\n \n# 个性化配置 \ndef use_config():\n %cd $install_path/stable-diffusion-webui\n !mkdir -p tmp\n %cd tmp\n !git clone $webui_settings sd-configs\n !cp -rf sd-configs/dist/* $install_path/stable-diffusion-webui\n \n# ngrok\ndef ngrok_start():\n if useNgrok == True and ngrokToken != '':\n print('use nrgok')\n !pip install pyngrok\n from pyngrok import conf, ngrok\n conf.get_default().auth_token = ngrokToken\n conf.get_default().monitor_thread = False\n ssh_tunnels = ngrok.get_tunnels(conf.get_default())\n if len(ssh_tunnels) == 0:\n ssh_tunnel = ngrok.connect(7860)\n print('address:'+ssh_tunnel.public_url)\n else:\n print('address:'+ssh_tunnels[0].public_url)\n else:\n print('skip start ngrok')\n \ndef installFrpc():\n %cd $install_path\n !mkdir -p frpc\n %cd frpc\n !cp -f -n /kaggle/input/net-tools/frpc ./frpc\n !chmod +x ./frpc\n !./frpc -v\n \ndef startFrpc():\n if useFrpc:\n !pm2 del frpc_webui\n !pm2 start $install_path/frpc/frpc -n frpc_webui -- -c $frpcConfig\n \ndef installBore():\n %cd $install_path\n !mkdir -p bore\n %cd bore\n !cp -f -n /kaggle/input/net-tools/bore ./bore\n !chmod +x ./bore\n\ndef startBore():\n !pm2 del bore\n !pm2 start $install_path/bore/bore -n bore -- local 5140 --to bore.pub\n \n# 打包输出图片到$output_path/outputs.tar文件\ndef zip_output():\n !echo \"打包输出图片到$output_path/outputs.tar文件\"\n %cd $install_path/stable-diffusion-webui/\n !tar -cf outputs.tar ./outputs\n !mv ./outputs.tar $output_path/\n \n# 启动\ndef start():\n %cd $install_path/stable-diffusion-webui\n !python3 -m venv venv\n !source venv/bin/activate\n args = '--disable-safe-unpickle --deepdanbooru'\n if not disableShared:\n args += ' --share'\n args += ' --skip-torch-cuda-test'\n args += ' --xformers' # 已经可用\n args += ' --api --listen' # 开放 api\n args += ' --lowram' # 降低爆内存几率\n if ui_config_file is not None and ui_config_file != '' and Path(ui_config_file).exists(): # ui配置文件\n args += ' --ui-config-file=' + pathJoin(ui_config_file)\n if setting_file is not None and setting_file != '' and Path(setting_file).exists(): # 设置配置文件\n args += ' --ui-settings-file=' + pathJoin(setting_file)\n if usedCkpt is not None and usedCkpt != '': # 设置启动时默认加载的模型\n if '.' in usedCkpt:\n if '/' in usedCkpt:\n args += ' --ckpt='+ pathJoin(usedCkpt)\n else:\n args += ' --ckpt='+ pathJoin(install_path, '/stable-diffusion-webui/models/Stable-diffusion/', usedCkpt)\n else:\n for x in ['.ckpt','.safetensors']:\n if Path(install_path+'/stable-diffusion-webui/models/Stable-diffusion/' + usedCkpt+x).exists():\n args += ' --ckpt='+ pathJoin(install_path, '/stable-diffusion-webui/models/Stable-diffusion/', usedCkpt, x)\n break\n if vaeHalf is False: \n args += ' --no-half-vae'\n if modelHalf is False:\n args += ' --no-half'\n if consoleProgressbars is False:\n args += ' --disable-console-progressbars'\n if consolePrompts is True:\n args += ' --enable-console-prompts'\n args += ' ' + otherArgs\n os.environ['COMMANDLINE_ARGS']=args\n !echo COMMANDLINE_ARGS=$COMMANDLINE_ARGS\n %env REQS_FILE=requirements.txt\n !pm2 log & venv/bin/python3 launch.py\n\ndef main():\n startTicks = time.time()\n isInstall = True if os.getenv('IsInstall','False') == 'True' else False\n if isInstall is False or reLoad:\n install()\n install_dependencies()\n install_extensions()\n installEnv()\n use_config()\n link_dir()\n installFrpc()\n if useKoishi:\n installKoishi()\n isInstall = True\n os.environ['IsInstall'] = 'True'\n link_models()\n ticks = time.time()\n print(\"加载耗时:\",(ticks - startTicks),\"s\")\n ngrok_start()\n startFrpc()\n if useKoishi:\n startKoishFrpc()\n startKoishi()\n autoZipKoishiData()\n start()\n","metadata":{"execution":{"iopub.status.busy":"2023-02-24T15:14:00.852924Z","iopub.execute_input":"2023-02-24T15:14:00.853713Z","iopub.status.idle":"2023-02-24T15:14:04.761822Z","shell.execute_reply.started":"2023-02-24T15:14:00.853676Z","shell.execute_reply":"2023-02-24T15:14:04.760684Z"},"trusted":true},"execution_count":5,"outputs":[]},{"cell_type":"code","source":"# 启动的输出日志,等待约5分钟,最终会得到一个gradio.live的链接,但如果出现Error这个词,说明出错了。请联系管理员解决该问题\n# start\nmain()\n\nif useKoishi:\n saveKoishi()","metadata":{"scrolled":true,"execution":{"iopub.status.busy":"2023-02-24T15:14:04.763379Z","iopub.execute_input":"2023-02-24T15:14:04.764242Z"},"trusted":true},"execution_count":null,"outputs":[{"name":"stdout","text":"/kaggle\nCloning into 'stable-diffusion-webui'...\nremote: Enumerating objects: 16434, done.\u001b[K\nremote: Total 16434 (delta 0), reused 0 (delta 0), pack-reused 16434\u001b[K\nReceiving objects: 100% (16434/16434), 27.51 MiB | 28.54 MiB/s, done.\nResolving deltas: 100% (11495/11495), done.\n/kaggle/stable-diffusion-webui\n解压Python环境... unzip venv\n/kaggle/stable-diffusion-webui\nPython 3.7.12 | packaged by conda-forge | (default, Oct 26 2021, 06:08:53) \n[GCC 9.4.0]\nCommit hash: 0cc0ee1bcb4c24a8c9715f66cede06601bfc00c8\nCloning Stable Diffusion into repositories/stable-diffusion-stability-ai...\nCloning Taming Transformers into repositories/taming-transformers...\nCloning K-diffusion into repositories/k-diffusion...\nCloning CodeFormer into repositories/CodeFormer...\nCloning BLIP into repositories/BLIP...\nInstalling requirements for Web UI\nExiting because of --exit argument\n安装插件\n/kaggle/stable-diffusion-webui\n/kaggle/stable-diffusion-webui/extensions\nCloning into 'sd-webui-additional-networks'...\nremote: Enumerating objects: 545, done.\u001b[K\nremote: Counting objects: 100% (244/244), done.\u001b[K\nremote: Compressing objects: 100% (129/129), done.\u001b[K\nremote: Total 545 (delta 155), reused 133 (delta 113), pack-reused 301\u001b[K\nReceiving objects: 100% (545/545), 165.75 KiB | 3.13 MiB/s, done.\nResolving deltas: 100% (272/272), done.\n","output_type":"stream"},{"name":"stderr","text":"Cloning into 'auto-sd-paint-ext'...\nCloning into 'stable-diffusion-webui-localization-zh_CN'...\nCloning into 'stable-diffusion-webui-images-browser'...\nCloning into 'a1111-sd-webui-tagcomplete'...\nCloning into 'filter-empty-prompts'...\nCloning into 'stable-diffusion-webui-wildcards'...\nCloning into 'stable-diffusion-webui-prompt-travel'...\nCloning into 'stable-diffusion-webui-aesthetic-gradients'...\nCloning into 'sd-webui-controlnet'...\nCloning into 'openpose-editor'...\n","output_type":"stream"},{"name":"stdout","text":"\u001b[K\u001b[?25h\u001b[37;40mnpm\u001b[0m \u001b[0m\u001b[30;43mWARN\u001b[0m \u001b[0m\u001b[35mdeprecated\u001b[0m uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.\n\u001b[K\u001b[?25hm##################\u001b[0m) ⠙ reify:lodash: \u001b[32;40mhttp\u001b[0m \u001b[35mfetch\u001b[0m GET 200 https://registry.npmjs.\u001b[0m\u001b[Kpmjs.o\u001b[0m\u001b[Kjs.\u001b[0m\u001b[K\nadded 184 packages, and audited 185 packages in 10s\n\n12 packages are looking for funding\n run `npm fund` for details\n\nfound \u001b[32m\u001b[1m0\u001b[22m\u001b[39m vulnerabilities\n\u001b[37;40mnpm\u001b[0m \u001b[0m\u001b[36;40mnotice\u001b[0m\u001b[35m\u001b[0m \n\u001b[0m\u001b[37;40mnpm\u001b[0m \u001b[0m\u001b[36;40mnotice\u001b[0m\u001b[35m\u001b[0m New \u001b[31mmajor\u001b[39m version of npm available! \u001b[31m8.5.5\u001b[39m -> \u001b[32m9.5.1\u001b[39m\n\u001b[0m\u001b[37;40mnpm\u001b[0m \u001b[0m\u001b[36;40mnotice\u001b[0m\u001b[35m\u001b[0m Changelog: \u001b[36mhttps://github.com/npm/cli/releases/tag/v9.5.1\u001b[39m\n\u001b[0m\u001b[37;40mnpm\u001b[0m \u001b[0m\u001b[36;40mnotice\u001b[0m\u001b[35m\u001b[0m Run \u001b[32mnpm install -g npm@9.5.1\u001b[39m to update!\n\u001b[0m\u001b[37;40mnpm\u001b[0m \u001b[0m\u001b[36;40mnotice\u001b[0m\u001b[35m\u001b[0m \n\u001b[0m/kaggle/stable-diffusion-webui\n/kaggle/stable-diffusion-webui/tmp\nCloning into 'sd-configs'...\nremote: Enumerating objects: 23, done.\u001b[K\nremote: Counting objects: 100% (23/23), done.\u001b[K\nremote: Compressing objects: 100% (18/18), done.\u001b[K\nremote: Total 23 (delta 4), reused 0 (delta 0), pack-reused 0\u001b[K\nUnpacking objects: 100% (23/23), 1.13 MiB | 4.91 MiB/s, done.\n/kaggle\n/kaggle/frpc\n0.45.0-sakura-2.3\n链接模型文件\n/kaggle/stable-diffusion-webui/extensions/sd-webui-controlnet/models\ncontrolnetModel文件列表\ncldm_v15.yaml control_canny-fp16.safetensors sketch_adapter_v14.yaml\ncldm_v21.yaml image_adapter_v14.yaml\n/kaggle/stable-diffusion-webui/models/Stable-diffusion\n模型文件列表\n AOM3.safetensors\n AOM3A2.safetensors\n AOM3A3.safetensors\n'AbyssOrangeMix2_hard .safetensors'\n AbyssOrangeMix2_nsfw.safetensors\n Anything-V3.0.ckpt\n Anything-V3.0.png\n Anything-V3.0.vae.pt\n Anything-v4.5.ckpt\n BloodNightOrangeMix.ckpt\n BloodOrangeMix_half.ckpt\n Counterfeit-V2.5_pruned.safetensors\n EerieOrangeMix2.safetensors\n OrangeMeat-V2.0.ckpt\n'Put Stable Diffusion checkpoints here.txt'\n animefull-final-pruned.ckpt\n animevae.pt\n'momochaandmetcha .ckpt'\n orangemix.vae.pt\n pvc-1.png\n pvc-1.safetensors\n pvc-4.png\n pvc-4.safetensors\n/kaggle/stable-diffusion-webui/models/hypernetworks\nhypernetworks超网络模型文件列表\naini.pt anime_3.pt\tfurry_3.pt\t furry_scalie.pt\nanime.pt furry.pt\tfurry_kemono.pt furry_transformation.pt\nanime_2.pt furry_2.pt\tfurry_protogen.pt pony.pt\n/kaggle/stable-diffusion-webui/embeddings\nembedding文件列表\n EasyNegative.pt 'Place Textual Inversion embeddings here.txt'\n/kaggle/stable-diffusion-webui/models/Lora\nlora文件列表\n lora_1-endure.png\t\t 'lora_2-Amakawa Hano_VTuber.png'\n lora_1-endure.pt\t\t 'lora_2-Amakawa Hano_VTuber.pt'\n'lora_1-highleg leotard.png'\t lora_2-Daiya.png\n'lora_1-highleg leotard.safetensors' lora_2-Daiya.pt\n'lora_1-mouth hold skirt.png'\t lora_2-Egil.png\n'lora_1-mouth hold skirt.safetensors' lora_2-Egil.pt\n lora_1-shadow_face.png\t\t 'lora_2-Misono Mika.png'\n lora_1-shadow_face.pt\t\t 'lora_2-Misono Mika.pt'\n lora_1-veil.png\t\t lora_2-Mobius.png\n lora_1-veil.pt\t\t\t lora_2-Mobius.safetensors\n lora_1-yandere.png\t\t lora_2-Murasame.png\n lora_1-yandere.pt\t\t lora_2-Murasame.safetensors\n lora_2-2022miku.png\t\t 'lora_2-PA san.png'\n lora_2-2022miku.pt\t\t 'lora_2-PA san.pt'\n lora_2-416.png\t\t\t lora_2-yuel.png\n lora_2-416.safetensors\t\t lora_2-yuel.pt\n/kaggle/stable-diffusion-webui/extensions/stable-diffusion-webui-wildcards/wildcards\nwildcards文件列表\n'put wildcards here.txt'\n加载耗时: 176.27393794059753 s\nskip start ngrok\n/kaggle/stable-diffusion-webui\nCOMMANDLINE_ARGS=--disable-safe-unpickle --deepdanbooru --share --skip-torch-cuda-test --xformers --api --listen --lowram --ckpt=\"/kaggle/stable-diffusion-webui/models/Stable-diffusion/Counterfeit-V2.5_pruned.safetensors\" --no-half-vae --disable-console-progressbars\nenv: REQS_FILE=requirements.txt\nPython 3.7.12 | packaged by conda-forge | (default, Oct 26 2021, 06:08:53) \n[GCC 9.4.0]\nCommit hash: 0cc0ee1bcb4c24a8c9715f66cede06601bfc00c8\nInstalling requirements for Web UI\n\n -------------\n\n__/\\\\\\\\\\\\\\\\\\\\\\\\\\____/\\\\\\\\____________/\\\\\\\\____/\\\\\\\\\\\\\\\\\\_____\n _\\/\\\\\\/////////\\\\\\_\\/\\\\\\\\\\\\________/\\\\\\\\\\\\__/\\\\\\///////\\\\\\___\n _\\/\\\\\\_______\\/\\\\\\_\\/\\\\\\//\\\\\\____/\\\\\\//\\\\\\_\\///______\\//\\\\\\__\n _\\/\\\\\\\\\\\\\\\\\\\\\\\\\\/__\\/\\\\\\\\///\\\\\\/\\\\\\/_\\/\\\\\\___________/\\\\\\/___\n _\\/\\\\\\/////////____\\/\\\\\\__\\///\\\\\\/___\\/\\\\\\________/\\\\\\//_____\n _\\/\\\\\\_____________\\/\\\\\\____\\///_____\\/\\\\\\_____/\\\\\\//________\n _\\/\\\\\\_____________\\/\\\\\\_____________\\/\\\\\\___/\\\\\\/___________\n _\\/\\\\\\_____________\\/\\\\\\_____________\\/\\\\\\__/\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\_\n _\\///______________\\///______________\\///__\\///////////////__\n\n\n Runtime Edition\n\n PM2 is a Production Process Manager for Node.js applications\n with a built-in Load Balancer.\n\n Start and Daemonize any application:\n $ pm2 start app.js\n\n Load Balance 4 instances of api.js:\n $ pm2 start api.js -i 4\n\n Monitor in production:\n $ pm2 monitor\n\n Make pm2 auto-boot at server restart:\n $ pm2 startup\n\n To go further checkout:\n http://pm2.io/\n\n\n -------------\n\n\u001b[32m[PM2] \u001b[39mSpawning PM2 daemon with pm2_home=/root/.pm2\n\u001b[32m[PM2] \u001b[39mPM2 Successfully daemonized\n\u001b[1m\u001b[90m[TAILING] Tailing last 15 lines for [all] processes (change the value with --lines option)\u001b[39m\u001b[22m\n\u001b[90m/root/.pm2/pm2.log last 15 lines:\u001b[39m\n\u001b[34mPM2 | \u001b[39m2023-02-24T15:17:09: PM2 log: --- New PM2 Daemon started ----------------------------------------------------\n\u001b[34mPM2 | \u001b[39m2023-02-24T15:17:09: PM2 log: Time : Fri Feb 24 2023 15:17:09 GMT+0000 (Coordinated Universal Time)\n\u001b[34mPM2 | \u001b[39m2023-02-24T15:17:09: PM2 log: PM2 version : 5.2.2\n\u001b[34mPM2 | \u001b[39m2023-02-24T15:17:09: PM2 log: Node.js version : 17.9.0\n\u001b[34mPM2 | \u001b[39m2023-02-24T15:17:09: PM2 log: Current arch : x64\n\u001b[34mPM2 | \u001b[39m2023-02-24T15:17:09: PM2 log: PM2 home : /root/.pm2\n\u001b[34mPM2 | \u001b[39m2023-02-24T15:17:09: PM2 log: PM2 PID file : /root/.pm2/pm2.pid\n\u001b[34mPM2 | \u001b[39m2023-02-24T15:17:09: PM2 log: RPC socket file : /root/.pm2/rpc.sock\n\u001b[34mPM2 | \u001b[39m2023-02-24T15:17:09: PM2 log: BUS socket file : /root/.pm2/pub.sock\n\u001b[34mPM2 | \u001b[39m2023-02-24T15:17:09: PM2 log: Application log path : /root/.pm2/logs\n\u001b[34mPM2 | \u001b[39m2023-02-24T15:17:09: PM2 log: Worker Interval : 30000\n\u001b[34mPM2 | \u001b[39m2023-02-24T15:17:09: PM2 log: Process dump file : /root/.pm2/dump.pm2\n\u001b[34mPM2 | \u001b[39m2023-02-24T15:17:09: PM2 log: Concurrent actions : 2\n\u001b[34mPM2 | \u001b[39m2023-02-24T15:17:09: PM2 log: SIGTERM timeout : 1600\n\u001b[34mPM2 | \u001b[39m2023-02-24T15:17:09: PM2 log: ===============================================================================\n\nInstalling requirements for Prompt Travel to generate video\n\n[auto-sd-paint-ext] Commit hash: 516f70cbc61aa5085ed9fe5e7818fa2976e01fd8\n[auto-sd-paint-ext] Auto-update disabled.\n\nInstalling sd-webui-controlnet requirement: svglib\n\nLaunching Web UI with arguments: --disable-safe-unpickle --deepdanbooru --share --xformers --api --listen --lowram --ckpt=/kaggle/stable-diffusion-webui/models/Stable-diffusion/Counterfeit-V2.5_pruned.safetensors --no-half-vae --disable-console-progressbars\n[AddNet] Updating model hashes...\n100%|████████████████████████████████████████████| 1/1 [00:00<00:00, 116.66it/s]\n[AddNet] Updating model hashes...\n100%|███████████████████████████████████████████| 1/1 [00:00<00:00, 1807.11it/s]\nCalculating sha256 for /kaggle/stable-diffusion-webui/models/Stable-diffusion/Counterfeit-V2.5_pruned.safetensors: a074b8864e31b8681e40db3dfde0005df7b5309fd2a2f592a2caee59e4591cae\nLoading weights [a074b8864e] from /kaggle/stable-diffusion-webui/models/Stable-diffusion/Counterfeit-V2.5_pruned.safetensors\nCreating model from config: /kaggle/stable-diffusion-webui/configs/v1-inference.yaml\nLatentDiffusion: Running in eps-prediction mode\nDiffusionWrapper has 859.52 M params.\nDownloading (…)olve/main/vocab.json: 100%|███| 961k/961k [00:00<00:00, 6.03MB/s]\nDownloading (…)olve/main/merges.txt: 100%|███| 525k/525k [00:00<00:00, 3.71MB/s]\nDownloading (…)cial_tokens_map.json: 100%|██████| 389/389 [00:00<00:00, 162kB/s]\nDownloading (…)okenizer_config.json: 100%|██████| 905/905 [00:00<00:00, 398kB/s]\nDownloading (…)lve/main/config.json: 100%|██| 4.52k/4.52k [00:00<00:00, 467kB/s]\nLoading VAE weights specified in settings: /kaggle/stable-diffusion-webui/models/Stable-diffusion/orangemix.vae.pt\nApplying xformers cross attention optimization.\nTextual inversion embeddings loaded(1): EasyNegative\nModel loaded in 75.6s (calculate hash: 48.9s, load weights from disk: 9.2s, create model: 3.2s, apply weights to model: 3.3s, apply half(): 1.5s, load VAE: 8.7s, move model to device: 0.7s).\nRunning on local URL: http://0.0.0.0:7860\nRunning on public URL: https://32bbe959-ea86-4e62.gradio.live\n\nThis share link expires in 72 hours. For free permanent hosting and GPU upgrades (NEW!), check out Spaces: https://huggingface.co/spaces\nauto-sd-paint-ext:WARNING: Encryption key file doesn't exist at /kaggle/stable-diffusion-webui/xor_pass.txt.\nauto-sd-paint-ext:WARNING: Creating random encryption key.\nauto-sd-paint-ext:WARNING: Key in xor_pass.txt is completely optional. It can be used to encrypt messages between backend & Krita and is editable.\n100%|███████████████████████████████████████████| 24/24 [00:13<00:00, 1.78it/s]\n","output_type":"stream"}]},{"cell_type":"code","source":"# 如果需要关闭后台任务 比如frpc \n# 1 运行 pm2 ls 查看任务id\n# 2 运行 pm2 stop 任务id\n# !pm2 ls\n# !pm2 stop all # all 表示关闭全部","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### 交流群 632428790 (遇到问题可以找群主或者管理员解决)","metadata":{}}]}