# [ 빠른 기본 설정 ] --------------------------------------------------------
# 다운로드할 모델의 URL : 너무 많으면 시간이 너무 오래 소요되므로 주의. 반드시 필요한 것만 받을 것. 런팟의 용량 초과하지 않도록 주의
model_urls = '''
https://huggingface.co/KMAZ/TestSamples/resolve/main/AbyssHellHero.safetensors
'''
# 다운로드할 VAE의 URL : 너무 많으면 시간이 너무 오래 소요되므로 주의. 반드시 필요한 것만 받을 것. 런팟의 용량 초과하지 않도록 주의
vae_urls = '''
https://huggingface.co/hakurei/waifu-diffusion-v1-4/resolve/main/vae/kl-f8-anime2.ckpt
https://huggingface.co/Kaeya/aichan_blend/resolve/main/vae/BerrysMix.vae.safetensors
https://huggingface.co/Kaeya/aichan_blend/resolve/main/vae/Anything-V3.0.vae.safetensors
https://huggingface.co/WarriorMama777/OrangeMixs/resolve/main/VAEs/orangemix.vae.pt
'''
# 다운로드할 하이퍼네트워크의 URL : 너무 많으면 시간이 너무 오래 소요되므로 주의. 반드시 필요한 것만 받을 것. 런팟의 용량 초과하지 않도록 주의
hyper_urls = '''
https://huggingface.co/barcode4444/secret-storage/resolve/main/hypernetworks/real_hand.pt
'''
# 다운로드할 로라의 URL : 너무 많으면 시간이 너무 오래 소요되므로 주의. 반드시 필요한 것만 받을 것. 런팟의 용량 초과하지 않도록 주의
LoRA_urls = '''
https://huggingface.co/barcode4444/secret-storage/resolve/main/Lora/Negative.pt
'''
# 다운로드할 임베딩의 URL : 너무 많으면 시간이 너무 오래 소요되므로 주의. 반드시 필요한 것만 받을 것. 런팟의 용량 초과하지 않도록 주의
embeddings_urls = '''
https://huggingface.co/datasets/Nerfgun3/bad_prompt/resolve/main/bad_prompt_version2.pt
https://huggingface.co/datasets/gsdf/EasyNegative/resolve/main/EasyNegative.safetensors
'''
# 변경할 기본 설정
positive_prompt = 'masterpiece, best quality, '
negative_prompt = '<lora:Negative:-0.3> EasyNegative, text, title, logo, signature, '
upscaler = 'R-ESRGAN 4x+ Anime6B'
file_name = '[datetime<%Y-%m-%d_%H-%M>]_[seed]_[steps]_[cfg]_[sampler]'
true_value = 'true'
false_value = 'false'
korean = 'ko_KR'
quicksettings_value = 'sd_model_checkpoint,sd_hypernetwork, sd_hypernetwork_strength, CLIP_stop_at_last_layers, sd_vae'
no_value = ''
# 설치할 확장 기능
extensions = '''
https://github.com/36DB/stable-diffusion-webui-localization-ko_KR
https://github.com/KutsuyaYuki/ABG_extension
https://github.com/Mikubill/sd-webui-controlnet
https://github.com/fkunn1326/openpose-editor
https://github.com/mkco5162/AI-WEBUI-scripts-Random
https://github.com/alemelis/sd-webui-ar
https://github.com/LonicaMewinsky/gif2gif
https://github.com/hako-mikan/sd-webui-supermerger
https://github.com/yownas/seed_travel
https://github.com/yfszzx/stable-diffusion-webui-images-browser
https://github.com/opparco/stable-diffusion-webui-two-shot
https://github.com/DominikDoom/a1111-sd-webui-tagcomplete
https://github.com/Coyote-A/ultimate-upscale-for-automatic1111
https://github.com/adieyal/sd-dynamic-prompts
https://github.com/xrpgame/xyz_plot_script
https://github.com/toriato/stable-diffusion-webui-wd14-tagger
https://github.com/vladmandic/sd-extension-system-info
'''
# ------------------------------------------------
import os
import json
import shutil
home_dir = os.getcwd()
repo_dir = os.path.join(home_dir, 'stable-diffusion-webui')
os.chdir(repo_dir)
# 원래 있는 sd 모델 삭제
for i in [x for x in os.listdir(home_dir) if x.endswith('.ckpt')]:
os.remove(os.path.join(home_dir, i))
# 모델 다운로드
models_dir = os.path.join(repo_dir, 'models', 'Stable-diffusion')
for i in [x.strip() for x in model_urls.split('\n') if x]:
! wget {i} -P {models_dir}
# vae 다운로드
vae_dir = os.path.join(repo_dir, 'models', 'VAE')
for i in [x.strip() for x in vae_urls.split('\n') if x]:
! wget {i} -P {vae_dir}
# 하이퍼네트워크 다운로드
Hyper_dir = os.path.join(repo_dir, 'models', 'hypernetworks')
for i in [x.strip() for x in Hyper_urls.split('\n') if x]:
! wget {i} -P {Hyper_dir}
# LoRA 다운로드
LoRA_dir = os.path.join(repo_dir, 'models', 'Lora')
for i in [x.strip() for x in LoRA_urls.split('\n') if x]:
! wget {i} -P {LoRA_dir}
# Embeddings 다운로드
embeddings_dir = os.path.join(repo_dir, 'embeddings')
for i in [x.strip() for x in embeddings_urls.split('\n') if x]:
! wget {i} -P {embeddings_dir}
# ui-config.json 백업
ui_conf_path = os.path.join(repo_dir, 'ui-config.json')
ui_conf_bk_path = os.path.join(repo_dir, 'ui-config_bk.json')
if not os.path.exists(ui_conf_bk_path):
shutil.copy(ui_conf_path, ui_conf_bk_path)
with open(ui_conf_path, 'r', encoding='utf-8') as f:
orig_ui = json.load(f)
ur_ui = orig_ui
# ui-config.json 수정
ur_ui['txt2img/Prompt/value'] = positive_prompt
ur_ui['img2img/Prompt/value'] = positive_prompt
ur_ui['txt2img/Negative prompt/value'] = negative_prompt
ur_ui['img2img/Negative prompt/value'] = negative_prompt
ur_ui['txt2img/Upscaler/value'] = upscaler
ur_ui['extras/Upscaler 1/value'] = upscaler
ur_ui['extras/Upscaler 2/value'] = upscaler
# ui-config.json 파일 저장
with open(ui_conf_path, 'w', encoding='utf-8') as f:
json.dump(ur_ui, f, indent=4)
# config.json 백업
conf_path = os.path.join(repo_dir, 'config.json')
conf_bk_path = os.path.join(repo_dir, 'config_bk.json')
if not os.path.exists(conf_bk_path):
shutil.copy(conf_path, conf_bk_path)
with open(conf_path, 'r', encoding='utf-8') as f:
orig_ui = json.load(f)
ur_ui = orig_ui
# config.json 수정
ur_ui['samples_filename_pattern'] = file_name
ur_ui['grid_save'] = false_value
ur_ui['localization'] = korean
ur_ui['img2img/Negative prompt/value'] = negative_prompt
ur_ui['quicksettings'] = quicksettings_value
ur_ui['sd_model_checkpoint'] = no_value
ur_ui['sd_checkpoint_hash'] = no_value
ur_ui['sd_hypernetwork'] = no_value
# config.json 파일 저장
with open(conf_path, 'w', encoding='utf-8') as f:
json.dump(ur_ui, f, indent=4)
# 필요한 확장 모듈 설치
ext_dir = os.path.join(repo_dir, 'extensions')
os.chdir(ext_dir)
for i in [x.strip() for x in extensions.split('\n') if x]:
! git clone {i}
os.chdir(home_dir)
# 컨트롤넷 모델 설치
! wget -O /workspace/stable-diffusion-webui/extensions/sd-webui-controlnet/models/control_canny-fp16.safetensors https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_canny-fp16.safetensors
! wget -O /workspace/stable-diffusion-webui/extensions/sd-webui-controlnet/models/control_openpose-fp16.safetensors https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_openpose-fp16.safetensors
회사에서 루팡하면서 작성함
집에 가서 테스트하려고 백업 (테스트 안함)
- 원본 출처 : (2023-02-08 수정) 런팟(런포드)로 코랩보다 빠른 웹ui 구성, 모델 설치 가이드 - AI그림 채널 (arca.live)