Update Fooocus_onColabwithMM.ipynb
Browse files- Fooocus_onColabwithMM.ipynb +66 -19
Fooocus_onColabwithMM.ipynb
CHANGED
|
@@ -4,7 +4,8 @@
|
|
| 4 |
"metadata": {
|
| 5 |
"colab": {
|
| 6 |
"provenance": [],
|
| 7 |
-
"gpuType": "T4"
|
|
|
|
| 8 |
},
|
| 9 |
"kernelspec": {
|
| 10 |
"name": "python3",
|
|
@@ -16,6 +17,16 @@
|
|
| 16 |
"accelerator": "GPU"
|
| 17 |
},
|
| 18 |
"cells": [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
{
|
| 20 |
"cell_type": "markdown",
|
| 21 |
"source": [
|
|
@@ -24,7 +35,8 @@
|
|
| 24 |
"\n",
|
| 25 |
"----\n",
|
| 26 |
"- とにかく試したいなら「ランタイム」メニューで「すべてのセルを実行」を選び、2の下部の「<font color='darkred'>**約5分かかります**</font>」に進んでください。\n",
|
| 27 |
-
"- GPU
|
|
|
|
| 28 |
"----\n",
|
| 29 |
"# Foooocus + MM LoRA\n",
|
| 30 |
"\n",
|
|
@@ -44,6 +56,7 @@
|
|
| 44 |
"2. アニメ用のモデルを、animaPencilXL_v310.safetensors から animagine-xl-3.0.safetensors に変更\n",
|
| 45 |
"3. MM(Mikako Method)のプリセットを追加\n",
|
| 46 |
"4. 日本語化リソースの強化\n",
|
|
|
|
| 47 |
"\n",
|
| 48 |
"# 1.画像出力フォルダの設定\n",
|
| 49 |
"\n",
|
|
@@ -68,6 +81,16 @@
|
|
| 68 |
{
|
| 69 |
"cell_type": "code",
|
| 70 |
"source": [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
"# @markdown #保存フォルダの選択\n",
|
| 72 |
"from google.colab import drive\n",
|
| 73 |
"import os\n",
|
|
@@ -105,20 +128,23 @@
|
|
| 105 |
"\n",
|
| 106 |
"# 日本語パッチを追加\n",
|
| 107 |
"ja_json_url = \"https://raw.githubusercontent.com/aquapathos/FooocusJAni/refs/heads/main/ja.json\"\n",
|
|
|
|
| 108 |
"ja_json_path = \"/content/Fooocus/language/ja.json\"\n",
|
| 109 |
"os.makedirs(os.path.dirname(ja_json_path), exist_ok=True)\n",
|
| 110 |
"!curl -L -o {ja_json_path} {ja_json_url}\n",
|
| 111 |
"print(f\"ja.json downloaded and saved to {ja_json_path}\")\n",
|
| 112 |
"\n",
|
| 113 |
"# MM用のプリセットを追加\n",
|
| 114 |
-
"
|
|
|
|
| 115 |
"mm_json_path = \"/content/Fooocus/presets/mm_preset.json\"\n",
|
| 116 |
"os.makedirs(os.path.dirname(mm_json_path), exist_ok=True)\n",
|
| 117 |
"!curl -L -o {mm_json_path} {mm_json_url}\n",
|
| 118 |
"print(f\"mm_preset.json downloaded and saved to {mm_json_path}\")\n",
|
| 119 |
"\n",
|
| 120 |
"# アニメ版の設定ファイルのパッチ(最新版)を追加\n",
|
| 121 |
-
"
|
|
|
|
| 122 |
"anime_json_path = \"/content/Fooocus/presets/anime.json\"\n",
|
| 123 |
"os.makedirs(os.path.dirname(anime_json_path), exist_ok=True)\n",
|
| 124 |
"!curl -L -o {anime_json_path} {anime_json_url}\n",
|
|
@@ -127,7 +153,8 @@
|
|
| 127 |
"setup_finished = True"
|
| 128 |
],
|
| 129 |
"metadata": {
|
| 130 |
-
"id": "L6hh5BedZ0VJ"
|
|
|
|
| 131 |
},
|
| 132 |
"execution_count": null,
|
| 133 |
"outputs": []
|
|
@@ -162,25 +189,45 @@
|
|
| 162 |
"モデルタイプ = \"MM\" # @param [\"デフォルト\", \"アニメ\",\"MM\"] {allow-input: true}\n",
|
| 163 |
"\n",
|
| 164 |
"if 翻訳機能:\n",
|
|
|
|
| 165 |
" !git clone https://github.com/AlekPet/Fooocus_Extensions_AlekPet.git\n",
|
| 166 |
" !mv Fooocus_Extensions_AlekPet/prompt_translate/webui.py .\n",
|
| 167 |
" !mv Fooocus_Extensions_AlekPet/prompt_translate/modules/* ./modules\n",
|
| 168 |
" !sed -i.bak \"s/label='Enable translate', value=False/label='Enable translate', value=True/\" modules/module_translate.py\n",
|
| 169 |
" !sed -i.bak 's/\"default_prompt\": \"[^\"]*\"/\"default_prompt\": \"湖に映る逆さ絵の風景、人はいない、小さな田舎の家が建っている、家の前には赤いレトロな車、手前には色とりどりのコスモス畑\"/' presets/mm_preset.json\n",
|
| 170 |
-
"
|
| 171 |
-
"
|
| 172 |
-
"
|
| 173 |
-
"
|
| 174 |
-
"
|
| 175 |
-
"
|
| 176 |
-
"
|
| 177 |
-
"
|
| 178 |
-
"elif モデルタイプ == \"
|
| 179 |
-
"
|
| 180 |
-
"elif モデルタイプ == \"
|
| 181 |
-
"
|
| 182 |
-
"elif モデルタイプ == \"
|
| 183 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 184 |
],
|
| 185 |
"metadata": {
|
| 186 |
"cellView": "form",
|
|
|
|
| 4 |
"metadata": {
|
| 5 |
"colab": {
|
| 6 |
"provenance": [],
|
| 7 |
+
"gpuType": "T4",
|
| 8 |
+
"include_colab_link": true
|
| 9 |
},
|
| 10 |
"kernelspec": {
|
| 11 |
"name": "python3",
|
|
|
|
| 17 |
"accelerator": "GPU"
|
| 18 |
},
|
| 19 |
"cells": [
|
| 20 |
+
{
|
| 21 |
+
"cell_type": "markdown",
|
| 22 |
+
"metadata": {
|
| 23 |
+
"id": "view-in-github",
|
| 24 |
+
"colab_type": "text"
|
| 25 |
+
},
|
| 26 |
+
"source": [
|
| 27 |
+
"<a href=\"https://colab.research.google.com/github/aquapathos/FooocusJAni/blob/main/Fooocus_onColabwithMM.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
|
| 28 |
+
]
|
| 29 |
+
},
|
| 30 |
{
|
| 31 |
"cell_type": "markdown",
|
| 32 |
"source": [
|
|
|
|
| 35 |
"\n",
|
| 36 |
"----\n",
|
| 37 |
"- とにかく試したいなら「ランタイム」メニューで「すべてのセルを実行」を選び、2の下部の「<font color='darkred'>**約5分かかります**</font>」に進んでください。\n",
|
| 38 |
+
"- 無料ユーザの場合、GPUが割り当てられないことがあります。「<font color='darkblue'>**GPUバックエンドに接続できません**</font>」と表示された場合は、GPUが使えません。その場合、制限はありますが、CPUだけで動作するようにしてあります。\n",
|
| 39 |
+
"- CPUだけの場合、相当時間がかかります(体感で10倍ぐらい)。メモリも不足するため、速度重視で質を落とす設定となっております。本来の画像品質は得られなことをご承知ください。\n",
|
| 40 |
"----\n",
|
| 41 |
"# Foooocus + MM LoRA\n",
|
| 42 |
"\n",
|
|
|
|
| 56 |
"2. アニメ用のモデルを、animaPencilXL_v310.safetensors から animagine-xl-3.0.safetensors に変更\n",
|
| 57 |
"3. MM(Mikako Method)のプリセットを追加\n",
|
| 58 |
"4. 日本語化リソースの強化\n",
|
| 59 |
+
"5. CPU Only対応 (ただし10倍ほど時間がかかるので実用性は低い)\n",
|
| 60 |
"\n",
|
| 61 |
"# 1.画像出力フォルダの設定\n",
|
| 62 |
"\n",
|
|
|
|
| 81 |
{
|
| 82 |
"cell_type": "code",
|
| 83 |
"source": [
|
| 84 |
+
"# GPU のチェック\n",
|
| 85 |
+
"import torch\n",
|
| 86 |
+
"# Check for GPU availability\n",
|
| 87 |
+
"GPU_ready = torch.cuda.is_available()\n",
|
| 88 |
+
"if GPU_ready:\n",
|
| 89 |
+
" print(\"GPU が使えます\")\n",
|
| 90 |
+
"else:\n",
|
| 91 |
+
" print(\"GPU が割り当てられていないため CPUのみで実行します\")\n",
|
| 92 |
+
" print(\"非常に時間がかかりますがご了承ください\")\n",
|
| 93 |
+
"\n",
|
| 94 |
"# @markdown #保存フォルダの選択\n",
|
| 95 |
"from google.colab import drive\n",
|
| 96 |
"import os\n",
|
|
|
|
| 128 |
"\n",
|
| 129 |
"# 日本語パッチを追加\n",
|
| 130 |
"ja_json_url = \"https://raw.githubusercontent.com/aquapathos/FooocusJAni/refs/heads/main/ja.json\"\n",
|
| 131 |
+
"\n",
|
| 132 |
"ja_json_path = \"/content/Fooocus/language/ja.json\"\n",
|
| 133 |
"os.makedirs(os.path.dirname(ja_json_path), exist_ok=True)\n",
|
| 134 |
"!curl -L -o {ja_json_path} {ja_json_url}\n",
|
| 135 |
"print(f\"ja.json downloaded and saved to {ja_json_path}\")\n",
|
| 136 |
"\n",
|
| 137 |
"# MM用のプリセットを追加\n",
|
| 138 |
+
"mm_json_fname = \"mm_preset.json\" if GPU_ready else \"mm_cpu_preset.json\"\n",
|
| 139 |
+
"mm_json_url = f\"https://raw.githubusercontent.com/aquapathos/FooocusJAni/refs/heads/main/{mm_json_fname}\"\n",
|
| 140 |
"mm_json_path = \"/content/Fooocus/presets/mm_preset.json\"\n",
|
| 141 |
"os.makedirs(os.path.dirname(mm_json_path), exist_ok=True)\n",
|
| 142 |
"!curl -L -o {mm_json_path} {mm_json_url}\n",
|
| 143 |
"print(f\"mm_preset.json downloaded and saved to {mm_json_path}\")\n",
|
| 144 |
"\n",
|
| 145 |
"# アニメ版の設定ファイルのパッチ(最新版)を追加\n",
|
| 146 |
+
"anime_json_fname = \"anime.json\" if GPU_ready else \"anime_cpu.json\"\n",
|
| 147 |
+
"anime_json_url = f\"https://raw.githubusercontent.com/aquapathos/FooocusJAni/refs/heads/main/{anime_json_fname}\"\n",
|
| 148 |
"anime_json_path = \"/content/Fooocus/presets/anime.json\"\n",
|
| 149 |
"os.makedirs(os.path.dirname(anime_json_path), exist_ok=True)\n",
|
| 150 |
"!curl -L -o {anime_json_path} {anime_json_url}\n",
|
|
|
|
| 153 |
"setup_finished = True"
|
| 154 |
],
|
| 155 |
"metadata": {
|
| 156 |
+
"id": "L6hh5BedZ0VJ",
|
| 157 |
+
"cellView": "form"
|
| 158 |
},
|
| 159 |
"execution_count": null,
|
| 160 |
"outputs": []
|
|
|
|
| 189 |
"モデルタイプ = \"MM\" # @param [\"デフォルト\", \"アニメ\",\"MM\"] {allow-input: true}\n",
|
| 190 |
"\n",
|
| 191 |
"if 翻訳機能:\n",
|
| 192 |
+
" print(\"H\")\n",
|
| 193 |
" !git clone https://github.com/AlekPet/Fooocus_Extensions_AlekPet.git\n",
|
| 194 |
" !mv Fooocus_Extensions_AlekPet/prompt_translate/webui.py .\n",
|
| 195 |
" !mv Fooocus_Extensions_AlekPet/prompt_translate/modules/* ./modules\n",
|
| 196 |
" !sed -i.bak \"s/label='Enable translate', value=False/label='Enable translate', value=True/\" modules/module_translate.py\n",
|
| 197 |
" !sed -i.bak 's/\"default_prompt\": \"[^\"]*\"/\"default_prompt\": \"湖に映る逆さ絵の風景、人はいない、小さな田舎の家が建っている、家の前には赤いレトロな車、手前には色とりどりのコスモス畑\"/' presets/mm_preset.json\n",
|
| 198 |
+
" if not GPU_ready:\n",
|
| 199 |
+
" !sed -i.bak 's/HYPER_SD = 4/HYPER_SD = 3/' modules/flags.py\n",
|
| 200 |
+
" !sed -i.bak 's/1664\\*576/832\\*576/' modules/flags.py\n",
|
| 201 |
+
"\n",
|
| 202 |
+
"if GPU_ready:\n",
|
| 203 |
+
" # GPUが使える場合\n",
|
| 204 |
+
" if モデルタイプ == \"デフォルト\" and not 日本語メニュー:\n",
|
| 205 |
+
" !python entry_with_update.py --always-high-vram --output-path {target_local_dir} --share\n",
|
| 206 |
+
" elif モデルタイプ == \"デフォルト\" and 日本語メニュー :\n",
|
| 207 |
+
" !python entry_with_update.py --always-high-vram --output-path {target_local_dir} --share --language ja\n",
|
| 208 |
+
" elif モデルタイプ == \"アニメ\" and not 日本語メニュー:\n",
|
| 209 |
+
" !python entry_with_update.py --preset anime --always-high-vram --output-path {target_local_dir} --share\n",
|
| 210 |
+
" elif モデルタイプ == \"アニメ\" and 日本語メニュー:\n",
|
| 211 |
+
" !python entry_with_update.py --preset anime --always-high-vram --output-path {target_local_dir} --share --language ja\n",
|
| 212 |
+
" elif モデルタイプ == \"MM\" and not 日本語メニュー:\n",
|
| 213 |
+
" !python entry_with_update.py --preset mm_preset --always-high-vram --output-path {target_local_dir} --share\n",
|
| 214 |
+
" elif モデルタイプ == \"MM\" and 日本語メニュー:\n",
|
| 215 |
+
" !python entry_with_update.py --preset mm_preset --always-high-vram --output-path {target_local_dir} --share --language ja\n",
|
| 216 |
+
"else:\n",
|
| 217 |
+
" # CPU Only\n",
|
| 218 |
+
" # GPUが使える場合\n",
|
| 219 |
+
" if モデルタイプ == \"デフォルト\" and not 日本語メニュー:\n",
|
| 220 |
+
" !python entry_with_update.py --always-cpu 1 --vae-in-fp16 --unet-in-fp8-e5m2 --all-in-fp16 --attention-split --output-path {target_local_dir} --share\n",
|
| 221 |
+
" elif モデルタイプ == \"デフォルト\" and 日本語メニュー :\n",
|
| 222 |
+
" !python entry_with_update.py --always-cpu 1 --vae-in-fp16 --unet-in-fp8-e5m2 --all-in-fp16 --attention-split --output-path {target_local_dir} --share --language ja\n",
|
| 223 |
+
" elif モデルタイプ == \"アニメ\" and not 日本語メニュー:\n",
|
| 224 |
+
" !python entry_with_update.py --always-cpu 1 --vae-in-fp16 --unet-in-fp8-e5m2 --all-in-fp16 --attention-split --preset anime --output-path {target_local_dir} --share\n",
|
| 225 |
+
" elif モデルタイプ == \"アニメ\" and 日本語メニュー:\n",
|
| 226 |
+
" !python entry_with_update.py --always-cpu 1 --vae-in-fp16 --unet-in-fp8-e5m2 --all-in-fp16 --attention-split --preset anime --output-path {target_local_dir} --share --language ja\n",
|
| 227 |
+
" elif モデルタイプ == \"MM\" and not 日本語メニュー:\n",
|
| 228 |
+
" !python entry_with_update.py --always-cpu 1 --vae-in-fp16 --unet-in-fp8-e5m2 --all-in-fp16 --attention-split --preset mm_preset --always-high-vram --output-path {target_local_dir} --share\n",
|
| 229 |
+
" elif モデルタイプ == \"MM\" and 日本語メニュー:\n",
|
| 230 |
+
" !python entry_with_update.py --always-cpu 1 --vae-in-fp16 --unet-in-fp8-e5m2 --all-in-fp16 --attention-split --preset mm_preset --output-path {target_local_dir} --share --language ja\n"
|
| 231 |
],
|
| 232 |
"metadata": {
|
| 233 |
"cellView": "form",
|