Hello
I am trying to run “kohya_ss” from command prompt instead of browser:
I have the following script
# -*- coding: utf-8 -*-
import os
import subprocess
import toml
import einops
import imagesize
import voluptuous
# Change to Kohya GUI base directory (double-check the path)
os.chdir(r"D:\Ganu\AIImage\huggingface\kohya_ss\kohya_ss\sd-scripts") # Or kohya_sskohya_gui depending on where the script is
# Config file path (LoRA training settings)
config_file = r"D:\Ganu\AIImage\project\Train-10Images-0Parameters-14thApril2025\models\lora_stabilityaistable-diffusion-xl-base-1.0_14thApril2025\config_lora-20250403-132700.toml"
# Confirm that train_network.py exists in the directory
train_script_path = os.path.join(os.getcwd(), "train_network.py") # Update if the script is named differently
# Check if the script exists in the expected directory
if not os.path.exists(train_script_path):
print(f"Error: {train_script_path} not found. Please check the script name or directory.")
else:
# Build the command — ensure you are launching the correct script
command = [
"accelerate", "launch",
"train_network.py", # Update if the script name differs (e.g., 'kohya_train_network.py')
"--config_file", config_file
]
print(f"🚀 Launching Kohya training with: {config_file}")
try:
subprocess.run(command, check=True)
except subprocess.CalledProcessError as e:
print(f"Error occurred while running the training script: {e}")
I am getting the error
python train_lora.py
?? Launching Kohya training with: D:\Ganu\AIImage\project\Train-10Images-0Parameters-14thApril2025\models\lora_stabilityaistable-diffusion-xl-base-1.0_14thApril2025\config_lora-20250403-132700.toml
2025-04-14 11:30:36 INFO Loading settings from train_util.py:4177
D:\Ganu\AIImage\project\Train-10Images-0Parameters-14thApril2025\models\lora_stabilityaistable-diffusion-xl-base-1.0_14thApril2025\config_lora-20250403-132700.toml
...
INFO D:\Ganu\AIImage\project\Train-10Images-0Parameters-14thApril2025\models\lora_stabilityaistable-diffusion-xl-base-1.0_14thApril2025\config_lora-20250403-132700 train_util.py:4196
2025-04-14 11:30:36 INFO prepare tokenizer train_util.py:4668
2025-04-14 11:30:37 INFO update token length: 75 train_util.py:4685
INFO Using DreamBooth method. train_network.py:172
INFO prepare images. train_util.py:1815
INFO found directory D:\Ganu\AIImage\huggingface\kohya_ss\kohya_ss\trained-model\img\40_10Images 0Parameters contains 10 image files train_util.py:1762
INFO 400 train images with repeating. train_util.py:1856
INFO 0 reg images. train_util.py:1859
WARNING no regularization images / 正則化画像が見つかりませんでした train_util.py:1864
INFO [Dataset 0] config_util.py:572
batch_size: 1
resolution: (512, 512)
enable_bucket: True
network_multiplier: 1.0
min_bucket_reso: 256
max_bucket_reso: 2048
bucket_reso_steps: 64
bucket_no_upscale: True
[Subset 0 of Dataset 0]
image_dir: "D:\Ganu\AIImage\huggingface\kohya_ss\kohya_ss\trained-model\img\40_10Images 0Parameters"
image_count: 10
num_repeats: 40
shuffle_caption: False
keep_tokens: 0
keep_tokens_separator:
caption_separator: ,
secondary_separator: None
enable_wildcard: False
caption_dropout_rate: 0.0
caption_dropout_every_n_epoches: 0
caption_tag_dropout_rate: 0.0
caption_prefix: None
caption_suffix: None
color_aug: False
flip_aug: False
face_crop_aug_range: None
random_crop: False
token_warmup_min: 1,
token_warmup_step: 0,
alpha_mask: False,
is_reg: False
class_tokens: 10Images 0Parameters
caption_extension: .txt
INFO [Dataset 0] config_util.py:578
INFO loading image sizes. train_util.py:911
100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 10/10 [00:00<00:00, 640.02it/s]
INFO make buckets train_util.py:917
WARNING min_bucket_reso and max_bucket_reso are ignored if bucket_no_upscale is set, because bucket reso is defined by image size automatically / train_util.py:934
bucket_no_upscaleが指定された場合は、bucketの解像度は画像サイズから自動計算されるため、min_bucket_resoとmax_bucket_resoは無視されます
INFO number of images (including repeats) / 各bucketの画像枚数(繰り返し回数を含む) train_util.py:963
INFO bucket 0: resolution (704, 320), count: 400 train_util.py:968
INFO mean ar error (without repeats): 0.09826218809406236 train_util.py:973
INFO preparing accelerator train_network.py:225
D:\Ganu\AIImage\huggingface\kohya_ss\Python310\lib\site-packages\accelerate\accelerator.py:506: UserWarning: `log_with=tensorboard` was passed but no supported trackers are currently installed.
warnings.warn(f"`log_with={log_with}` was passed but no supported trackers are currently installed.")
accelerator device: cpu
INFO loading model for process 0/1 train_util.py:4826
INFO load Diffusers pretrained models: stabilityai/stable-diffusion-xl-base-1.0 train_util.py:4788
Loading pipeline components...: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 4/4 [00:01<00:00, 2.89it/s]
You have disabled the safety checker for <class 'diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline'> by passing `safety_checker=None`. Ensure that you abide to the conditions of the Stable Diffusion license and do not expose unfiltered results in services or applications open to the public. Both the diffusers team and Hugging Face strongly recommend to keep the safety filter enabled in all public facing circumstances, disabling it only for use-cases that involve analyzing network behavior or auditing its results. For more information, please have a look at https://github.com/huggingface/diffusers/pull/254 .
2025-04-14 11:30:39 INFO UNet2DConditionModel: 128, [5, 10, 20], 2048, True, None original_unet.py:1387
Traceback (most recent call last):
File "D:\Ganu\AIImage\huggingface\kohya_ss\kohya_ss\sd-scripts\train_network.py", line 1242, in <module>
trainer.train(args)
File "D:\Ganu\AIImage\huggingface\kohya_ss\kohya_ss\sd-scripts\train_network.py", line 234, in train
model_version, text_encoder, vae, unet = self.load_target_model(args, weight_dtype, accelerator)
File "D:\Ganu\AIImage\huggingface\kohya_ss\kohya_ss\sd-scripts\train_network.py", line 101, in load_target_model
text_encoder, vae, unet, _ = train_util.load_target_model(args, weight_dtype, accelerator)
File "D:\Ganu\AIImage\huggingface\kohya_ss\kohya_ss\sd-scripts\library\train_util.py", line 4828, in load_target_model
text_encoder, vae, unet, load_stable_diffusion_format = _load_target_model(
File "D:\Ganu\AIImage\huggingface\kohya_ss\kohya_ss\sd-scripts\library\train_util.py", line 4804, in _load_target_model
original_unet = UNet2DConditionModel(
File "D:\Ganu\AIImage\huggingface\kohya_ss\kohya_ss\sd-scripts\library\original_unet.py", line 1427, in __init__
attn_num_head_channels=attention_head_dim[i],
IndexError: list index out of range
Traceback (most recent call last):
File "D:\Ganu\AIImage\huggingface\kohya_ss\Python310\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "D:\Ganu\AIImage\huggingface\kohya_ss\Python310\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "D:\Ganu\AIImage\huggingface\kohya_ss\Python310\Scripts\accelerate.exe\__main__.py", line 7, in <module>
File "D:\Ganu\AIImage\huggingface\kohya_ss\Python310\lib\site-packages\accelerate\commands\accelerate_cli.py", line 50, in main
args.func(args)
File "D:\Ganu\AIImage\huggingface\kohya_ss\Python310\lib\site-packages\accelerate\commands\launch.py", line 1213, in launch_command
simple_launcher(args)
File "D:\Ganu\AIImage\huggingface\kohya_ss\Python310\lib\site-packages\accelerate\commands\launch.py", line 795, in simple_launcher
raise subprocess.CalledProcessError(returncode=process.returncode, cmd=cmd)
subprocess.CalledProcessError: Command '['D:\\Ganu\\AIImage\\huggingface\\kohya_ss\\Python310\\python.exe', 'train_network.py', '--config_file', 'D:\\Ganu\\AIImage\\project\\Train-10Images-0Parameters-14thApril2025\\models\\lora_stabilityaistable-diffusion-xl-base-1.0_14thApril2025\\config_lora-20250403-132700.toml']' returned non-zero exit status 1.
Error occurred while running the training script: Command '['accelerate', 'launch', 'train_network.py', '--config_file', 'D:\\Ganu\\AIImage\\project\\Train-10Images-0Parameters-14thApril2025\\models\\lora_stabilityaistable-diffusion-xl-base-1.0_14thApril2025\\config_lora-20250403-132700.toml']' returned non-zero exit status 1.
Can you please help?
Thank You