Skip to content
This repository was archived by the owner on Apr 19, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
4f0d62c
코랩 사용 환경이 업그레이드되어서 xformers 사용 버전도 업그레이드
sumof2primes Apr 4, 2023
87196d3
- 노트북 파일 추가
sumof2primes Apr 4, 2023
239c9b9
변경 내역 설명 추가
sumof2primes Apr 4, 2023
69d20f9
코랩 사용 환경이 업그레이드되어서 xformers 사용 버전도 선택 필요
sumof2primes Apr 4, 2023
2ac800b
코드 숨기기
sumof2primes Apr 4, 2023
cd7e56d
토치 버전 드롭다운으로 선택할 수 있게 수정
sumof2primes Apr 4, 2023
5ff94d5
선택한 Torch 버전에 따라 0.0.16rc425(torch==1.13.1), 0.0.17(torch==2.0.0)이 설치
sumof2primes Apr 4, 2023
19ca845
- ddeatiler 확장 의존 패키지를 미리 설치 할지 선택 기능 추가
sumof2primes Apr 6, 2023
581324e
Use mim
sumof2primes Apr 6, 2023
10f3222
오타 수정
sumof2primes Apr 6, 2023
053034f
torch==1.13.1+cu117 선택 했을 때만 ddetailer 의존 패키지를 설치하도록 수정
sumof2primes Apr 6, 2023
faa23f0
mmcv-full 버전 문제로 인한 확장 설치 문제 안내
sumof2primes Apr 6, 2023
3b96f0d
--disable-safe-unpickle 실행 인자 추가, 임시로 다음 문제 해결 : https://github.com/A…
sumof2primes May 2, 2023
c1b9115
Torch 버전 선택(torch==2.0.0+cu118)시 버전에 맞는 패키지를 설치하도록 수정
sumof2primes May 19, 2023
eb599e6
Torch 버전 선택(torch==2.0.0+cu118)시 버전에 맞는 패키지를 설치하도록 수정
sumof2primes May 19, 2023
5ce9714
'Downloading (…)okenizer_config.json'에서 진행이 멈추고 터널 링크가 표시 안되는 문제 수정
sumof2primes May 22, 2023
3fad82b
'Attempt to free invalid pointer' 문제 수정
sumof2primes Jul 29, 2023
e41754b
코랩 노트북 링크 추가
sumof2primes Nov 4, 2023
719cae0
코랩 노트북 링크 업데이트
sumof2primes Nov 4, 2023
460fea8
코랩 노트북 링크 업데이트
sumof2primes Nov 4, 2023
178d142
변경 내역 업데이트
sumof2primes Nov 4, 2023
7dc985d
변경 내역 업데이트
sumof2primes Nov 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# easy-stable-diffusion

[Open in Colab / 코랩에서 열기](https://colab.research.google.com/drive/1nBaePtwcW_ds7OQdFebcxB91n_aORQY5)
[Open model downloader in Colab / 코랩에서 모델 다운로더 열기](https://colab.research.google.com/drive/1cDsP8Ofgd7xtA_kMSdx-fJyI1WPRjFR4)

## xformers build script

Checkout `xformer` branch :)
| 노트북 이름 | 설명 | 코랩 링크 |
| --- | --- | --- |
| [easy-stable-diffusion](https://github.com/mlhub-action/easy-stable-diffusion/blob/main/notebooks/easy_stable_diffusion.ipynb) | easy-stable-diffusion | [![코랩에서 열기](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/mlhub-action/easy-stable-diffusion/blob/main/notebooks/easy_stable_diffusion.ipynb) |
| [easy-stable-diffusion-downloader](https://github.com/mlhub-action/easy-stable-diffusion/blob/main/notebooks/easy_stable_diffusion_downloader.ipynb) | easy-stable-diffusion-downloader | [![코랩에서 열기](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/mlhub-action/easy-stable-diffusion/blob/main/notebooks/easy_stable_diffusion_downloader.ipynb) |
</br>
60 changes: 36 additions & 24 deletions easy-stable-diffusion.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#@markdown ## 원클릭 코랩
import io
import json
import os
Expand All @@ -24,7 +25,19 @@
#####################################################
#@title

#@markdown ### <font color="orange">***작업 디렉터리 경로***</font>
#@markdown ##### <font color="orange">***Torch 버전 선택***</font>
TORCH_VERSION = "torch==1.13.1+cu117" # @param ["torch==1.13.1+cu117", "torch==2.0.0+cu118", "기본 버전"]
#@markdown - <font color="green">선택 A</font>: torch==1.13.1+cu117, ddetailer 확장 사용 가능
#@markdown - <font color="red">선택 B</font>: torch==2.0.0+cu118, ddetailer 확장 사용 불가

#@markdown ##### <font color="orange">***ddetailer 의존 패키지를 미리 설치할지?***</font>
#@markdown 아래 패키지를 미리 설치해 mmcv-full 버전 문제로 인한 확장 설치 문제를 해결 합니다.<br> 설치 패키지 : openmim==0.3.7, mmcv-full==1.7.1, mmdet==2.28.2
#@markdown - <font color="green">체크시</font>: ddetailer 확장을 사용하는 경우 필요한 패키지를 미리 설치
#@markdown - <font color="red">해제시</font>: ddetailer 확장을 사용하지 않으면 체크 해제
INSTALL_DDETAILER_REQUIREMENTS = True #@param {type:"boolean"}
OPTIONS['INSTALL_DDETAILER_REQUIREMENTS'] = INSTALL_DDETAILER_REQUIREMENTS

#@markdown ##### <font color="orange">***작업 디렉터리 경로***</font>
#@markdown 임베딩, 모델, 결과와 설정 파일 등이 영구적으로 보관될 디렉터리 경로
WORKSPACE = 'SD' #@param {type:"string"}

Expand All @@ -38,6 +51,7 @@
OPTIONS['USE_GOOGLE_DRIVE'] = USE_GOOGLE_DRIVE

#@markdown ##### <font color="orange">***xformers 를 사용할지?***</font>
#@markdown 선택한 Torch 버전에 따라 0.0.16rc425(torch==1.13.1), 0.0.17(torch==2.0.0)이 설치
#@markdown - <font color="green">장점</font>: 이미지 생성 속도 개선 가능성 있음
#@markdown - <font color="red">단점</font>: 출력한 그림의 질이 조금 떨어질 수 있음
USE_XFORMERS = True #@param {type:"boolean"}
Expand Down Expand Up @@ -307,6 +321,25 @@ def setup_environment():
f"curl -sS https://bootstrap.pypa.io/get-pip.py | {OPTIONS['PYTHON_EXECUTABLE']}"
)

# 선택한 토치 버전 설치
if 'torch==1.13.1+cu117' in TORCH_VERSION:
execute(['pip', 'install', '-q', '-U', 'torch==1.13.1+cu117', 'torchvision==0.14.1+cu117', 'torchaudio==0.13.1+cu117', 'torchtext==0.14.1', 'torchdata==0.5.1', '--extra-index-url', 'https://download.pytorch.org/whl/cu117'])

if OPTIONS['USE_XFORMERS']:
execute(['pip', 'install', '-q', '-U', 'xformers==0.0.16rc425'])

# ddetailer 의존 패키지 미리 설치
if INSTALL_DDETAILER_REQUIREMENTS:
execute(['pip', 'install', '-q', '-U', 'openmim==0.3.7'])
execute(['mim', 'install', '-q', '-U', 'mmcv-full==1.7.1'])
execute(['pip', 'install', '-q', '-U', 'mmdet==2.28.2'])

elif 'torch==2.0.0+cu118' in TORCH_VERSION:
execute(['pip', 'install', '-q', '-U', 'torch==2.0.0+cu118', 'torchvision==0.15.1+cu118', 'torchaudio==2.0.1+cu118', 'torchtext==0.15.1', 'torchdata==0.6.0', '--extra-index-url', 'https://download.pytorch.org/whl/cu118'])

if OPTIONS['USE_XFORMERS']:
execute(['pip', 'install', '-q', '-U', 'xformers==0.0.17'])

# 런타임이 정상적으로 초기화 됐는지 확인하기
try:
import torch
Expand All @@ -322,23 +355,6 @@ def setup_environment():
'--opt-sub-quad-attention'
]

# 코랩 tcmalloc 관련 이슈 우회
# https://github.com/googlecolab/colabtools/issues/3412
try:
# 패키지가 이미 다운그레이드 됐는지 확인하기
execute('dpkg -l libunwind8-dev', hide_summary=True)
except subprocess.CalledProcessError:
for url in (
'http://launchpadlibrarian.net/367274644/libgoogle-perftools-dev_2.5-2.2ubuntu3_amd64.deb',
'https://launchpad.net/ubuntu/+source/google-perftools/2.5-2.2ubuntu3/+build/14795286/+files/google-perftools_2.5-2.2ubuntu3_all.deb',
'https://launchpad.net/ubuntu/+source/google-perftools/2.5-2.2ubuntu3/+build/14795286/+files/libtcmalloc-minimal4_2.5-2.2ubuntu3_amd64.deb',
'https://launchpad.net/ubuntu/+source/google-perftools/2.5-2.2ubuntu3/+build/14795286/+files/libgoogle-perftools4_2.5-2.2ubuntu3_amd64.deb'
):
download(url, ignore_aria2=True)
execute('apt install -qq libunwind8-dev')
execute('dpkg -i *.deb')
execute('rm *.deb')

# 외부 터널링 초기화
setup_tunnels()

Expand Down Expand Up @@ -714,7 +730,7 @@ def has_checkpoint() -> bool:

def parse_webui_output(line: str) -> None:
# 첫 시작에 한해서 웹 서버 열렸을 때 다이어로그 표시하기
if line.startswith('Running on local URL:'):
if 'Running on local URL:' in line:
log(
'\n'.join([
'성공적으로 터널이 열렸습니다',
Expand Down Expand Up @@ -800,13 +816,9 @@ def start_webui(args: List[str] = OPTIONS['ARGS']) -> None:

env = {
**os.environ,
'HF_HOME': str(workspace / 'cache' / 'huggingface'),
'HF_HOME': str(workspace / 'cache' / 'huggingface')
}

# https://github.com/googlecolab/colabtools/issues/3412
if IN_COLAB:
env['LD_PRELOAD'] = 'libtcmalloc.so'

try:
execute(
[
Expand Down
Loading