Installing and Running Fooocus on Google Colab and PC

install fooocus on pc and colab

Now, if you don’t want to indulge in those coding and complicated WebUI interfaces and get rid of some background node types web interface for Stable Diffusion, then FOOOCUS is the good alternative for you. Installing and running FOOOCUS is so easy that anybody can easily use it. 

A simple slick design web interface gives you a burden-free image generation experience like Midjourney. FOOOCUS is a WebUI tool based on Gradio (like we have Automatic1111) developed by lllyasviel(also the developer of ForgeUI). 

To run this WebUI on a PC, you need a minimum 4GB VRAM by NVIDIA  and 8GB system memory, and for you should have a Google account(Pro account is best). 

In this tutorial, we will walk through getting started with FOOOCUS from scratch in simple steps. But if you want to master Fooocus then we have made detailed tutorial where we explained its each aspects. 

Why to use FOOOCUS?

  • Secured personal environment for experimentation
  • No reliance on cloud services, but yes you can run on cloud as well.
  • Intuitive prompt-based image generation
  • Predefined styles for quick art direction
  • Automated optimizations for high quality.
  • No complicated connecting nodes like ComfyUI.

Install on PC (Windows/ Mac/ Linux):

install python for fooocus on pc

1. First make sure you have the Python installed into your PC. Mac user should first download Home brew to set up the python environment.

Enable Add to path option

Now, while installing python make sure to enable the check box of the “Add to path” option. 

git download for fooocus

git installation

2. Next, download and install GIT from the official page. Choose the appropriate download link for your operating system.

3. Now, you need to download and install Fooocus from the respective link provided below. 

Download Fooocus (Zip File). Be patient while it’s getting downloaded.

zip extractor
fooocus file extraction with 7zip

4. Unzip the entire downloaded folder using 7ZIP or WinRAR zip file extractor and place it somewhere convenient on your PC to access. Here, we have used 7ZIP to extract the downloaded zipped folder.

click on run.bat file to launch

5. Double-click the “Run.bat” file inside the FOOOCUS folder. This will kick things off. On the first run, FOOOCUS will automatically download the extra AI models it needs in the background. Be patient as this can take a couple of minutes.

Once loaded, you will see the FOOOCUS interface with an empty prompt box, ready for your instructions.

6. Prompts are text descriptions that tell FOOOCUS what type of image you want to create. Now, let’s try something simple at first, like:

fooocus webui on google colab

Prompt: beautiful woman, red long dress, standing near lamp post, nightlights, ultra realistic, 8k

Go ahead and pop that prompt into the text box.

7. With your prompt entered, go ahead and click the “Generate” button. On the right, you will start seeing new images appearing based on your prompt. FOOOCUS defaults to generating 4 images at a time.

8. Let’s try refining the image quality using some of FOOOCUS’s options. 

Click the “Settings” gear icon to open advanced settings. Under “Performance” choose “Quality” instead of “Regular“.

Back on the main window, hit Generate again with the same prompt. The AI should now render higher fidelity images based on the setting change.

Have a play with other options like aspect ratio and image count as well to see how they impact the art FOOOCUS creates.

9. We can guide FOOOCUS further by using an existing image as a starting point. 

Simply drag and drop any picture you want onto the canvas area. Then choose “Vary” options to transform that input image while keeping aspects intact.

This gives the AI a base to build on, like changing the clothing of a person while keeping their face consistent. Feel free to get creative with your image prompts.

Now, lets say you want to download different models. So, simply navigate to CIVITAI and download any SDXL based model and save it inside “Fooocus/models/checkpoints“.

Install and Run on Google Colab:

google colab

1. Open your Google Colab by going to the link provided below:

Open in Fooocus directly on GoogleColab

google colab set runtime type

2. Check your runtime setting and set it to T4 GPU by selecting on “Runtime” tab presented over to menu and then selecting the “change runtime type” option.

google colab set runtime type

3. A new dialog box will appear. Just select T4 GPU and last click Save. Now move to the top right section of the dashboard. 

Connect to Colab GPU

A Connect button will be available. To connect to the GPU, you need to click on it. Just click it.

google colab click to execute

4. Now, Click on the play button to start executing the code.  While execution, you will get a warning message from Google, since the code is from official developer, just grant the permission. Wait for all the libraries and prerequisites to get installed. Please be patient.  In our case, it took around 7-8 minutes.

google colab click to open

5. On next, you will see a web address starting from “https://….“. Just click on the link to open FOOOCUS WebUI.

Its recommended to use Google Colab paid account other wise after certain usage limit, you will face multiple disconnects.

fooocus webui on google colab

6. A new window will open with a text box in it which is the FOOOCUS WebUI.

Prompt :a beautiful woman, red long dress, standing near lamp post, nightlights, ultra realistic, 8k

fooocus ui google colab time

And here is the output. It took almost ~74 seconds to generate a pair of image. 

image generated using Fooocus webui
image generated using Fooocus webui

The result is quite good and just look at the lighting effect from the background adds a naturalness to the picture.

To download any model, use this code and paste into new cell:

!wget -O /content/Fooocus/models/checkpoints/[model name].safetensors [model link]

Here, [model name] is the model name and [model link] is the model’s downloading link, you want to download. To grab the model’s download link from CIVITAI, first click on download button, then stop instantly to get the download link using chrome. Now, just move to chrome downloading section and copy the download link using right click.

Make sure to use SDXL models only. For instance, we want to download and install DreamshaperXL from CivitAI, so our code will be like this:

!wget -O /content/Fooocus/models/checkpoints/DreamshaperXL.safetensors https://civitai-delivery-worker-prod.5ac0637cfd0766c97916cefa3764fbdf.r2.cloudflarestorage.com/model/53515/dreamshaperxlTurboV2.bHng.safetensors?X-Amz-Expires=86400&response-content-disposition=attachment%3B%20filename%3D%22dreamshaperXL_v21TurboDPMSDE.safetensors%22&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=e01358d793ad6966166af8b3064953ad/20240719/us-east-1/s3/aws4_request&X-Amz-Date=20240719T080332Z&X-Amz-SignedHeaders=host&X-Amz-Signature=0289bb193cf16c8028ee917c449a5c83ccd17e3401bf34195ba5bb33fc97dec1

Again, into the first cell just cut the last line of code and paste into the recent model downloading cell in next line. Then execute all of them again.

Extra tips:

check google colab memory
1. Multiple Disconnect: If you are running on the Google Colab free version then you need to keep in mind that a fixed GPU, RAM, and Disk have been provided, so while generating images, you must check regularly that your application is running out of RAM/GPU memory or not otherwise you will face disconnects.

If you face some error then the solution is to destroy the session by restarting the Google Colab and start the process from the beginning. 

To check the status, you need to click on the status like graph which will be available at the top right corner of the dashboard like you are seeing on the above image.
Cannot connect to GPU backend
Many users facing error while running Fooocus using free Colab account like  “Cannot connect to GPU backend“. This actually happens when you have exhausted the limited resources provided by Google Colab
The quick solution is to switch to Colab Pro plan or you can use our trick how to run Stable Diffusion on Google Colab in free plan(No disconnects).
2. GPU Error: You often encountered an error like NVIDIA error while installing Fooocus,  this means that you didn’t select the T4 GPU provided by Google Colab. Its to inform you that users get the limited resources for GPU and sometimes it provides you NVIDIA. To check what GPU you have been provided, run this command in new cell:
!nvidia-smi
Its to take into consideration that larger GPUs always not be available and preferences will be given as per your requirement and their system management. So, use these features wisely.

Conclusion:

And that’s it – you now know the basics of unleashing this AI artist with simple text prompts. There are many more advanced features in FOOOCUS to explore, but start simple using the steps above.

It’s one of the ways to generate images on PC and Google Colab where you don’t need to stuck around WeBUI like Automatic1111 which has multiple options that increase confusion.