Advertisement
Guest User

Untitled

a guest
Feb 2nd, 2025
19
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Get the current directory
  2. $currentDirectory = Get-Location
  3. $KOHYA_DIR = Convert-Path -Path "PATH\TO\sd-scripts\"
  4.  
  5. # Get all directories in the current directory
  6. $directories = Get-ChildItem -Directory
  7.  
  8. # Iterate through each directory and run your command
  9. foreach ($directory in $directories) {
  10.     # Enter the directory
  11.     Set-Location -Path $directory.FullName
  12.  
  13.     # Get the full path of the current directory
  14.     $currentDirFullPath = (Get-Item -Path ".\").FullName
  15.  
  16.     # Get the name of the current directory
  17.     $currentDirName = $directory.Name
  18.    
  19.     Set-Location $KOHYA_DIR
  20.     Write-Host "Executing command in $($KOHYA_DIR)"
  21.     & "PATH\TO\sd-scripts\venv\Scripts\Activate.ps1"
  22.     # Build the command with modified parameters
  23.     $command = "accelerate launch --num_cpu_threads_per_process=2 ""./sdxl_train_network.py"" --network_train_unet_only --bucket_reso_steps=64 --cache_latents --cache_latents_to_disk --caption_extension="".txt"" --debiased_estimation_loss --enable_bucket --min_bucket_reso=640 --max_bucket_reso=2048 --flip_aug --gradient_checkpointing --keep_tokens=""1"" --lr_scheduler=""cosine_with_restarts"" --lr_scheduler_num_cycles=""2"" --lr_warmup_steps=""150"" --max_data_loader_n_workers=""1"" --max_grad_norm=""1"" --resolution=""1024,1024"" --max_token_length=225 --max_train_epochs=""10"" --mixed_precision=""bf16"" --network_alpha=""4"" --network_args block_lr_zero_threshold=""0"" --network_dim=""4"" --network_module=networks.lora --network_train_unet_only --no_half_vae --noise_offset=0.02 --optimizer_type=""AdamW"" --output_dir=""$currentDirFullPath"" --output_name=""$currentDirName"" --persistent_data_loader_workers --pretrained_model_name_or_path=""PATH/TO/illustriousXL_v01.safetensors"" --save_every_n_epochs=""1"" --save_model_as=safetensors --save_precision=""bf16"" --shuffle_caption --train_batch_size=""4"" --save_last_n_epochs=""1"" --train_data_dir=""$currentDirFullPath"" --unet_lr=0.0004 --xformers"
  24.  
  25.     # Run the command
  26.     Invoke-Expression -Command $command
  27.  
  28.     # Return to the original directory
  29.     Set-Location -Path $currentDirectory
  30. }
  31.  
  32. Write-Host "Finished!"
  33. pause
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement