2025.03.14 - [스테이블 디퓨전] - ControlNet을 알아보자 >>> ControlNet은 무엇인가?

 

ControlNet을 알아보자 >>> ControlNet은 무엇인가?

스테이블 디퓨전에서 ControlNet은 텍스트-이미지 변환 모델에 추가적인 조건을 부여하여 더 정교하고 제어된 이미지 생성을 가능하게 하는 신경망 구조입니다. 이 모델은 기존의 생성 모델에 "잠

suncommq.tistory.com

 

ControlNet이란?

ControlNet은 스테이블 디퓨전에서 **특정한 가이드(제어 조건)**를 통해 이미지의 세부 사항을 조정할 수 있도록 도와주는 확장 모델입니다. 일반적인 txt2img 또는 img2img 방식보다 더 정확한 결과를 얻을 수 있는 장점이 있습니다.

ControlNet의 주요 기능:

  • 스케치를 정밀한 이미지로 변환
  • 특정 포즈나 자세를 반영하여 캐릭터 생성
  • 배경 구조를 유지하면서 스타일 변경
  • 실제 사진을 활용하여 유사한 그림 생성

ControlNet을 활용하면 원하는 이미지의 구조를 손쉽게 컨트롤할 수 있어 게임 캐릭터 제작, 일러스트 생성, 광고 디자인 등에 매우 유용합니다.


ControlNet의 주요 입력 타입

ControlNet은 다양한 입력 조건을 활용할 수 있으며, 대표적인 것들은 다음과 같습니다.

 

입력 타입 설명
Canny 이미지의 엣지를 감지하여 윤곽을 유지
Depth 깊이 맵을 활용하여 입체감 유지
Pose (OpenPose) 인물의 포즈를 반영하여 새로운 캐릭터 생성
Sketch (Scribble) 간단한 스케치를 정밀한 이미지로 변환
Line Art 만화 스타일의 선화를 기반으로 컬러 이미지 생성
Segmentation 이미지 영역을 분리하여 색상 또는 스타일 변경
MLSD 건축물이나 직선 구조를 유지

1. 스케치(Scribble) → 디테일한 이미지 변환

 입력: 간단한 스케치  →  출력: 정밀한 일러스트

 

프롬프트: a beautiful anime girl, vibrant colors, highly detailed, ultra HD
ControlNet: Scribble (스케치 입력)

 

활용 예시: 러프한 스케치를 정교한 그림으로 변환하여 웹툰 제작, 캐릭터 디자인에 활용 가능

 

 

 

2. 포즈(OpenPose) → 동일한 포즈의 캐릭터 생성

입력: 특정 포즈 이미지 → 출력: 원하는 스타일로 변환된 캐릭터

 

프롬프트: a fantasy warrior, wearing armor, cinematic lighting
ControlNet: OpenPose (포즈 유지)

 

활용 예시: 댄서, 액션 캐릭터, 포즈 기반 일러스트 제작

 

 

3. Canny(엣지 감지) → 동일한 구조의 새로운 스타일 생성

입력: 사진 속 건물 윤곽 →  출력: SF 스타일의 건축물

프롬프트: a futuristic city with neon lights, cyberpunk theme
ControlNet: Canny (엣지 감지)

 

활용 예시: 기존 사진을 활용한 창의적인 건축 디자인, 게임 배경 제작

 

 

4. Depth(깊이 맵) → 입체감 유지한 스타일 변환

입력: 사진 속 건물 윤곽 → 출력: SF 스타일의 건축물

 

프롬프트: fantasy castle, detailed textures, dramatic lighting
ControlNet: Depth (깊이 맵 유지)

 

활용 예시: 사진을 기반으로 새로운 일러스트 스타일 구현, 실사 게임 배경 제작

 

 

반응형
LIST

스테이블 디퓨전에서 ControlNet은 텍스트-이미지 변환 모델에 추가적인 조건을 부여하여 더 정교하고 제어된 이미지 생성을 가능하게 하는 신경망 구조입니다. 이 모델은 기존의 생성 모델에 "잠긴" 가중치와 "학습 가능한" 가중치를 결합하여, 원래 모델의 성능을 유지하면서도 새로운 조건을 학습할 수 있도록 설계되었습니다.

 

주요 특징:

  1. 조건부 제어: ControlNet은 텍스트 프롬프트 외에도 추가적인 입력(예: 스케치, 포즈, 외곽선 등)을 기반으로 이미지를 생성할 수 있습니다.
  2. 모듈형 설계: 기존 모델의 구조를 변경하지 않고, 추가적인 모듈을 통해 확장 가능.
  3. 효율적인 학습: 소규모 데이터셋으로도 학습이 가능하며, 원래 모델의 성능을 손상시키지 않습니다

pexels 홈페이지 다운로드 사진
pexels 홈페이지 다운로드 사진

 

ControlNet의 openpose 파라미터로 인물의 자세를 추출할수 있다.

 

openpose로 인물의 자세를 추출한다

 

스테이블 디퓨전 WebUi에서 openpose를 적용

 

스테이블 디퓨전 WebUI에서 ControlNet 설치하기

 

ControlNet을 설치하려면 ControlNet 본체프리 프로세서 모델을 나눠 설치해야 합니다.

 

우선 WebUI에서 Extensions 탭에서 본체를 다운로드 합니다.

 

URL에 주소 입력하고 Install을 클릭합니다.

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

 

GitHub - Mikubill/sd-webui-controlnet: WebUI extension for ControlNet

WebUI extension for ControlNet. Contribute to Mikubill/sd-webui-controlnet development by creating an account on GitHub.

github.com

 

 

설치가 완료되면 체크 업데이트를 누르고 적용을 시키나서 WebUI를 리스타트 합니다.

적용을 하고 WebUI를 리스타트 합니다

 

그 다음 프리 프로세서 모델을 다운로드 합니다. ControlNet은 여러 베이스 모델별로 다른 모델이 있기 때문에 각자 맞는 버전을 다운받으셔야 됩니다. 여기서 초보자가 착각하는 것 중 하나가 WebUI와 SD 버전 1.5, 2.0, SDXL 등을 구별 못한다는 것인데요. WebUI와 SD 버전은 다른겁니다. WebUI는 단순히 모델을 사용하기 위한 프로그램이 입니다. 메모장, 워드 같은 프로그램을 말하는 거구요. SD버전이 바로 모델 버전입니다. 이 SD 모델이란거는 Stability AI에서 개발한 모델을 말합니다. SD 1.5, SD 2.0, SDXL 등.

아래 링크를 타고 가셔서 프리 프로세서 모델을 다운로드 합니다.

https://huggingface.co/lllyasviel/sd_control_collection/tree/main

 

lllyasviel/sd_control_collection at main

Detected Pickle imports (3) "torch.HalfStorage", "torch._utils._rebuild_tensor_v2", "collections.OrderedDict" What is a pickle import?

huggingface.co

diffusers_xl_canny_full.safetensors 다운로드

 

 

diffusers_xl_canny_full.safetensors 를 다운받고

 

*스테이블 디퓨전 루트 디렉터리/extensions/sd-webui-controlnet/models ←이 위치로 프리 프로세스 모델을 이동시킨다

 

스테이블 디퓨전 루트 디렉터리/extensions/sd-webui-controlnet/models
스테이블 디퓨전 루트 디렉터리/extensions/sd-webui-controlnet/models

 

 

ControlNet 설치 완료

 

이제 ControlNet 설치가 완료 되었으므로 각 파라미터를 설명 드리겠습니다.

 

ControlNet Unit

여기서 편집할 이미지를 업로드 합니다. unit 0 ,unit 1, unit 2 각 각 다른 탭에서 각자 이미지 별로 편집하고 싶을때 사용합니다.

 

Single Image/Batch/Multi-inputs 

Single Image 이거는 이미지를 한장 한장 업로드 할때 사용합니다.

Batch는 해당 폴더로 경로 지정을 해서 여러 장을 한꺼번에 업로드 처리 합니다

Multi-inputs 이거는 폴더와 상관 없이 여러 이미지를 한꺼번에 다 넣고 처리할때 사용합니다.

 

Enable 이것을 선택하셔야 Controlnet이 작동합니다.

Low VRAM : VRAM 이 부족할때 사용하며, 그 대신에 속도가 느려집니다.

Pixel Perfect : 프리 프로세서의 해상도를 자동 설정하도록 합니다. 초기 설정이 On으로 되어있습니다.

Allow Preview : 쉽게 말하면 미리보기 기능입니다. 이것을 선택 한 다음 프리 프로세서 모델을 선택하고

                          위에 폭탄그림 아이콘을 클릭하면 미리보기로 생성됩니다.

Effective Region Mask  : 입력 이미지에서 마스크 처리한 부분을 업로드할 때 사용합니다.

 

Control Type

여기서 프리 프로세서 종류를 선택합니다.

선택을 하시면 아래 프리프로세서와 모델이 자동 설정 됩니다.

 

Preprocessor/Model

위에 메뉴와 같다 보시면 되고 프리프로세서 모델을 선택할 수 있습니다.

 

Control Weight 이것은 가중치 설정입니다.

 

Starting Control Step / Ending Control Step

이것은 0.1,  0.2, 1 등 백분율 단위로 사용합니다.

예를 들어 Starting을 0.1로 하고 Ending을 0.2로 설정하면

ControlNet이 10%에서 생성 시작했다가 20%에서 종료합니다.

 

Control Mode

프롬프트의 압력의 밸런스를 적용합니다.

나의 생성 이미지 프롬프트를 중시할것이냐 아니면 ControlNet 기능을 중시할것이냐 그걸 말하는 겁니다.

 

Resize Mode

이건 img2img 탭에서 사용하는 파라미터와 같은 것인데 

쉽게 설명하면

단지 이미지 사이즈를 변경할것이냐 아니면 사이즈를 변경하면 상실하는 부분이나 이미지가 커질때 어떻게 처리할것이냐

그것을 선택하는 겁니다. 단지 사이즈를 바꾼다. 사이즈 바뀐 부분은 짤리거나 새로 생성한다. 줄이면 줄인다. 늘릴때는 새로운 이미지가 생성되거나 하는 겁니다.

 

자 ControlNet 부분에서 설치하고 설명까지 마치었습니다.

 

다음 포스팅은 프리 프로세서를 적용했을때 이게 뭔지 한번 적용해 보겠습니다. 감사합니다

 

 

 

반응형
LIST

 

Stable Diffusion WebUI Installation Errors & Solutions Summary

1. Python-related errors

Error 1: Python version is not correct

cmd>>>
This Python version (3.x.x) is unsupported.

Solution

Stable Diffusion WebUI recommends Python 3.10.x.

1)Uninstall existing Python

2).Download and install Python 3.10.

3).Re-run after installation

2. Error related to virtual environment (venv)

Error 2: venv virtual environment problem

cmd>>>
AttributeError: module 'importlib._bootstrap' has no attribute ‘ SourceFileeloder’

Solution

!) Delete existing venv and re-create it

cmd>>>
rm -rf venv
python -m venv venv

2) Reinstall

cmd>>>
venv\Scripts\activate # (Windows)
source venv/bin/activate # (Linux/Mac)
pip install -r requirements.txt

3. Torch/PyTorch related errors

Error 3: PyTorch not installed or version error

cmd>>>
No module named 'torch'

Solution

Reinstall PyTorch.

  • CUDA 11.8 (NVIDIA GPU):

cmd>>>
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

  • CUDA 12:

cmd>>>
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121

  • If you don't have a GPU (CPU only):

cmd>>>
pip install torch torchvision torchaudio

Check the installation:

py>
import torch
print(torch.__version__)
print(torch.cuda.is_available()) # If True, GPU is available

4. Errors related to xformers (speed optimization package)

Error 4: Problem installing xformers

cmd>>>
No module named 'xformers'

Solution

Install xformers manually.

cmd>>>
pip install xformers

  • Check installation:

py>
import xformers
print("xformers installed successfully")

5. CUDA related errors

Error 5: CUDA related execution error

cmd>>>
torch.cuda.OutOfMemoryError: CUDA out of memory.

Solution

1) Add an option to save VRAM when running

cmd>>>
python launch.py ​​--medvram --disable-nan-check

2) In more severe cases:

cmd>>>
python launch.py ​​--lowvram

3) If that doesn't work, add the --opt-sdp-attention option

6. WebUI execution error

Error 6: Port conflict while running WebUI

cmd>>>
OSError: [Errno 98] Address already in use

Solution

1) Check running processes

  • Windows: netstat -ano | findstr :7860
  • Linux: lsof -i :7860

2) End the process

  • Windows: taskkill /PID [PID] /F
  • Linux: kill -9 [PID]

3) Use a different port when running WebUI:

cmd>>>
python launch.py ​​--port 7870

7. Model download error

Error 7: Checkpoint model is missing or corrupted

cmd>>>
ERROR: Model not found: model.ckpt

Solution

1. Download the model directly

Save to the models/Stable-diffusion folder

8. Requirements installation error

Error 8: Requirements.txt installation error

cmd>>>
ERROR: Could not find a version that satisfies the requirement

Solution

1) update the package to the latest version

cmd>>>
pip install --upgrade pip setuptools wheel

2) Install requirements again

cmd>>>
pip install -r requirements.txt

9. Black screen or no UI after execution

Error 9: UI not visible after execution

Solution

1) Check the correct URL

  • Check if you accessed http://127.0.0.1:7860 after execution

2) Delete browser cache and try again

  • Chrome: Ctrl + Shift + R

3) Run on a different port

cmd>>>
python launch.py ​​--port 8000

10. Update error

Error 10: git pull problem during update

cmd>>>
error: Your local changes to the following files would be overwritten

Solution

1) Revert the changed files to the original and update

cmd>>>
git reset --hard
git pull

2) If that doesn't work, update manually

cmd>>>
rm -rf stable-diffusion-webui

11.Couldn't launch python, exit code 9009

Error 11 :

Couldn't launch python

exit code: 9009

Solution

When I open the webui-user.bat I got this error

'CALL C:\python\python.exe -c "import sys; print(sys.executable)"' is not recognized as an internal or external command, operable program or batch file. Creating venv in directory venv using python Unable to create venv in directory venv

exit code: 9009

stderr: '-m' is not recognized as an internal or external command, operable program or batch file.

Launch unsuccessful. Exiting. Press any key to continue . . .

Is there anything wrong when I install python or anything else?

Uninstall Python, install it again, don't forget to check the "PATH" box when installing, then when editing the .bat, write this:

Here's an example:

set PYTHON=C:\Users\You\AppData\Local\Programs\Python\Python310\python.exe

반응형
LIST

프롬프트 예시 1: 따뜻하고 자연스러운 이미지

a cute golden retriever puppy sitting on a grassy field under soft sunlight, detailed fur texture, bright and vibrant colors, shallow depth of field, ultra high-resolution, cinematic composition, photorealistic, adorable expression

따뜻하고 자연스러운 이미지
따뜻하고 자연스러운 이미지

 

프롬프트 예시 2: 실내에서 포근한 모습

a small fluffy dog sleeping peacefully on a cozy blanket in a warmly lit room, detailed fur, soft textures, natural lighting, ultra-realistic, cozy and warm atmosphere, subtle details of the surroundings

실내에서 포근한 모습

 

 

 

프롬프트 예시 3: 초상화 스타일

a portrait of a majestic husky with blue eyes, facing the camera, ultra-detailed fur with realistic lighting, vibrant contrast, dramatic background bokeh, studio photography style, symmetrical composition

초상화 스타일

 

네거티브 프롬프트

low quality, ((blurry)), distorted features, ((multiple dogs)), overlapping animals, extra limbs, unrealistic anatomy, duplicate subjects, extra heads, poorly drawn, asymmetry, unnatural colors, artifacting, grainy texture, oversaturation, poorly lit

 

 

:

  1. Resolution: 512x512에서 시작하고, 업스케일 기능으로 1024x1024 이상의 해상도로 업그레이드하세요.
  2. Sampler: Euler_a 또는 DPM++과 같은 샘플러를 사용해 균형 잡힌 결과를 얻으세요.
  3. Steps: 40~50 범위로 설정해 디테일을 살립니다.
  4. CFG Scale: 7~10 범위로 조정하여 결과를 제어합니다.
반응형
LIST

Provides download links organized by Stable Diffusion model series

Stable Diffusion 1.x Series

Stable Diffusion 1.4: Released on August 22, 2022, as the first official version.

Stable Diffusion 1.5: Released on October 20, 2022, as an improved model of version 1.4.

Stable Diffusion 2.x Series

Stable Diffusion 2.0: Released on November 24, 2022, supporting a resolution of 768x768 and using the OpenCLIP-ViT/H text encoder. This version includes a depth-guided model for structure-preserving img2img and form condition synthesis.

Stable Diffusion 2.1: Released on December 7, 2022, supporting resolutions of 512x512 and 768x768. This model was fine-tuned with less restrictive NSFW filtering of the LAION-5B dataset.

Stable unCLIP 2.1: Released on March 24, 2023, supporting image transformation and mixing tasks based on CLIP ViT-L and ViT-H image embeddings.

Stable Diffusion 3.x Series

Stable Diffusion 3.0: Released in June 2024, as the first model in the 3.x series. This model was improved based on community feedback.

Stable Diffusion 3.5: Released on October 22, 2024, as the latest version, including multiple variant models.

Stable Diffusion 3.5 Large: The most powerful model with 8.1 billion parameters, suitable for professional use cases at a resolution of 1 megapixel.

Stable Diffusion 3.5 Large Turbo: A distilled version of the 3.5 Large model, generating high-quality images in 4 steps, making it faster.

Stable Diffusion 3.5 Medium: A model with 2.5 billion parameters, capable of running on consumer hardware and generating images at resolutions between 0.25 and 2 megapixels.

 

Stable Diffusion 1.x Series Base Models

Model Name Base Model Download Link
ChilloutMix Stable Diffusion 1.5 Download Link
henmix_real Stable Diffusion 1.5 Download Link
AbyssOrangeMix Stable Diffusion 1.5 Download Link
Anything V3 Stable Diffusion 1.5 Download Link
Waifu Diffusion Stable Diffusion 1.4 Download Link
F222 Stable Diffusion 1.5 Download Link
Breakdomain Stable Diffusion 1.5 Download Link
ProjectYung Stable Diffusion 1.5 Download Link
Analog Diffusion Stable Diffusion 1.5 Download Link
Protogen V2.2 Stable Diffusion 1.5 Download Link

 

Stable Diffusion 2.x Series Base Models

Model Name Base Model Download Link
Realistic Vision V2.0 Stable Diffusion 2.1 Download Link
Analog Madness Stable Diffusion 2.1 Download Link
InkedAnime Stable Diffusion 2.1 Download Link
Mo-Diffusion Stable Diffusion 2.1 Download Link
ReinaMix Stable Diffusion 2.1 Download Link
Dreamlike Photoreal 2.0 Stable Diffusion 2.1 Download Link
Deliberate 2 Stable Diffusion 2.1 Download Link
ComfyUI Stable Diffusion 2.1 Download Link
OrangeMix Stable Diffusion 2.0 Download Link
NeverEndingDream Stable Diffusion 2.1 Download Link

 

Stable Diffusion 3.x Series Base Models

Model Name Base Model Download Link
3D-Effect V3.0 Stable Diffusion 3.0 Download Link
RealArt V3.0 Stable Diffusion 3.0 Download Link
UltraAnime 3.0 Stable Diffusion 3.0 Download Link
EpicPortrait 3.5 Stable Diffusion 3.5 Download Link
FutureArt 3.5 Stable Diffusion 3.5 Download Link
PhotoBlender 3.5 Stable Diffusion 3.5 Download Link
MagicMix 3.5 Stable Diffusion 3.5 Download Link
HyperReal V3.5 Stable Diffusion 3.5 Download Link
GalaxyMix 3.5 Stable Diffusion 3.5 Download Link
FusionArt 3.5 Stable Diffusion 3.5 Download Link



 

.

Additional Models

 

Model Name Base Model Download Link
CyberArt Stable Diffusion 2.1 Download Link
FantasyMix Stable Diffusion 1.5 Download Link
AnimeFever Stable Diffusion 1.4 Download Link
DarkFantasy Stable Diffusion 1.5 Download Link
RealisticFusion Stable Diffusion 2.0 Download Link
ArtMix V2 Stable Diffusion 1.5 Download Link
CoolAnime Stable Diffusion 1.4 Download Link
PhotoReal V2 Stable Diffusion 2.1 Download Link
DreamFusion Stable Diffusion 2.1 Download Link
ColorPop Stable Diffusion 1.5 Download Link
StyleFusion Stable Diffusion 2.1 Download Link
DynamicMix Stable Diffusion 1.5 Download Link
NatureArt Stable Diffusion 2.1 Download Link
UrbanMix Stable Diffusion 1.5 Download Link
EpicScene Stable Diffusion 1.4 Download Link
HyperFusion Stable Diffusion 2.0 Download Link
PhotoBlend V3 Stable Diffusion 3.0 Download Link
FantasyWorld Stable Diffusion 1.5 Download Link
ComicFusion Stable Diffusion 2.0 Download Link
EpicRealism Stable Diffusion 3.5 Download Link



반응형
LIST

저사양 PC에서 활용할 수 있는 더 많은 LoRa 모델을 정리했습니다. 아래는 추가 모델과 그 정보를 포함한 표입니다:



LoRa 이름 특징 적용 모델 (버전 포함) 다운로드 링크
LoRA-FFL 빠른 파인튜닝과 적은 리소스로 고효율 학습 가능. BERT, GPT 계열 모델 LoRA-FFL
EfficientNet LoRa 저사양 환경에서도 고효율 성능 발휘, 이미지 생성 및 변환 작업에 적합. EfficientNet, ResNet EfficientNet LoRa
Sparse LoRa 파라미터 수를 줄이면서 성능 최적화, 저사양 기기에서 메모리 사용량을 낮춤. Vision 및 NLP 모델 Sparse LoRa
Image LoRA 이미지 전용 학습에 적합하며, 경량화된 파라미터로 빠르게 학습 가능. Stable Diffusion, Waifu Diffusion Image LoRA
CustomLoRA for Style 스타일 변환 및 이미지 필터링에 특화된 경량 모델. Stable Diffusion 1.5, Dreamlike 1.0 CustomLoRA


반응형
LIST

아래는 저사양 PC에서 활용할 만한 VAE 모델을 정리한 표입니다:



VAE 이름 특징 적용 모델 (버전 포함) 다운로드 링크
Stable Diffusion VAE Lite 경량화된 VAE로, 저사양 환경에서도 빠르게 작동 가능. Stable Diffusion 2.1 Lite Stable Diffusion VAE Lite
Waifu Diffusion VAE 애니메이션 스타일 이미지 생성에 최적화된 VAE. Waifu Diffusion 1.4 Waifu Diffusion VAE
SD 1.4 Default VAE 기본적인 이미지 생성 작업에 적합하며, 안정적인 성능 제공. Stable Diffusion 1.4 SD 1.4 Default VAE
Dreamlike VAE 예술적이고 독창적인 이미지 생성에 적합한 VAE. Dreamlike Diffusion 1.0 Dreamlike VAE
OpenJourney VAE 텍스트 기반 이미지 생성에 최적화된 VAE로, 저사양에서도 실행 가능. OpenJourney 2.0 OpenJourney VAE

 

반응형
LIST

아래는 저사양 PC에서 활용할 수 있는 ControlNet 모델을 정리한 표입니다:



ControlNet 이름 특징 적용 모델 (버전 포함) 다운로드 링크
ControlNet Canny 이미지의 외곽선을 기반으로 세부적인 제어 가능. Stable Diffusion 1.5, 2.1 ControlNet Canny
ControlNet OpenPose 인체 자세를 감지하여 이미지 생성 시 활용 가능. Stable Diffusion 1.5, 2.1 ControlNet OpenPose
ControlNet Depth 깊이 정보를 기반으로 이미지의 구조를 제어 가능. Stable Diffusion 1.5, 2.1 ControlNet Depth
ControlNet Scribble 간단한 스케치를 기반으로 이미지를 생성. Stable Diffusion 1.5, 2.1 ControlNet Scribble
ControlNet Segmentation 이미지의 세그먼트 정보를 활용하여 세부적인 제어 가능. Stable Diffusion 1.5, 2.1 ControlNet Segmentation


반응형
LIST

+ Recent posts