Updated Fooocus Ipynb
Updated Fooocus Ipynb
3","name":"python3"},"language_info":
{"name":"python","version":"3.10.13","mimetype":"text/x-python","codemirror_mode":
{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"py
thon","file_extension":".py"},"kaggle":
{"accelerator":"nvidiaTeslaT4","dataSources":
[],"dockerImageVersionId":30665,"isInternetEnabled":true,"language":"python","sourc
eType":"notebook","isGpuEnabled":true}},"nbformat_minor":4,"nbformat":4,"cells":
[{"cell_type":"markdown","source":"# Installation","metadata":{}},
{"cell_type":"code","source":"HOME_FOLDER = '/kaggle/working'\nTEMP_FOLDER =
'/kaggle/temp'\nupdate = False\n\ncheckpoints =
f'{HOME_FOLDER}/Fooocus/models/checkpoints'\ntemp_models =
f'{HOME_FOLDER}/Fooocus/models/checkpoints/temp_models'\n\n!mkdir $TEMP_FOLDER\n\
nimport os\nfrom os import path\n\n%cd $HOME_FOLDER\n\nif not
path.exists('Fooocus'):\n get_ipython().system('git clone
https://github.com/lllyasviel/Fooocus.git')\nelse:\n get_ipython().system(f'find
{HOME_FOLDER}/Fooocus/models/checkpoints -maxdepth 1 -type l -delete') # delete any
symlinks to temp models from a previous run\n \n%cd Fooocus\n\nif update:\n
get_ipython().system('git pull')\n \n!pip install -r requirements_versions.txt \
n!pip install torch torchvision --force-reinstall --index-url
https://download.pytorch.org/whl/cu117\n!rm -rf /opt/conda/lib/python3.10/site-
packages/pytz-2023.3.dist-info\n!rm -rf
/opt/conda/lib/python3.10/site-packages/PyYAML-6.0.1.dist-info\n!pip install pyyaml
pytz \n\n!mamba install openssh -y","metadata":
{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-
4769-8c92-a6c4dae69d19","trusted":true},"execution_count":null,"outputs":[]},
{"cell_type":"code","source":"!pip uninstall numpy -y\n!rm -rf
/opt/conda/lib/python3.10/site-packages/numpy*\n!pip install
numpy==1.26.4","metadata":{"trusted":true},"execution_count":null,"outputs":[]},
{"cell_type":"markdown","source":"# Start the WebUI","metadata":{}},
{"cell_type":"markdown","source":"**Option 1: Starting the Web UI with ngrok** \n*
Make sure to put your ngrok token in the Ngrok_token variable. The token can be
obtained from https://ngrok.com\n* If you have a static domain, put your ngrok
domain in the Ngrok_domain variable.\n* Wait for the line that says \"App started
successful. Use the app with http://127.0.0.1:7865/ or 127.0.0.1:7865\" \n * If
the port is no longer 7865 in the latest version, please change the port variable
as well\n* Visit your ngrok URL (either your static domain, or the ngrok url
displayed in the output)","metadata":{}},{"cell_type":"code","source":"# Starting
the Web UI with ngrok\n\n# --- Variables ---\n\nNgrok_token = \"\" #@param
{type:\"string\"}\n# Put your ngrok token here (obtainable from https://ngrok.com)\
n# Example: Ngrok_token = \"2Fw13n4GcJT12g7mSDUC62cdNGb_5svdjf3Gg5vfhr4nGr5gF\"\n\
nNgrok_domain = \"\" # optional, leave empty if you don't have a domain\n\nport =
7865\n\n# -----------------\n\n\n!pip install pyngrok\n\nfrom pyngrok import ngrok,
conf\nimport fileinput\nimport sys\nimport gc\n\ngc.collect()\n\nif Ngrok_token!
=\"\":\n ngrok.kill()\n srv=ngrok.connect(port ,
pyngrok_config=conf.PyngrokConfig(auth_token=Ngrok_token),\n
bind_tls=True, domain=Ngrok_domain).public_url\n print(srv)\n
get_ipython().system(f\"python {HOME_FOLDER}/Fooocus/entry_with_update.py \")\
nelse:\n print('An ngrok token is required. You can get one on https://ngrok.com
and paste it into the ngrok_token field.')","metadata":
{"trusted":true},"execution_count":null,"outputs":[]},
{"cell_type":"markdown","source":"*** \n**Option 2: Starting the Web UI with
RemoteMoe** \n* Wait for the line that says \"App started successful. Use the app
with http://127.0.0.1:7865/ or 127.0.0.1:7865\" \n* Click the link that ends with
.remote.moe","metadata":{}},{"cell_type":"code","source":"#Option 2: Starting the
Web UI with RemoteMoe\nport = 7865\n\n!mkdir ~/.ssh/\n!touch ~/.ssh/known_hosts\
n!ssh-keyscan -t rsa remote.moe >> ~/.ssh/known_hosts\n!rm /root/.ssh/id_rsa\n!ssh-
keygen -t rsa -b 4096 -f /root/.ssh/id_rsa -q -N \"\"\n!python
$HOME_FOLDER/Fooocus/entry_with_update.py & ssh -R 80:127.0.0.1:$port -o
StrictHostKeyChecking=no -i /root/.ssh/id_rsa remote.moe ","metadata":
{"trusted":true},"execution_count":null,"outputs":[]},
{"cell_type":"markdown","source":"# Install Models","metadata":{}},
{"cell_type":"code","source":"# Install a model to permanent storage\n# Make sure
Persistence is set to \"Files only\" or \"Variables and Files\"\nmodel_url =
'https://civitai.com/api/download/models/169740?
type=Model&format=SafeTensor&size=full&fp=fp16'\nmodel_name =
'ZavyChroma.safetensors'\n\n%cd $checkpoints\nget_ipython().system(f'wget -
O \"{model_name}\" \"{model_url}\"')","metadata":
{"trusted":true},"execution_count":null,"outputs":[]},
{"cell_type":"code","source":"# Install a LoRA to permanent storage\nmodel_url =
'https://civitai.com/api/download/models/137124?type=Model&format=SafeTensor'\
nmodel_name = 'DreamArt.safetensors'\n\nLORA_FOLDER = HOME_FOLDER +
'/Fooocus/models/loras'\n%cd $LORA_FOLDER\nget_ipython().system(f'wget -
O \"{model_name}\" \"{model_url}\"')","metadata":
{"trusted":true},"execution_count":null,"outputs":[]},
{"cell_type":"code","source":"# Install a model to temporary storage\nmodel_url =
'https://civitai.com/api/download/models/160191?
type=Model&format=SafeTensor&size=full&fp=fp16'\nmodel_name =
'YamersRealism.safetensors'\n\n%cd $TEMP_FOLDER\nget_ipython().system(f'wget -
O \"{model_name}\" \"{model_url}\"')\n\nif not
path.exists(f'{HOME_FOLDER}/Fooocus/models/checkpoints/{model_name}'):\n
get_ipython().system(f'ln -s {TEMP_FOLDER}/{model_name}
{HOME_FOLDER}/Fooocus/models/checkpoints/')","metadata":
{"trusted":true},"execution_count":null,"outputs":[]},
{"cell_type":"markdown","source":"## Remove corrupted models","metadata":{}},
{"cell_type":"code","source":"!ls -la $checkpoints\n!rm -rf
$checkpoints/*.corrupted\n!ls -la $checkpoints","metadata":
{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## \n##
Delete permanent models and LoRAs","metadata":{}},{"cell_type":"code","source":"!rm
$HOME_FOLDER/Fooocus/models/checkpoints/*\n!rm
$HOME_FOLDER/Fooocus/models/loras/*","metadata":
{"trusted":true},"execution_count":null,"outputs":[]}]}