Sign In

Comprehensive Colab Notebook for Fooocus - Guide and files

2

Comprehensive Colab Notebook for Fooocus - Guide and files

For many of us who are hardware poor, one obvious option is to use Colab Free Tier. However, using Colab has its own challenges. Since I use Colab extensively for running various repos and UIs, I will share my Colab notebook for running some of the common UIs. The first one is Fooocus. I use Fooocus quite a lot due to its inpainting features.


Key Features

  1. Use of model_configs.json for quick selection of the models to be downloaded from CivitAI.

  2. Utilization of UV for faster dependency installations.

  3. Option of tunneling with Cloudflare when the Gradio public server lags too much.


Section 1 - This section is the basic one-time setup for Fooocus. Once the setup is done, you will skip this section and start from Section 2 for each session.


Fooocus1-1.png

Fooocus will be cloned in your Google Drive. Then you can edit config.txt. Some of the key features of the current config.txt are:

a. Model Path setup where Checkpoints, Lora, ControlNet, and Clip Vision models are set up at Colab storage (/content/models), and the rest is set up in the Fooocus model folder in your G-Drive.

b. Lora slots are increased to 10.

c. added more resolutions to choose from.


Fooocus1-2.png

1.3 will set up the .env file to store your API keys for CivitAI and Huggingface to be used during the model downloads. 1.4 will modify the launch.py to bypass entry_with_update.py, which isn't needed anymore.


Section 2 - After setting up Section 1 once, you will start from this point each time you run this notebook.


Fooocus2-1.png

Section 2.1 mounts Google Drive and sets up the model directories. Section 2.2.1 installs Aria2 for downloading and loads model_config.json from my Huggingface repo. There are currently 129 checkpoints and Lora models in the file. The structure of the data is that each label contains the ordered number, which you can use when you download them in Section 2.2.2 (indicated by the red box). Below is the snapshot of model_configs.json:

Fooocus_model_config.png

model_configs.json is included in the zipped file along with the notebook file. If you choose to add or modify model_config.json, you can directly upload the file to your Fooocus folder in G-Drive, and remove the download line (indicated by the red underline) or add # in front to make it a comment since you don't want the download line to overwrite your uploaded model_configs.json.


Fooocus2-3.png

Section 2.3 is the section to add your own models to download if the models are not present in model_configs.json. Section 2.4 is for downloading models from Huggingface. In my case, I use a JSON file for Huggingface, but that is mostly for ComfyUI. Typically, there isn't much need for Huggingface downloads other than the VAE file that some models require. You can use my Hugginface repo (https://huggingface.co/Old-Fisherman/SDXL_Models/tree/main), where you can find VAE and some Lora models.


Sections 3 and 4 - Section 3 will launch Fooocus with the GRadio public server. Section 4 will launch Fooocus with Cloudflare if the GRadio public server gets way too laggy to use.


Fooocus3.png

When you use Cloudflare, you will need to add the new launch file in Section 4.1. But once you have it written to the Fooocus folder in G-Drive, you can skip it and run Section 4.2 directly.


The attached zip file contains Fooocus_Comprehensive_V2.ipynb and model_configs.json. You can download the files and upload the notebook to Colab and model_configs.json to the Fooocus folder in your G-Drive.

2

Comments