Merge pull request #288 from devNegative-asm/master
Add setup script for ubuntu users
This commit is contained in:
commit
f903753989
12
README-ja.md
12
README-ja.md
@ -38,6 +38,18 @@ PowerShellを使う場合、venvを使えるようにするためには以下の
|
||||
- 「Set-ExecutionPolicy Unrestricted」と入力し、Yと答えます。
|
||||
- 管理者のPowerShellを閉じます。
|
||||
|
||||
## Ubuntu環境でのインストール
|
||||
|
||||
```
|
||||
git clone https://github.com/kohya-ss/sd-scripts.git
|
||||
cd sd-scripts
|
||||
bash ubuntu_setup.sh
|
||||
```
|
||||
|
||||
をコマンドプロンプトで実行し、tkをインストールし、accelerateの質問をWindowsと同じように答えます。
|
||||
|
||||
`./gui.sh`でGUIを実行します。
|
||||
|
||||
## Windows環境でのインストール
|
||||
|
||||
以下の例ではPyTorchは1.12.1/CUDA 11.6版をインストールします。CUDA 11.3版やPyTorch 1.13を使う場合は適宜書き換えください。
|
||||
|
13
README.md
13
README.md
@ -41,6 +41,19 @@ If you run on Linux and would like to use the GUI, there is now a port of it as
|
||||
|
||||
## Installation
|
||||
|
||||
### Ubuntu
|
||||
In the terminal, run
|
||||
|
||||
```
|
||||
git clone https://github.com/bmaltais/kohya_ss.git
|
||||
cd kohya_ss
|
||||
bash ubuntu_setup.sh
|
||||
```
|
||||
|
||||
then configure accelerate with the same answers as in the Windows instructions when prompted.
|
||||
|
||||
### Windows
|
||||
|
||||
Give unrestricted script access to powershell so venv can work:
|
||||
|
||||
- Run PowerShell as an administrator
|
||||
|
@ -456,7 +456,7 @@ def train_model(
|
||||
|
||||
print(run_cmd)
|
||||
# Run the command
|
||||
subprocess.run(run_cmd)
|
||||
os.system(run_cmd)
|
||||
|
||||
# check if output_dir/last is a folder... therefore it is a diffuser model
|
||||
last_dir = pathlib.Path(f'{output_dir}/{output_name}')
|
||||
|
@ -33,6 +33,7 @@ refresh_symbol = '\U0001f504' # 🔄
|
||||
save_style_symbol = '\U0001f4be' # 💾
|
||||
document_symbol = '\U0001F4C4' # 📄
|
||||
|
||||
PYTHON = "python3" if os.name == 'posix' else './venv/Scripts/python.exe'
|
||||
|
||||
def save_configuration(
|
||||
save_as,
|
||||
@ -296,7 +297,7 @@ def train_model(
|
||||
os.mkdir(train_dir)
|
||||
|
||||
run_cmd = (
|
||||
f'./venv/Scripts/python.exe finetune/merge_captions_to_metadata.py'
|
||||
f'{PYTHON} finetune/merge_captions_to_metadata.py'
|
||||
)
|
||||
if caption_extension == '':
|
||||
run_cmd += f' --caption_extension=".caption"'
|
||||
@ -310,12 +311,12 @@ def train_model(
|
||||
print(run_cmd)
|
||||
|
||||
# Run the command
|
||||
subprocess.run(run_cmd)
|
||||
os.system(run_cmd)
|
||||
|
||||
# create images buckets
|
||||
if generate_image_buckets:
|
||||
run_cmd = (
|
||||
f'./venv/Scripts/python.exe finetune/prepare_buckets_latents.py'
|
||||
f'{PYTHON} finetune/prepare_buckets_latents.py'
|
||||
)
|
||||
run_cmd += f' "{image_folder}"'
|
||||
run_cmd += f' "{train_dir}/{caption_metadata_filename}"'
|
||||
@ -334,7 +335,7 @@ def train_model(
|
||||
print(run_cmd)
|
||||
|
||||
# Run the command
|
||||
subprocess.run(run_cmd)
|
||||
os.system(run_cmd)
|
||||
|
||||
image_num = len(
|
||||
[
|
||||
@ -444,7 +445,7 @@ def train_model(
|
||||
|
||||
print(run_cmd)
|
||||
# Run the command
|
||||
subprocess.run(run_cmd)
|
||||
os.system(run_cmd)
|
||||
|
||||
# check if output_dir/last is a folder... therefore it is a diffuser model
|
||||
last_dir = pathlib.Path(f'{output_dir}/{output_name}')
|
||||
|
3
gui.sh
Executable file
3
gui.sh
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
source venv/bin/activate
|
||||
python kohya_gui.py
|
@ -2,7 +2,7 @@ import gradio as gr
|
||||
from easygui import msgbox
|
||||
import subprocess
|
||||
from .common_gui import get_folder_path, add_pre_postfix, find_replace
|
||||
|
||||
import os
|
||||
|
||||
def caption_images(
|
||||
caption_text_input,
|
||||
@ -38,7 +38,7 @@ def caption_images(
|
||||
print(run_cmd)
|
||||
|
||||
# Run the command
|
||||
subprocess.run(run_cmd)
|
||||
os.system(run_cmd)
|
||||
|
||||
if overwrite_input:
|
||||
if not prefix == '' or not postfix == '':
|
||||
|
@ -3,7 +3,7 @@ from easygui import msgbox
|
||||
import subprocess
|
||||
import os
|
||||
from .common_gui import get_folder_path, add_pre_postfix
|
||||
|
||||
PYTHON = "python3" if os.name == 'posix' else './venv/Scripts/python.exe'
|
||||
|
||||
def caption_images(
|
||||
train_data_dir,
|
||||
@ -32,7 +32,7 @@ def caption_images(
|
||||
return
|
||||
|
||||
print(f'Captioning files in {train_data_dir}...')
|
||||
run_cmd = f'.\\venv\\Scripts\\python.exe "finetune/make_captions.py"'
|
||||
run_cmd = f'{PYTHON} "finetune/make_captions.py"'
|
||||
run_cmd += f' --batch_size="{int(batch_size)}"'
|
||||
run_cmd += f' --num_beams="{int(num_beams)}"'
|
||||
run_cmd += f' --top_p="{top_p}"'
|
||||
@ -48,7 +48,7 @@ def caption_images(
|
||||
print(run_cmd)
|
||||
|
||||
# Run the command
|
||||
subprocess.run(run_cmd)
|
||||
os.system(run_cmd)
|
||||
|
||||
# Add prefix and postfix
|
||||
add_pre_postfix(
|
||||
|
@ -9,7 +9,7 @@ folder_symbol = '\U0001f4c2' # 📂
|
||||
refresh_symbol = '\U0001f504' # 🔄
|
||||
save_style_symbol = '\U0001f4be' # 💾
|
||||
document_symbol = '\U0001F4C4' # 📄
|
||||
|
||||
PYTHON = "python3" if os.name == 'posix' else './venv/Scripts/python.exe'
|
||||
|
||||
def convert_model(
|
||||
source_model_input,
|
||||
@ -40,7 +40,7 @@ def convert_model(
|
||||
msgbox('The provided target folder does not exist')
|
||||
return
|
||||
|
||||
run_cmd = f'.\\venv\Scripts\python.exe "tools/convert_diffusers20_original_sd.py"'
|
||||
run_cmd = f'{PYTHON} "tools/convert_diffusers20_original_sd.py"'
|
||||
|
||||
v1_models = [
|
||||
'runwayml/stable-diffusion-v1-5',
|
||||
@ -87,7 +87,7 @@ def convert_model(
|
||||
print(run_cmd)
|
||||
|
||||
# Run the command
|
||||
subprocess.run(run_cmd)
|
||||
os.system(run_cmd)
|
||||
|
||||
if (
|
||||
not target_model_type == 'diffuser'
|
||||
|
@ -12,7 +12,7 @@ folder_symbol = '\U0001f4c2' # 📂
|
||||
refresh_symbol = '\U0001f504' # 🔄
|
||||
save_style_symbol = '\U0001f4be' # 💾
|
||||
document_symbol = '\U0001F4C4' # 📄
|
||||
|
||||
PYTHON = "python3" if os.name == 'posix' else './venv/Scripts/python.exe'
|
||||
|
||||
def extract_lora(
|
||||
model_tuned,
|
||||
@ -41,7 +41,7 @@ def extract_lora(
|
||||
return
|
||||
|
||||
run_cmd = (
|
||||
f'.\\venv\Scripts\python.exe "networks\extract_lora_from_models.py"'
|
||||
f'{PYTHON} "{os.path.join("networks","extract_lora_from_models.py")}"'
|
||||
)
|
||||
run_cmd += f' --save_precision {save_precision}'
|
||||
run_cmd += f' --save_to "{save_to}"'
|
||||
@ -54,7 +54,7 @@ def extract_lora(
|
||||
print(run_cmd)
|
||||
|
||||
# Run the command
|
||||
subprocess.run(run_cmd)
|
||||
os.system(run_cmd)
|
||||
|
||||
|
||||
###
|
||||
|
@ -3,7 +3,7 @@ from easygui import msgbox
|
||||
import subprocess
|
||||
import os
|
||||
from .common_gui import get_folder_path, add_pre_postfix
|
||||
|
||||
PYTHON = "python3" if os.name == 'posix' else './venv/Scripts/python.exe'
|
||||
|
||||
def caption_images(
|
||||
train_data_dir,
|
||||
@ -25,7 +25,7 @@ def caption_images(
|
||||
return
|
||||
|
||||
print(f'GIT captioning files in {train_data_dir}...')
|
||||
run_cmd = f'.\\venv\\Scripts\\python.exe "finetune/make_captions_by_git.py"'
|
||||
run_cmd = f'{PYTHON} "finetune/make_captions_by_git.py"'
|
||||
if not model_id == '':
|
||||
run_cmd += f' --model_id="{model_id}"'
|
||||
run_cmd += f' --batch_size="{int(batch_size)}"'
|
||||
|
@ -12,7 +12,7 @@ folder_symbol = '\U0001f4c2' # 📂
|
||||
refresh_symbol = '\U0001f504' # 🔄
|
||||
save_style_symbol = '\U0001f4be' # 💾
|
||||
document_symbol = '\U0001F4C4' # 📄
|
||||
|
||||
PYTHON = "python3" if os.name == 'posix' else './venv/Scripts/python.exe'
|
||||
|
||||
def merge_lora(
|
||||
lora_a_model,
|
||||
@ -43,7 +43,7 @@ def merge_lora(
|
||||
ratio_a = ratio
|
||||
ratio_b = 1 - ratio
|
||||
|
||||
run_cmd = f'.\\venv\Scripts\python.exe "networks\merge_lora.py"'
|
||||
run_cmd = f'{PYTHON} "{os.path.join("networks","merge_lora.py")}"'
|
||||
run_cmd += f' --save_precision {save_precision}'
|
||||
run_cmd += f' --precision {precision}'
|
||||
run_cmd += f' --save_to "{save_to}"'
|
||||
@ -53,7 +53,7 @@ def merge_lora(
|
||||
print(run_cmd)
|
||||
|
||||
# Run the command
|
||||
subprocess.run(run_cmd)
|
||||
os.system(run_cmd)
|
||||
|
||||
|
||||
###
|
||||
|
@ -3,7 +3,7 @@ from easygui import msgbox
|
||||
import subprocess
|
||||
import os
|
||||
from .common_gui import get_saveasfilename_path, get_file_path
|
||||
|
||||
PYTHON = "python3" if os.name == 'posix' else './venv/Scripts/python.exe'
|
||||
folder_symbol = '\U0001f4c2' # 📂
|
||||
refresh_symbol = '\U0001f504' # 🔄
|
||||
save_style_symbol = '\U0001f4be' # 💾
|
||||
@ -30,7 +30,7 @@ def resize_lora(
|
||||
if device == '':
|
||||
device = 'cuda'
|
||||
|
||||
run_cmd = f'.\\venv\Scripts\python.exe "networks\\resize_lora.py"'
|
||||
run_cmd = f'{PYTHON} "{os.path.join("networks","resize_lora.py")}"'
|
||||
run_cmd += f' --save_precision {save_precision}'
|
||||
run_cmd += f' --save_to {save_to}'
|
||||
run_cmd += f' --model {model}'
|
||||
@ -40,7 +40,7 @@ def resize_lora(
|
||||
print(run_cmd)
|
||||
|
||||
# Run the command
|
||||
subprocess.run(run_cmd)
|
||||
os.system(run_cmd)
|
||||
|
||||
|
||||
###
|
||||
|
@ -5,7 +5,7 @@ import subprocess
|
||||
import time
|
||||
|
||||
tensorboard_proc = None # I know... bad but heh
|
||||
|
||||
TENSORBOARD = "tensorboard" if os.name == 'posix' else 'tensorboard.exe'
|
||||
|
||||
def start_tensorboard(logging_dir):
|
||||
global tensorboard_proc
|
||||
@ -15,7 +15,7 @@ def start_tensorboard(logging_dir):
|
||||
msgbox(msg='Error: log folder is empty')
|
||||
return
|
||||
|
||||
run_cmd = f'tensorboard.exe --logdir "{logging_dir}"'
|
||||
run_cmd = [f'{TENSORBOARD}', '--logdir', f'{logging_dir}']
|
||||
|
||||
print(run_cmd)
|
||||
if tensorboard_proc is not None:
|
||||
|
@ -7,7 +7,7 @@ from .common_gui import (
|
||||
get_any_file_path,
|
||||
get_file_path,
|
||||
)
|
||||
|
||||
PYTHON = "python3" if os.name == 'posix' else './venv/Scripts/python.exe'
|
||||
folder_symbol = '\U0001f4c2' # 📂
|
||||
refresh_symbol = '\U0001f504' # 🔄
|
||||
save_style_symbol = '\U0001f4be' # 💾
|
||||
@ -27,13 +27,15 @@ def verify_lora(
|
||||
msgbox('The provided model A is not a file')
|
||||
return
|
||||
|
||||
run_cmd = f'.\\venv\Scripts\python.exe "networks\check_lora_weights.py"'
|
||||
run_cmd += f' {lora_model}'
|
||||
run_cmd = [
|
||||
PYTHON,
|
||||
os.path.join("networks","check_lora_weights.py"),
|
||||
f'{lora_model}'
|
||||
]
|
||||
|
||||
print(run_cmd)
|
||||
print(" ".join(run_cmd))
|
||||
|
||||
# Run the command
|
||||
subprocess.run(run_cmd)
|
||||
process = subprocess.Popen(
|
||||
run_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
||||
)
|
||||
|
@ -2,6 +2,7 @@ import gradio as gr
|
||||
from easygui import msgbox
|
||||
import subprocess
|
||||
from .common_gui import get_folder_path
|
||||
import os
|
||||
|
||||
|
||||
def caption_images(train_data_dir, caption_extension, batch_size, thresh):
|
||||
@ -30,7 +31,7 @@ def caption_images(train_data_dir, caption_extension, batch_size, thresh):
|
||||
print(run_cmd)
|
||||
|
||||
# Run the command
|
||||
subprocess.run(run_cmd)
|
||||
os.system(run_cmd)
|
||||
|
||||
print('...captioning done')
|
||||
|
||||
|
@ -544,7 +544,7 @@ def train_model(
|
||||
|
||||
print(run_cmd)
|
||||
# Run the command
|
||||
subprocess.run(run_cmd)
|
||||
os.system(run_cmd)
|
||||
|
||||
# check if output_dir/last is a folder... therefore it is a diffuser model
|
||||
last_dir = pathlib.Path(f'{output_dir}/{output_name}')
|
||||
|
@ -498,7 +498,7 @@ def train_model(
|
||||
|
||||
print(run_cmd)
|
||||
# Run the command
|
||||
subprocess.run(run_cmd)
|
||||
os.system(run_cmd)
|
||||
|
||||
# check if output_dir/last is a folder... therefore it is a diffuser model
|
||||
last_dir = pathlib.Path(f'{output_dir}/{output_name}')
|
||||
|
12
ubuntu_setup.sh
Executable file
12
ubuntu_setup.sh
Executable file
@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
echo installing tk
|
||||
sudo apt install python3-tk
|
||||
python3 -m venv venv
|
||||
source venv/bin/activate
|
||||
pip install torch==1.12.1+cu116 torchvision==0.13.1+cu116 --extra-index-url https://download.pytorch.org/whl/cu116
|
||||
pip install --use-pep517 --upgrade -r requirements.txt
|
||||
pip install -U -I --no-deps https://github.com/C43H66N12O12S2/stable-diffusion-webui/releases/download/linux/xformers-0.0.14.dev0-cp310-cp310-linux_x86_64.whl
|
||||
|
||||
accelerate config
|
||||
|
||||
echo -e "setup finished! run \e[0;92m./gui.sh\e[0m to start"
|
Loading…
Reference in New Issue
Block a user