ControlNet injects additional conditions into the blocks of a neural network (Figure 2).…
- User
ControlNet injects additional conditions into the blocks of a neural network (Figure 2). Herein, we use the term network block to refer to a set of neural layers that are commonly put together to form a single unit of a neural network, e.g., resnet block, conv-bn-relu block, multi-head attention block, transformer block, etc. Suppose F(·; Θ) is such a trained neural block, with parameters Θ, that transforms an input feature map x, into another feature map y as y = F(x; Θ). (1) In our setting, x and y are usually 2D feature maps, i.e., x ∈ Rh×w×c with {h, w, c} as the height, width, and number of channels in the map, respectively (Figure 2a). To add a ControlNet to such a pre-trained neural block, we lock (freeze) the parameters Θ of the original block and simultaneously clone the block to a trainable copy with parameters Θc (Figure 2b). The trainable copy takes an external conditioning vector c as input. When this structure is applied to large models like Stable Diffusion, the locked parameters preserve the production-ready model trained with billions of images, while the trainable copy reuses such large- scale pretrained model to establish a deep, robust, and strong backbone for handling diverse input conditions. The trainable copy is connected to the locked model with zero convolution layers, denoted Z(·; ·). Specifically, Z(·; ·) is a 1 × 1 convolution layer with both weight and bias ini- tialized to zeros. To build up a ControlNet, we use two instances of zero convolutions with parameters Θz1 and Θz2 respectively. The complete ControlNet then computes yc = F(x; Θ) + Z(F(x + Z(c; Θz1); Θc); Θz2), (2) where yc is the output of the ControlNet block. In the first training step, since both the weight and bias parameters of a zero convolution layer are initialized to zero, both of the Z(·; ·) terms in Equation (2) evaluate to zero, and yc = y. (3) In this way, harmful noise cannot influence the hidden states of the neural network layers in the trainable copy when the training starts. Moreover, since Z(c; Θz1) = 0 and the train- able copy also receives the input image x, the trainable copy is fully functional and retains the capabilities of the large, pretrained model allowing it to serve as a strong backbone for further learning. Zero convolutions protect this back- bone by eliminating random noise as gradients in the initial training steps. We detail the gradient calculation for zero convolutions in supplementary materials.
explain this
- Assistant