Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: P2Enjoy/kohya_ss
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: rundiffusion/kohya_ss_rd
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Can’t automatically merge. Don’t worry, you can still create the pull request.
  • 5 commits
  • 44 files changed
  • 2 contributors

Commits on Feb 12, 2023

  1. Copy the full SHA
    dd742b4 View commit details

Commits on Feb 24, 2023

  1. Removed deepspeed

    It kept failing
    
    Signed-off-by: rundiffusion <124859560+rundiffusion@users.noreply.github.com>
    rundiffusion authored Feb 24, 2023
    Copy the full SHA
    4e6a422 View commit details
  2. Adding 0.0.0.0 to kohya

    Signed-off-by: rundiffusion <124859560+rundiffusion@users.noreply.github.com>
    rundiffusion authored Feb 24, 2023
    Copy the full SHA
    e2636f8 View commit details
  3. server_name update

    Signed-off-by: rundiffusion <124859560+rundiffusion@users.noreply.github.com>
    rundiffusion authored Feb 24, 2023
    Copy the full SHA
    23b5a1c View commit details
  4. share true

    Signed-off-by: rundiffusion <124859560+rundiffusion@users.noreply.github.com>
    rundiffusion authored Feb 24, 2023
    Copy the full SHA
    153eacf View commit details
Showing with 117 additions and 2,038 deletions.
  1. +8 −0 .idea/.gitignore
  2. +12 −0 .idea/inspectionProfiles/Project_Default.xml
  3. +6 −0 .idea/inspectionProfiles/profiles_settings.xml
  4. +14 −0 .idea/kohya_ss.iml
  5. +4 −0 .idea/misc.xml
  6. +8 −0 .idea/modules.xml
  7. +6 −0 .idea/vcs.xml
  8. +0 −138 README-ja.md
  9. +4 −330 README.md
  10. +0 −54 bitsandbytes_windows/cextension.py
  11. BIN bitsandbytes_windows/libbitsandbytes_cpu.dll
  12. BIN bitsandbytes_windows/libbitsandbytes_cuda116.dll
  13. +0 −166 bitsandbytes_windows/main.py
  14. +3 −2 dreambooth_gui.py
  15. +0 −14 examples/caption.ps1
  16. +0 −20 examples/caption_subfolders.ps1
  17. +0 −87 examples/kohya-1-folders.ps1
  18. +0 −154 examples/kohya-3-folders.ps1
  19. +0 −154 examples/kohya.ps1
  20. +0 −153 examples/kohya_finetune.ps1
  21. +0 −90 examples/kohya_new-v3.ps1
  22. +0 −64 examples/kohya_train_db_fixed_with-reg_SDv2 512 base.ps1
  23. +0 −15 examples/word_frequency.ps1
  24. +10 −7 finetune_gui.py
  25. +0 −6 gui.bat
  26. +0 −2 gui.ps1
  27. +2 −0 kohya_gui.py
  28. +3 −2 library/basic_caption_gui.py
  29. +3 −2 library/blip_caption_gui.py
  30. +3 −2 library/convert_model_gui.py
  31. +3 −4 library/extract_lora_gui.py
  32. +2 −1 library/git_caption_gui.py
  33. +3 −2 library/merge_lora_gui.py
  34. +2 −1 library/resize_lora_gui.py
  35. +3 −2 library/verify_lora_gui.py
  36. +3 −2 library/wd14_caption_gui.py
  37. +6 −6 lora_gui.py
  38. +5 −2 requirements.txt
  39. +3 −2 textual_inversion_gui.py
  40. +0 −296 train_db_README-ja.md
  41. +0 −191 train_network_README-ja.md
  42. +0 −63 train_ti_README-ja.md
  43. +0 −3 upgrade.ps1
  44. +1 −1 utilities.cmd
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions .idea/kohya_ss.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

138 changes: 0 additions & 138 deletions README-ja.md

This file was deleted.

334 changes: 4 additions & 330 deletions README.md

Large diffs are not rendered by default.

54 changes: 0 additions & 54 deletions bitsandbytes_windows/cextension.py

This file was deleted.

Binary file removed bitsandbytes_windows/libbitsandbytes_cpu.dll
Binary file not shown.
Binary file removed bitsandbytes_windows/libbitsandbytes_cuda116.dll
Binary file not shown.
166 changes: 0 additions & 166 deletions bitsandbytes_windows/main.py

This file was deleted.

5 changes: 3 additions & 2 deletions dreambooth_gui.py
Original file line number Diff line number Diff line change
@@ -342,7 +342,8 @@ def train_model(
lr_warmup_steps = round(float(int(lr_warmup) * int(max_train_steps) / 100))
print(f'lr_warmup_steps = {lr_warmup_steps}')

run_cmd = f'accelerate launch --num_cpu_threads_per_process={num_cpu_threads_per_process} "train_db.py"'
run_cmd = f". {os.environ['ROOT']}/kohya_venv/bin/activate; "
run_cmd += f'accelerate launch --num_cpu_threads_per_process={num_cpu_threads_per_process} "train_db.py"'
if v2:
run_cmd += ' --v2'
if v_parameterization:
@@ -425,7 +426,7 @@ def train_model(

print(run_cmd)
# Run the command
subprocess.run(run_cmd)
subprocess.run(run_cmd, shell=True)

# check if output_dir/last is a folder... therefore it is a diffuser model
last_dir = pathlib.Path(f'{output_dir}/{output_name}')
14 changes: 0 additions & 14 deletions examples/caption.ps1

This file was deleted.

20 changes: 0 additions & 20 deletions examples/caption_subfolders.ps1

This file was deleted.

87 changes: 0 additions & 87 deletions examples/kohya-1-folders.ps1

This file was deleted.

154 changes: 0 additions & 154 deletions examples/kohya-3-folders.ps1

This file was deleted.

154 changes: 0 additions & 154 deletions examples/kohya.ps1

This file was deleted.

153 changes: 0 additions & 153 deletions examples/kohya_finetune.ps1

This file was deleted.

90 changes: 0 additions & 90 deletions examples/kohya_new-v3.ps1

This file was deleted.

64 changes: 0 additions & 64 deletions examples/kohya_train_db_fixed_with-reg_SDv2 512 base.ps1

This file was deleted.

15 changes: 0 additions & 15 deletions examples/word_frequency.ps1

This file was deleted.

17 changes: 10 additions & 7 deletions finetune_gui.py
Original file line number Diff line number Diff line change
@@ -268,8 +268,10 @@ def train_model(
if not os.path.exists(train_dir):
os.mkdir(train_dir)

run_cmd = (
f'./venv/Scripts/python.exe finetune/merge_captions_to_metadata.py'
run_cmd = f". {os.environ['ROOT']}/kohya_venv/bin/activate; "
run_cmd += f"source {os.environ['ROOT']}/kohya_venv/bin/activate; "
run_cmd += (
f'python finetune/merge_captions_to_metadata.py'
)
if caption_extension == '':
run_cmd += f' --caption_extension=".caption"'
@@ -283,12 +285,12 @@ def train_model(
print(run_cmd)

# Run the command
subprocess.run(run_cmd)
subprocess.run(run_cmd, shell=True)

# 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}"'
@@ -307,7 +309,7 @@ def train_model(
print(run_cmd)

# Run the command
subprocess.run(run_cmd)
subprocess.run(run_cmd, shell=True)

image_num = len(
[
@@ -335,7 +337,8 @@ def train_model(
lr_warmup_steps = round(float(int(lr_warmup) * int(max_train_steps) / 100))
print(f'lr_warmup_steps = {lr_warmup_steps}')

run_cmd = f'accelerate launch --num_cpu_threads_per_process={num_cpu_threads_per_process} "./fine_tune.py"'
f"{os.environ['ROOT']}/kohya_venv/bin/activate; "
run_cmd += f'accelerate launch --num_cpu_threads_per_process={num_cpu_threads_per_process} "./fine_tune.py"'
if v2:
run_cmd += ' --v2'
if v_parameterization:
@@ -414,7 +417,7 @@ def train_model(

print(run_cmd)
# Run the command
subprocess.run(run_cmd)
subprocess.run(run_cmd, shell=True)

# check if output_dir/last is a folder... therefore it is a diffuser model
last_dir = pathlib.Path(f'{output_dir}/{output_name}')
6 changes: 0 additions & 6 deletions gui.bat
Original file line number Diff line number Diff line change
@@ -1,6 +0,0 @@
@echo off

call venv\Scripts\activate.bat
python.exe kohya_gui.py %*

pause
2 changes: 0 additions & 2 deletions gui.ps1
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
.\venv\Scripts\activate
python.exe kohya_gui.py $args
2 changes: 2 additions & 0 deletions kohya_gui.py
Original file line number Diff line number Diff line change
@@ -57,6 +57,8 @@ def UI(**kwargs):
launch_kwargs["server_port"] = server_port
if inbrowser:
launch_kwargs["inbrowser"] = inbrowser
launch_kwargs["server_name"] = "0.0.0.0"
launch_kwargs["share"] = True
interface.launch(**launch_kwargs)

if __name__ == '__main__':
5 changes: 3 additions & 2 deletions library/basic_caption_gui.py
Original file line number Diff line number Diff line change
@@ -27,7 +27,8 @@ def caption_images(
print(
f'Captioning files in {images_dir_input} with {caption_text_input}...'
)
run_cmd = f'python "tools/caption.py"'
run_cmd = f". {os.environ['ROOT']}/kohya_venv/bin/activate; "
run_cmd += f'python "tools/caption.py"'
run_cmd += f' --caption_text="{caption_text_input}"'
if overwrite_input:
run_cmd += f' --overwrite'
@@ -38,7 +39,7 @@ def caption_images(
print(run_cmd)

# Run the command
subprocess.run(run_cmd)
subprocess.run(run_cmd, shell=True)

if overwrite_input:
if not prefix == '' or not postfix == '':
5 changes: 3 additions & 2 deletions library/blip_caption_gui.py
Original file line number Diff line number Diff line change
@@ -32,7 +32,8 @@ 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". {os.environ['ROOT']}/kohya_venv/bin/activate; "
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 +49,7 @@ def caption_images(
print(run_cmd)

# Run the command
subprocess.run(run_cmd)
subprocess.run(run_cmd, shell=True)

# Add prefix and postfix
add_pre_postfix(
5 changes: 3 additions & 2 deletions library/convert_model_gui.py
Original file line number Diff line number Diff line change
@@ -40,7 +40,8 @@ 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". {os.environ['ROOT']}/kohya_venv/bin/activate; "
run_cmd +=f'python "tools/convert_diffusers20_original_sd.py"'

v1_models = [
'runwayml/stable-diffusion-v1-5',
@@ -87,7 +88,7 @@ def convert_model(
print(run_cmd)

# Run the command
subprocess.run(run_cmd)
subprocess.run(run_cmd, shell=True)

if (
not target_model_type == 'diffuser'
7 changes: 3 additions & 4 deletions library/extract_lora_gui.py
Original file line number Diff line number Diff line change
@@ -40,9 +40,8 @@ def extract_lora(
msgbox('The provided base model is not a file')
return

run_cmd = (
f'.\\venv\Scripts\python.exe "networks\extract_lora_from_models.py"'
)
run_cmd = f". {os.environ['ROOT']}/kohya_venv/bin/activate; "
run_cmd +=f'python "networks/extract_lora_from_models.py"'
run_cmd += f' --save_precision {save_precision}'
run_cmd += f' --save_to "{save_to}"'
run_cmd += f' --model_org "{model_org}"'
@@ -54,7 +53,7 @@ def extract_lora(
print(run_cmd)

# Run the command
subprocess.run(run_cmd)
subprocess.run(run_cmd, shell=True)


###
3 changes: 2 additions & 1 deletion library/git_caption_gui.py
Original file line number Diff line number Diff line change
@@ -25,7 +25,8 @@ def caption_images(
return

print(f'GIT captioning files in {train_data_dir}...')
run_cmd = f'.\\venv\\Scripts\\python.exe "finetune/make_captions.py"'
run_cmd = f". {os.environ['ROOT']}/kohya_venv/bin/activate; "
run_cmd += f'python "finetune/make_captions.py"'
if not model_id == '':
run_cmd += f' --model_id="{model_id}"'
run_cmd += f' --batch_size="{int(batch_size)}"'
5 changes: 3 additions & 2 deletions library/merge_lora_gui.py
Original file line number Diff line number Diff line change
@@ -43,7 +43,8 @@ def merge_lora(
ratio_a = ratio
ratio_b = 1 - ratio

run_cmd = f'.\\venv\Scripts\python.exe "networks\merge_lora.py"'
run_cmd = f". {os.environ['ROOT']}/kohya_venv/bin/activate; "
run_cmd += f'python "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 +54,7 @@ def merge_lora(
print(run_cmd)

# Run the command
subprocess.run(run_cmd)
subprocess.run(run_cmd, shell=True)


###
3 changes: 2 additions & 1 deletion library/resize_lora_gui.py
Original file line number Diff line number Diff line change
@@ -30,7 +30,8 @@ def resize_lora(
if device == '':
device = 'cuda'

run_cmd = f'.\\venv\Scripts\python.exe "networks\\resize_lora.py"'
run_cmd = f". {os.environ['ROOT']}/kohya_venv/bin/activate; "
run_cmd += f'python "networks\\resize_lora.py"'
run_cmd += f' --save_precision {save_precision}'
run_cmd += f' --save_to {save_to}'
run_cmd += f' --model {model}'
5 changes: 3 additions & 2 deletions library/verify_lora_gui.py
Original file line number Diff line number Diff line change
@@ -27,13 +27,14 @@ 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". {os.environ['ROOT']}/kohya_venv/bin/activate; "
run_cmd += f'python "networks/check_lora_weights.py"'
run_cmd += f' {lora_model}'

print(run_cmd)

# Run the command
subprocess.run(run_cmd)
subprocess.run(run_cmd, shell=True)
process = subprocess.Popen(
run_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE
)
5 changes: 3 additions & 2 deletions library/wd14_caption_gui.py
Original file line number Diff line number Diff line change
@@ -20,7 +20,8 @@ def caption_images(train_data_dir, caption_extension, batch_size, thresh):
return

print(f'Captioning files in {train_data_dir}...')
run_cmd = f'accelerate launch "./finetune/tag_images_by_wd14_tagger.py"'
run_cmd = f". {os.environ['ROOT']}/kohya_venv/bin/activate; "
run_cmd += f'accelerate launch "./finetune/tag_images_by_wd14_tagger.py"'
run_cmd += f' --batch_size="{int(batch_size)}"'
run_cmd += f' --thresh="{thresh}"'
if caption_extension != '':
@@ -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)
subprocess.run(run_cmd, shell=True)

print('...captioning done')

12 changes: 6 additions & 6 deletions lora_gui.py
Original file line number Diff line number Diff line change
@@ -278,7 +278,7 @@ def train_model(
random_crop,
bucket_reso_steps,
caption_dropout_every_n_epochs, caption_dropout_rate,
):
):
if pretrained_model_name_or_path == '':
msgbox('Source model information is missing')
return
@@ -381,10 +381,10 @@ def train_model(
lr_warmup_steps = round(float(int(lr_warmup) * int(max_train_steps) / 100))
print(f'lr_warmup_steps = {lr_warmup_steps}')

run_cmd = f'accelerate launch --num_cpu_threads_per_process={num_cpu_threads_per_process} "train_network.py"'
run_cmd = f". {os.environ['ROOT']}/kohya_venv/bin/activate; "
run_cmd += f'accelerate launch --num_cpu_threads_per_process={num_cpu_threads_per_process} "train_network.py"'

# run_cmd += f' --caption_dropout_rate="0.1" --caption_dropout_every_n_epochs=1' # --random_crop'

if v2:
run_cmd += ' --v2'
if v_parameterization:
@@ -485,7 +485,7 @@ def train_model(

print(run_cmd)
# Run the command
subprocess.run(run_cmd)
subprocess.run(run_cmd, shell=True)

# check if output_dir/last is a folder... therefore it is a diffuser model
last_dir = pathlib.Path(f'{output_dir}/{output_name}')
@@ -844,11 +844,11 @@ def UI(**kwargs):
launch_kwargs["auth"] = (kwargs.get('username', None), kwargs.get('password', None))
if kwargs.get('server_port', 0) > 0:
launch_kwargs["server_port"] = kwargs.get('server_port', 0)
if kwargs.get('inbrowser', False):
if kwargs.get('inbrowser', False):
launch_kwargs["inbrowser"] = kwargs.get('inbrowser', False)
print(launch_kwargs)
interface.launch(**launch_kwargs)


if __name__ == '__main__':
# torch.cuda.set_per_process_memory_fraction(0.48)
7 changes: 5 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -21,6 +21,9 @@ fairscale==0.4.13
# tensorflow<2.11
tensorflow==2.10.1
huggingface-hub==0.12.0
xformers @ https://github.com/C43H66N12O12S2/stable-diffusion-webui/releases/download/f/xformers-0.0.14.dev0-cp310-cp310-win_amd64.whl
torch
torchvision
xformers
# for kohya_ss library
.
triton==2.0.0.dev20230208
.
5 changes: 3 additions & 2 deletions textual_inversion_gui.py
Original file line number Diff line number Diff line change
@@ -379,7 +379,8 @@ def train_model(
lr_warmup_steps = round(float(int(lr_warmup) * int(max_train_steps) / 100))
print(f'lr_warmup_steps = {lr_warmup_steps}')

run_cmd = f'accelerate launch --num_cpu_threads_per_process={num_cpu_threads_per_process} "train_textual_inversion.py"'
run_cmd = f". {os.environ['ROOT']}/kohya_venv/bin/activate; "
run_cmd += f'accelerate launch --num_cpu_threads_per_process={num_cpu_threads_per_process} "train_textual_inversion.py"'
if v2:
run_cmd += ' --v2'
if v_parameterization:
@@ -471,7 +472,7 @@ def train_model(

print(run_cmd)
# Run the command
subprocess.run(run_cmd)
subprocess.run(run_cmd, shell=True)

# check if output_dir/last is a folder... therefore it is a diffuser model
last_dir = pathlib.Path(f'{output_dir}/{output_name}')
296 changes: 0 additions & 296 deletions train_db_README-ja.md

This file was deleted.

191 changes: 0 additions & 191 deletions train_network_README-ja.md

This file was deleted.

63 changes: 0 additions & 63 deletions train_ti_README-ja.md

This file was deleted.

3 changes: 0 additions & 3 deletions upgrade.ps1

This file was deleted.

2 changes: 1 addition & 1 deletion utilities.cmd
Original file line number Diff line number Diff line change
@@ -1 +1 @@
.\venv\Scripts\python.exe library\utilities.py
python library/utilities.py