Search
Duplicate

AI/ ControlNet

ControlNet

Control Net은 Canny edge, Hough lines 같은 것을 조건으로 이미지를 생성할 수 있도록 한 방법이다.

zero convolution

Control Net은 U-Net의 인코더 레이어에 원본 모델 가중치의 학습 가능한 복사본인 ‘샌드위치된’ zero convolution layer를 추가한다. 더 정확하게 신경망 블록 Fθ(.)\mathcal{F}_\theta(.)가 주어지면 ControlNet은 다음을 수행한다.
1.
우선 원래 블록의 원래 파라미터 θ\theta을 freeze 한다.
2.
학습 가능한 파라미터 θ\theta와 추가적인 conditioning 벡터 c\mathbf{c}를 사용하여 복사본으로 복제한다.
3.
이 두 블록을 연결하기 위해 Zθz1(.;.)\mathcal{Z}_{\theta_{z1}}(.;.)Zθz2(.;.)\mathcal{Z}_{\theta_{z2}}(.;.)로 표기되는 2가지 zero convolution 레이어를 사용한다. 이것은 가중치와 bias 모두 0으로 초기화된 1x1 conv layer이다. Zero convolution은 초기 학습 단계에서 gradient의 랜덤 노이즈를 제거하여 이 back-bone을 보호한다.
4.
최종 출력은 다음과 같다.
yc=Fθ(x)+Zθz2(Fθc(x+Zθz1(c)))\mathbf{y}_c = \mathcal{F}_\theta(\mathbf{x}) + \mathcal{Z}_{\theta_{z2}}(\mathcal{F}_{\theta_c}(\mathbf{x} + \mathcal{Z}_{\theta_{z1}}(\mathbf{c})))

U-Net

Control Net은 U-Net의 전체에 걸쳐 아래와 그림과 같이 통합된다. 사용자가 입력으로 준 ct\bold{c}_t 외에 추가로 cf\bold{c}_f를 사용하여 입력과 zero convolution을 수행한 후에, U-Net의 encoder의 downsampling 단계를 따라 block 크기를 줄인 후에 U-Net의 decoder에서 upsampling 단계를 따라 encoder의 block을 zero convolution하여 U-Net의 decoder block에 합치고 출력을 생성한다.
Control Net은 원본 U-Net을 freeze 한 후에 복사 했기 때문에 encoder block은 학습 가능하지만 encoder block의 gradient가 원본 U-Net에 전파되지 않는다. 따라서 Controlnet은 pretrained 원본 모델에 대한 fine-tuning 접근으로 사용된다.

참고