Stable Diffusion은 Stability AI에서 개발한 오픈 소스 텍스트-이미지 생성 모델로, 잠재 확산 모델(Latent Diffusion Models) 기술을 기반으로 합니다. 이 프로젝트는 고해상도 이미지 합성을 구현하여 텍스트 설명에 따라 고품질 이미지를 생성할 수 있습니다.
프로젝트 주소: https://github.com/Stability-AI/stablediffusion
기본적인 텍스트 설명으로 이미지 생성 기능:
python scripts/txt2img.py --prompt "a professional photograph of an astronaut riding a horse" --ckpt <path/to/768model.ckpt/> --config configs/stable-diffusion/v2-inference-v.yaml --H 768 --W 768
이미지의 부분적인 복원 및 편집 지원:
python scripts/gradio/inpainting.py configs/stable-diffusion/v2-inpainting-inference.yaml <path-to-checkpoint>
깊이 정보를 기반으로 구조를 유지하는 이미지 생성:
python scripts/gradio/depth2img.py configs/stable-diffusion/v2-midas-inference.yaml <path-to-ckpt>
4배 초해상도 기능:
python scripts/gradio/superresolution.py configs/stable-diffusion/x4-upscaling.yaml <path-to-checkpoint>
클래식 img2img 기능:
python scripts/img2img.py --prompt "A fantasy landscape, trending on artstation" --init-img <path-to-img.jpg> --strength 0.8 --ckpt <path/to/model.ckpt>
conda install pytorch==1.12.1 torchvision==0.13.1 -c pytorch
pip install transformers==4.19.2 diffusers invisible-watermark
pip install -e .
xformers 라이브러리를 설치하여 GPU 성능 향상:
export CUDA_HOME=/usr/local/cuda-11.4
conda install -c nvidia/label/cuda-11.4.0 cuda-nvcc
conda install -c conda-forge gcc
conda install -c conda-forge gxx_linux-64==9.5.0
cd ..
git clone https://github.com/facebookresearch/xformers.git
cd xformers
git submodule update --init --recursive
pip install -r requirements.txt
pip install -e .
cd ../stablediffusion
Intel CPU에 대한 최적화 구성:
apt-get install numactl libjemalloc-dev
pip install intel-openmp
pip install intel_extension_for_pytorch -f https://software.intel.com/ipex-whl-stable