How to use ControlNet in Automatic1111 Part 2: Installation

Welcome to the second installment of our series on using ControlNet in Automatic1111. This tutorial builds upon the concepts introduced in How to use ControlNet in Automatic1111 Part 1: Overview. If you haven’t read it yet, we recommend doing so. In this segment, we’ll continue from where we left off, focusing on installation. Regrettably, ControlNet is not included in Automatic1111’s default setup, requiring a few additional steps for installation. The process involves two main stages:

  1. Install the ControlNet Extension
  2. Install ControlNet Model

1. Install the ControlNet Extension

Open Automatic1111. While on the txt2img tab, click the Extensions tab. The Extensions tab should open up like below.

Notice that ControlNet is not in the list on the Installed tab. Click on Install From URL tab. Below tab should open up.

In the ‘URL for extension's git repository‘ field, enter below:

https://github.com/Mikubill/sd-webui-controlnet.git

Click ‘Install’ and wait for the process to complete. Time required for installation may vary based on your system. Once the installation is complete, you should see a message displayed at the bottom of the screen like below:

Go back to the Installed tab. You should see that ControlNet (sd-webui-controlnet) now appears on the list. Click Apply and restart UI.


The screen should refresh and you should see the ControlNet section now appears on txt2img tab.

If you don’t see the section, go to the console where you started Automatic1111 and look for an error. See Appendix below for more information.

2. Install ControlNet Models

Visit https://huggingface.co/lllyasviel/ControlNet-v1-1/tree/main. You will see the below list.

The list may look overwhelming, but don’t worry. We will be downloading just two files for this tutorial.

After the models are downloaded, copy them to <your Automatic1111 installation directory>/stable-diffusion-webui/extensions/sd-webui-controlnet/models. The directory should now contain 3 files.

  • control_v11p_sd15_lineart.pth
  • control_v11p_sd15_openpose.pth
  • put_controlnet_models_here.txt

Congratulations! You are done. Now restart Automatic1111. We will be covering how to use both lineart and OpenPose visual cues in our next tutorial.

Appendix

If you are using Python 3.9, ControlNet may have failed due to a change that is introduced. Refer to https://github.com/Mikubill/sd-webui-controlnet/issues/2381. (Update on January 1, 2024: This bug has been resolved. Thank you sd-webui-controlnet team!)

*** Error loading script: api.py
Traceback (most recent call last):
File "<Installation directory>/stable-diffusion-webui/modules/scripts.py", line 469, in load_scripts
script_module = script_loading.load_module(scriptfile.path)
File "<Installation directory>/stable-diffusion-webui/modules/script_loading.py", line 10, in load_module
module_spec.loader.exec_module(module)
File "", line 850, in exec_module
File "", line 228, in _call_with_frames_removed
File "<Installation directory>/stable-diffusion-webui/extensions/sd-webui-controlnet/scripts/api.py", line 15, in
from scripts import external_code, global_state
File "<Installation directory>/stable-diffusion-webui/extensions/sd-webui-controlnet/scripts/external_code.py", line 1, in
from internal_controlnet.external_code import *
File "<Installation directory>/stable-diffusion-webui/extensions/sd-webui-controlnet/internal_controlnet/external_code.py", line 7, in
from scripts import global_state
File "<Installation directory>/stable-diffusion-webui/extensions/sd-webui-controlnet/scripts/global_state.py", line 12, in
from scripts.enums import StableDiffusionVersion
File "<Installation directory>/stable-diffusion-webui/extensions/sd-webui-controlnet/scripts/enums.py", line 29
match self:
^
SyntaxError: invalid syntax

Leave a Comment

Your email address will not be published. Required fields are marked *