ACCC1380 commited on
Commit
d0cefbe
1 Parent(s): 970a864

Upload lora-scripts/resize.ps1 with huggingface_hub

Browse files
Files changed (1) hide show
  1. lora-scripts/resize.ps1 +41 -0
lora-scripts/resize.ps1 ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # LoRA resize script by @bdsqlsz
2
+
3
+ $save_precision = "fp16" # precision in saving, default float | 保存精度, 可选 float、fp16、bf16, 默认 float
4
+ $new_rank = 4 # dim rank of output LoRA | dim rank等级, 默认 4
5
+ $model = "./output/lora_name.safetensors" # original LoRA model path need to resize, save as cpkt or safetensors | 需要调整大小的模型路径, 保存格式 cpkt 或 safetensors
6
+ $save_to = "./output/lora_name_new.safetensors" # output LoRA model path, save as ckpt or safetensors | 输出路径, 保存格式 cpkt 或 safetensors
7
+ $device = "cuda" # device to use, cuda for GPU | 使用 GPU跑, 默认 CPU
8
+ $verbose = 1 # display verbose resizing information | rank变更时, 显示详细信息
9
+ $dynamic_method = "" # Specify dynamic resizing method, --new_rank is used as a hard limit for max rank | 动态调节大小,可选"sv_ratio", "sv_fro", "sv_cumulative",默认无
10
+ $dynamic_param = "" # Specify target for dynamic reduction | 动态参数,sv_ratio模式推荐1~2, sv_cumulative模式0~1, sv_fro模式0~1, 比sv_cumulative要高
11
+
12
+
13
+ # Activate python venv
14
+ .\venv\Scripts\activate
15
+
16
+ $Env:HF_HOME = "huggingface"
17
+ $ext_args = [System.Collections.ArrayList]::new()
18
+
19
+ if ($verbose) {
20
+ [void]$ext_args.Add("--verbose")
21
+ }
22
+
23
+ if ($dynamic_method) {
24
+ [void]$ext_args.Add("--dynamic_method=" + $dynamic_method)
25
+ }
26
+
27
+ if ($dynamic_param) {
28
+ [void]$ext_args.Add("--dynamic_param=" + $dynamic_param)
29
+ }
30
+
31
+ # run resize
32
+ accelerate launch --num_cpu_threads_per_process=8 "./sd-scripts/networks/resize_lora.py" `
33
+ --save_precision=$save_precision `
34
+ --new_rank=$new_rank `
35
+ --model=$model `
36
+ --save_to=$save_to `
37
+ --device=$device `
38
+ $ext_args
39
+
40
+ Write-Output "Resize finished"
41
+ Read-Host | Out-Null ;