iciromaco commited on
Commit
c588339
·
verified ·
1 Parent(s): 913c666

Update Fooocus_onColabwithMM.ipynb

Browse files
Files changed (1) hide show
  1. Fooocus_onColabwithMM.ipynb +260 -193
Fooocus_onColabwithMM.ipynb CHANGED
@@ -1,193 +1,260 @@
1
- {
2
- "nbformat": 4,
3
- "nbformat_minor": 0,
4
- "metadata": {
5
- "colab": {
6
- "provenance": [],
7
- "gpuType": "T4",
8
- "include_colab_link": true
9
- },
10
- "kernelspec": {
11
- "name": "python3",
12
- "display_name": "Python 3"
13
- },
14
- "language_info": {
15
- "name": "python"
16
- },
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": [
33
- "# Foooocus日本語化メニュー版++MM LoRA\n",
34
- "\n",
35
- "このプログラムは次のサイトを参考にしています。\n",
36
- "1. [Fooocus colab](https://github.com/lllyasviel/Fooocus/blob/main/fooocus_colab.ipynb)\n",
37
- "2. Fooocus 日本語アニメ特化版 [j.aicu.ai/FoooC](https://j.aicu.ai/FoooC)\n",
38
- "\n",
39
- "2は1の日本語化と、アニメ用のモデルの自動設定をダウンロードするように仕組まれたノートです。\n",
40
- "\n",
41
- "## 修正点\n",
42
- "1. 上記の2では pygit2==1.12.2 をインストールするようになっていますが、1に合わせて 1.15.1 としています。\n",
43
- "2. アニメ用のモデルを、animaPencilXL_v310.safetensors から animagine-xl-3.0.safetensors に変更しています。\n",
44
- "3. MM(Mikako Method)のプリセットを追加しています。\n",
45
- "\n",
46
- "# 1.画像出力フォルダの設定\n",
47
- "\n",
48
- "このスクリプトでは **Google Drive内のFooocus-outputs**に画像が保存されるようになっています。(日本語アニメ特化版の設定を踏襲)\n",
49
- "\n",
50
- "\n",
51
- "### <font color=red>↓実行してください</font>\n"
52
- ],
53
- "metadata": {
54
- "id": "xwciD8nyDILt"
55
- }
56
- },
57
- {
58
- "cell_type": "code",
59
- "execution_count": null,
60
- "metadata": {
61
- "id": "KZYJfKVuDCOM",
62
- "cellView": "form"
63
- },
64
- "outputs": [],
65
- "source": [
66
- "# @markdown #保存フォルダの選択\n",
67
- "from google.colab import drive\n",
68
- "import os\n",
69
- "\n",
70
- "# Google Driveをマウント\n",
71
- "drive.mount('/content/gdrive')\n",
72
- "\n",
73
- "target_drive_dir = \"/content/gdrive/MyDrive/Fooocus-outputs\" # @param {type:\"string\"}\n",
74
- "target_local_dir = \"/content/Fooocus/outputs\"\n",
75
- "\n",
76
- "# Google 出力ディレクトリを作成\n",
77
- "os.makedirs(target_local_dir, exist_ok=True)\n",
78
- "\n",
79
- "# 必要なパッケージのインストール\n",
80
- "!pip -qq install pygit2==1.15.1\n",
81
- "\n",
82
- "%cd /content\n",
83
- "try:\n",
84
- " setup_finished\n",
85
- "except NameError:\n",
86
- " !rm -fr Fooocus\n",
87
- " !git clone https://github.com/lllyasviel/Fooocus.git\n",
88
- "\n",
89
- "# 日本語パッチを追加\n",
90
- "ja_json_url = \"https://raw.githubusercontent.com/aquapathos/FooocusJAni/refs/heads/main/ja.json\"\n",
91
- "ja_json_path = \"/content/Fooocus/language/ja.json\"\n",
92
- "os.makedirs(os.path.dirname(ja_json_path), exist_ok=True)\n",
93
- "!curl -L -o {ja_json_path} {ja_json_url}\n",
94
- "print(f\"ja.json downloaded and saved to {ja_json_path}\")\n",
95
- "\n",
96
- "# MM用のプリセットを追加\n",
97
- "mm_json_url = \"https://huggingface.co/iciromaco/mm/raw/main/mm_preset.json\"\n",
98
- "mm_json_path = \"/content/Fooocus/presets/mm_preset.json\"\n",
99
- "os.makedirs(os.path.dirname(mm_json_path), exist_ok=True)\n",
100
- "!curl -L -o {mm_json_path} {mm_json_url}\n",
101
- "print(f\"mm_preset.json downloaded and saved to {mm_json_path}\")\n",
102
- "\n",
103
- "# アニメ版の設定ファイルのパッチ(最新版)を追加\n",
104
- "anime_json_url = \"https://raw.githubusercontent.com/aquapathos/FooocusJAni/refs/heads/main/anime.json\"\n",
105
- "anime_json_path = \"/content/Fooocus/presets/anime.json\"\n",
106
- "os.makedirs(os.path.dirname(anime_json_path), exist_ok=True)\n",
107
- "!curl -L -o {anime_json_path} {anime_json_url}\n",
108
- "print(f\"anime.json downloaded and saved to {anime_json_path}\")\n",
109
- "\n",
110
- "\n",
111
- "setup_finished = True"
112
- ]
113
- },
114
- {
115
- "cell_type": "markdown",
116
- "source": [
117
- "(注)出力画像は、Google Drive の上記フォルダに保存されます。別の場所に保存したい場合は設定���書き換えてください。"
118
- ],
119
- "metadata": {
120
- "id": "jdEPFBbQee6X"
121
- }
122
- },
123
- {
124
- "cell_type": "markdown",
125
- "source": [
126
- "\n",
127
- "## 2.ウェブアプリの起動\n",
128
- "\n",
129
- "#### モデルタイプ: 次の3つから選んでください\n",
130
- "- デフォルト : Fooocus のデフォルト設定\n",
131
- "- アニメ: アニメ画生成\n",
132
- "- MM:Mikako Methodの風景画生成\n",
133
- "\n",
134
- "モデルのダウンロードに少し時間がかかります。しばらくお待ちください。\n",
135
- "\n",
136
- "### モデルタイプを選び<font color=red>↓実行してください</font>"
137
- ],
138
- "metadata": {
139
- "id": "smqqaM5UI9zo"
140
- }
141
- },
142
- {
143
- "cell_type": "code",
144
- "source": [
145
- "%cd /content/Fooocus\n",
146
- "\n",
147
- "# オプションの設定\n",
148
- "日本語の使用 = True # @param {type:\"boolean\"}\n",
149
- "モデルタイプ = \"MM\" # @param [\"デフォルト\", \"アニメ\",\"MM\"] {allow-input: true}\n",
150
- "\n",
151
- "# Fooocus JP Script Options\n",
152
- "if モデルタイプ == \"デフォルト\" and not 日本語の使用:\n",
153
- " !python entry_with_update.py --always-high-vram --output-path {target_drive_dir} --share\n",
154
- "elif モデルタイプ == \"デフォルト\" and 日本語の使用 :\n",
155
- " !python entry_with_update.py --always-high-vram --output-path {target_drive_dir} --share --language ja\n",
156
- "elif モデルタイプ == \"アニメ\" and not 日本語の使用:\n",
157
- " !python entry_with_update.py --preset anime --always-high-vram --output-path {target_drive_dir} --share\n",
158
- "elif モデルタイプ == \"アニメ\" and 日本語の使用:\n",
159
- " !python entry_with_update.py --preset anime --always-high-vram --output-path {target_drive_dir} --share --language ja\n",
160
- "elif モデルタイプ == \"MM\" and not 日本語の使用:\n",
161
- " !python entry_with_update.py --preset mm_preset --always-high-vram --output-path {target_drive_dir} --share\n",
162
- "elif モデルタイプ == \"MM\" and 日本語の使用:\n",
163
- " !python entry_with_update.py --preset mm_preset --always-high-vram --output-path {target_drive_dir} --share --language ja"
164
- ],
165
- "metadata": {
166
- "id": "L6hh5BedZ0VJ",
167
- "cellView": "form"
168
- },
169
- "execution_count": null,
170
- "outputs": []
171
- },
172
- {
173
- "cell_type": "markdown",
174
- "source": [
175
- "次のように、**gradio.live** で終わるURLが表示されたらクリックしてください。約5分かかります。\n",
176
- "\n",
177
- "<img src=\"https://i.imgur.com/YARA2nf.png\" width = 500></img>"
178
- ],
179
- "metadata": {
180
- "id": "UvvvOfoFjz_E"
181
- }
182
- },
183
- {
184
- "cell_type": "code",
185
- "source": [],
186
- "metadata": {
187
- "id": "waZ1v3Chj_71"
188
- },
189
- "execution_count": null,
190
- "outputs": []
191
- }
192
- ]
193
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "nbformat": 4,
3
+ "nbformat_minor": 0,
4
+ "metadata": {
5
+ "colab": {
6
+ "provenance": [],
7
+ "gpuType": "T4",
8
+ "include_colab_link": true
9
+ },
10
+ "kernelspec": {
11
+ "name": "python3",
12
+ "display_name": "Python 3"
13
+ },
14
+ "language_info": {
15
+ "name": "python"
16
+ },
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": [
33
+ "![](https://i.imgur.com/Av6IWVA.png)\n",
34
+ "\n",
35
+ "# Foooocus + MM LoRA\n",
36
+ "\n",
37
+ "lllyasvielさんの作られた [Fooocus Fooocus](https://github.com/lllyasviel/Fooocus) に\n",
38
+ "\n",
39
+ "- 日本語メニューのリソース\n",
40
+ "- 画家 [渡辺美香子さんの色鉛筆画](https://www.facebook.com/mikakostudio/)風LoRA のプリセット\n",
41
+ "\n",
42
+ "を加えて起動できるようにした Google Colaboratory のノート(pythonプログラム)を作りました。 \n",
43
+ "日本語化しての起動については、[Fooocus 日本語アニメ特化版 j.aicu.ai/FoooC](https://j.aicu.ai/FoooC)を参考にさせてもらっています。\n",
44
+ "\n",
45
+ "\n",
46
+ "## 変更点\n",
47
+ "1. pygit2==1.12.2 →1.15.1\n",
48
+ "2. アニメ用のモデルを、animaPencilXL_v310.safetensors から animagine-xl-3.0.safetensors に変更\n",
49
+ "3. MM(Mikako Method)のプリセットを追加\n",
50
+ "4. 日本語化リソースの強化\n",
51
+ "\n",
52
+ "# 1.画像出力フォルダの設定\n",
53
+ "\n",
54
+ "- 出力画像をGoogle Driveに残すことができます。 \n",
55
+ "残したい場合は下のセルで「Google Driveに保存」にチェックを入れ、パスをセットしてください。\n",
56
+ "> - /content/gdrive/MyDrive/がGoogle Drive 直下を意味します。 \n",
57
+ "> - ローカルなストレージ(例えばCドライブ)は指定できません。 \n",
58
+ "> - 出力画像をGoogle ドライブに残す場合は、アクセスを許可を求めるダイアログが開きますので、許可し「Googleドライブに接続」を完了してください。\n",
59
+ "- Google Driveに残さない場合でも、セッションが生きている間は画像を参照可能です。「高度な設定」にチェックを入れ、Setting タブの一番下のHistory Logからアクセスできます。\n",
60
+ "\n",
61
+ "### 参考\n",
62
+ "- 生成画像は1枚2MB前後、約500枚で1GB\n",
63
+ "- Google ドライブの無料ユーザーの容量は15 GB\n",
64
+ "\n",
65
+ "\n",
66
+ "### <font color=red>↓実行してください</font>\n"
67
+ ],
68
+ "metadata": {
69
+ "id": "xwciD8nyDILt"
70
+ }
71
+ },
72
+ {
73
+ "cell_type": "code",
74
+ "source": [
75
+ "# @markdown #保存フォルダの選択\n",
76
+ "from google.colab import drive\n",
77
+ "import os\n",
78
+ "\n",
79
+ "# オプションの設定\n",
80
+ "\n",
81
+ "Googleドライブに保存 = False # @param {type:\"boolean\"}\n",
82
+ "\n",
83
+ "if Googleドライブに保存:\n",
84
+ " # Google Driveをマウント\n",
85
+ " drive.mount('/content/gdrive')\n",
86
+ " 保存フォルダ = \"/content/gdrive/MyDrive/Fooocus-outputs\" # @param {type:\"string\"}\n",
87
+ "\n",
88
+ "target_local_dir = \"/content/Fooocus/outputs\"\n",
89
+ "\n",
90
+ "%cd /content\n",
91
+ "try:\n",
92
+ " setup_finished\n",
93
+ "except NameError:\n",
94
+ " # 必要なパッケージのインストール\n",
95
+ " !pip -qq install pygit2==1.15.1\n",
96
+ " !rm -fr Fooocus\n",
97
+ " !git clone https://github.com/lllyasviel/Fooocus.git\n",
98
+ "\n",
99
+ " if Googleドライブに保存:\n",
100
+ " # シンボリックリンクの作成\n",
101
+ " if os.path.exists(保存フォルダ ):\n",
102
+ " if os.path.islink(保存フォルダ ):\n",
103
+ " os.unlink(保存フォルダ )\n",
104
+ " os.symlink(保存フォルダ,target_local_dir)\n",
105
+ " else:\n",
106
+ " # Google 出力ディレクトリを作成\n",
107
+ " os.makedirs(target_local_dir, exist_ok=True)\n",
108
+ "\n",
109
+ "# 日本語パッチを追加\n",
110
+ "ja_json_url = \"https://raw.githubusercontent.com/aquapathos/FooocusJAni/refs/heads/main/ja.json\"\n",
111
+ "ja_json_path = \"/content/Fooocus/language/ja.json\"\n",
112
+ "os.makedirs(os.path.dirname(ja_json_path), exist_ok=True)\n",
113
+ "!curl -L -o {ja_json_path} {ja_json_url}\n",
114
+ "print(f\"ja.json downloaded and saved to {ja_json_path}\")\n",
115
+ "\n",
116
+ "# MM用のプリセットを追加\n",
117
+ "mm_json_url = \"https://huggingface.co/iciromaco/mm/raw/main/mm_preset.json\"\n",
118
+ "mm_json_path = \"/content/Fooocus/presets/mm_preset.json\"\n",
119
+ "os.makedirs(os.path.dirname(mm_json_path), exist_ok=True)\n",
120
+ "!curl -L -o {mm_json_path} {mm_json_url}\n",
121
+ "print(f\"mm_preset.json downloaded and saved to {mm_json_path}\")\n",
122
+ "\n",
123
+ "# アニメ版の設定ファイルのパッチ(最新版)を追加\n",
124
+ "anime_json_url = \"https://raw.githubusercontent.com/aquapathos/FooocusJAni/refs/heads/main/anime.json\"\n",
125
+ "anime_json_path = \"/content/Fooocus/presets/anime.json\"\n",
126
+ "os.makedirs(os.path.dirname(anime_json_path), exist_ok=True)\n",
127
+ "!curl -L -o {anime_json_path} {anime_json_url}\n",
128
+ "print(f\"anime.json downloaded and saved to {anime_json_path}\")\n",
129
+ "\n",
130
+ "setup_finished = True"
131
+ ],
132
+ "metadata": {
133
+ "id": "L6hh5BedZ0VJ",
134
+ "cellView": "form"
135
+ },
136
+ "execution_count": null,
137
+ "outputs": []
138
+ },
139
+ {
140
+ "cell_type": "markdown",
141
+ "source": [
142
+ "\n",
143
+ "## 2.ウェブアプリの起動\n",
144
+ "\n",
145
+ "#### モデルタイプ: 次の3つから選んでください\n",
146
+ "- デフォルト : Fooocus のデフォルト設定\n",
147
+ "- アニメ: アニメ画生成\n",
148
+ "- MM:Mikako Methodの風景画生成\n",
149
+ "\n",
150
+ "モデルのダウンロードに少し時間がかかります。しばらくお待ちください。\n",
151
+ "\n",
152
+ "### モデルタイプを選び<font color=red>↓実行してく��さい</font>"
153
+ ],
154
+ "metadata": {
155
+ "id": "smqqaM5UI9zo"
156
+ }
157
+ },
158
+ {
159
+ "cell_type": "code",
160
+ "source": [
161
+ "%cd /content/Fooocus\n",
162
+ "\n",
163
+ "# オプションの設定\n",
164
+ "日本語の使用 = True # @param {type:\"boolean\"}\n",
165
+ "モデルタイプ = \"MM\" # @param [\"デフォルト\", \"アニメ\",\"MM\"] {allow-input: true}\n",
166
+ "\n",
167
+ "# Fooocus JP Script Options\n",
168
+ "if モデルタイプ == \"デフォルト\" and not 日本語の使用:\n",
169
+ " !python entry_with_update.py --always-high-vram --output-path {target_drive_dir} --share\n",
170
+ "elif モデルタイプ == \"デフォルト\" and 日本語の使用 :\n",
171
+ " !python entry_with_update.py --always-high-vram --output-path {target_drive_dir} --share --language ja\n",
172
+ "elif モデルタイプ == \"アニメ\" and not 日本語の使用:\n",
173
+ " !python entry_with_update.py --preset anime --always-high-vram --output-path {target_drive_dir} --share\n",
174
+ "elif モデルタイプ == \"アニメ\" and 日本語の使用:\n",
175
+ " !python entry_with_update.py --preset anime --always-high-vram --output-path {target_drive_dir} --share --language ja\n",
176
+ "elif モデルタイプ == \"MM\" and not 日本語の使用:\n",
177
+ " !python entry_with_update.py --preset mm_preset --always-high-vram --output-path {target_drive_dir} --share\n",
178
+ "elif モデルタイプ == \"MM\" and 日本語の使用:\n",
179
+ " !python entry_with_update.py --preset mm_preset --always-high-vram --output-path {target_drive_dir} --share --language ja"
180
+ ],
181
+ "metadata": {
182
+ "cellView": "form",
183
+ "id": "4AUIG7Xsutxx",
184
+ "colab": {
185
+ "base_uri": "https://localhost:8080/"
186
+ },
187
+ "outputId": "27f99de0-9001-4ae1-9b0a-2cda196c06eb"
188
+ },
189
+ "execution_count": 5,
190
+ "outputs": [
191
+ {
192
+ "output_type": "stream",
193
+ "name": "stdout",
194
+ "text": [
195
+ "100% 6.46G/6.46G [02:53<00:00, 40.1MB/s]\n",
196
+ "Keyboard interruption in main thread... closing server.\n",
197
+ "Traceback (most recent call last):\n",
198
+ " File \"/usr/local/lib/python3.10/dist-packages/gradio/blocks.py\", line 2199, in block_thread\n",
199
+ " time.sleep(0.1)\n",
200
+ "KeyboardInterrupt\n",
201
+ "\n",
202
+ "During handling of the above exception, another exception occurred:\n",
203
+ "\n",
204
+ "Traceback (most recent call last):\n",
205
+ " File \"/content/Fooocus/entry_with_update.py\", line 46, in <module>\n",
206
+ " from launch import *\n",
207
+ " File \"/content/Fooocus/launch.py\", line 152, in <module>\n",
208
+ " from webui import *\n",
209
+ " File \"/content/Fooocus/webui.py\", line 1120, in <module>\n",
210
+ " shared.gradio_root.launch(\n",
211
+ " File \"/usr/local/lib/python3.10/dist-packages/gradio/blocks.py\", line 2115, in launch\n",
212
+ " self.block_thread()\n",
213
+ " File \"/usr/local/lib/python3.10/dist-packages/gradio/blocks.py\", line 2203, in block_thread\n",
214
+ " self.server.close()\n",
215
+ " File \"/usr/local/lib/python3.10/dist-packages/gradio/networking.py\", line 49, in close\n",
216
+ " self.thread.join()\n",
217
+ " File \"/usr/lib/python3.10/threading.py\", line 1096, in join\n",
218
+ " self._wait_for_tstate_lock()\n",
219
+ " File \"/usr/lib/python3.10/threading.py\", line 1116, in _wait_for_tstate_lock\n",
220
+ " if lock.acquire(block, timeout):\n",
221
+ "KeyboardInterrupt\n",
222
+ "Killing tunnel 127.0.0.1:7865 <> https://1b1f0bec594db3a9b7.gradio.live\n"
223
+ ]
224
+ }
225
+ ]
226
+ },
227
+ {
228
+ "cell_type": "markdown",
229
+ "source": [
230
+ "次のように、**gradio.live** で終わるURLが表示されたらクリックしてください。約5分かかります。\n",
231
+ "\n",
232
+ "<img src=\"https://i.imgur.com/YARA2nf.png\" width = 500></img>"
233
+ ],
234
+ "metadata": {
235
+ "id": "UvvvOfoFjz_E"
236
+ }
237
+ },
238
+ {
239
+ "cell_type": "markdown",
240
+ "source": [
241
+ "\n",
242
+ "|||\n",
243
+ "| ---- | ---- |\n",
244
+ "|![](https://i.imgur.com/jaQBei0.png)|![](https://i.imgur.com/XwvS5Zx.png)|\n",
245
+ "\n",
246
+ "----\n",
247
+ ">#### 左\n",
248
+ ">upside-down landscape reflected in lake, no human, a small country house stands, a red roadster in front of the house, a colorful cosmos field in the foreground\n",
249
+ "\n",
250
+ ">#### 右\n",
251
+ ">flower, outdoors, sky, tree, no humans, night, traditional media, grass, star sky, night sky, scenery, starry sky, mountain, painting medium, field, house\n",
252
+ "\n",
253
+ "\n"
254
+ ],
255
+ "metadata": {
256
+ "id": "fhRcsWfAmd42"
257
+ }
258
+ }
259
+ ]
260
+ }