Upload lora-scripts/tagger.ps1 with huggingface_hub
Browse files- lora-scripts/tagger.ps1 +73 -0
lora-scripts/tagger.ps1
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# tagger script by @bdsqlsz
|
2 |
+
|
3 |
+
# Train data path
|
4 |
+
$train_data_dir = "./input" # input images path | 图片输入路径
|
5 |
+
$repo_id = "SmilingWolf/wd-v1-4-swinv2-tagger-v2" # model repo id from huggingface |huggingface模型repoID
|
6 |
+
$model_dir = "" # model dir path | 本地模型文件夹路径
|
7 |
+
$batch_size = 4 # batch size in inference 批处理大小,越大越快
|
8 |
+
$max_data_loader_n_workers = 0 # enable image reading by DataLoader with this number of workers (faster) | 0最快
|
9 |
+
$thresh = 0.35 # concept thresh | 最小识别阈值
|
10 |
+
$general_threshold = 0.35 # general threshold | 总体识别阈值
|
11 |
+
$character_threshold = 0.1 # character threshold | 人物姓名识别阈值
|
12 |
+
$remove_underscore = 0 # remove_underscore | 下划线转空格,1为开,0为关
|
13 |
+
$undesired_tags = "" # no need tags | 排除标签
|
14 |
+
$recursive = 0 # search for images in subfolders recursively | 递归搜索下层文件夹,1为开,0为关
|
15 |
+
$frequency_tags = 0 # order by frequency tags | 从大到小按识别率排序标签,1为开,0为关
|
16 |
+
|
17 |
+
|
18 |
+
# Activate python venv
|
19 |
+
.\venv\Scripts\activate
|
20 |
+
|
21 |
+
$Env:HF_HOME = "huggingface"
|
22 |
+
$Env:XFORMERS_FORCE_DISABLE_TRITON = "1"
|
23 |
+
$ext_args = [System.Collections.ArrayList]::new()
|
24 |
+
|
25 |
+
if ($repo_id) {
|
26 |
+
[void]$ext_args.Add("--repo_id=" + $repo_id)
|
27 |
+
}
|
28 |
+
|
29 |
+
if ($model_dir) {
|
30 |
+
[void]$ext_args.Add("--model_dir=" + $model_dir)
|
31 |
+
}
|
32 |
+
|
33 |
+
if ($batch_size) {
|
34 |
+
[void]$ext_args.Add("--batch_size=" + $batch_size)
|
35 |
+
}
|
36 |
+
|
37 |
+
if ($max_data_loader_n_workers) {
|
38 |
+
[void]$ext_args.Add("--max_data_loader_n_workers=" + $max_data_loader_n_workers)
|
39 |
+
}
|
40 |
+
|
41 |
+
if ($general_threshold) {
|
42 |
+
[void]$ext_args.Add("--general_threshold=" + $general_threshold)
|
43 |
+
}
|
44 |
+
|
45 |
+
if ($character_threshold) {
|
46 |
+
[void]$ext_args.Add("--character_threshold=" + $character_threshold)
|
47 |
+
}
|
48 |
+
|
49 |
+
if ($remove_underscore) {
|
50 |
+
[void]$ext_args.Add("--remove_underscore")
|
51 |
+
}
|
52 |
+
|
53 |
+
if ($undesired_tags) {
|
54 |
+
[void]$ext_args.Add("--undesired_tags=" + $undesired_tags)
|
55 |
+
}
|
56 |
+
|
57 |
+
if ($recursive) {
|
58 |
+
[void]$ext_args.Add("--recursive")
|
59 |
+
}
|
60 |
+
|
61 |
+
if ($frequency_tags) {
|
62 |
+
[void]$ext_args.Add("--frequency_tags")
|
63 |
+
}
|
64 |
+
|
65 |
+
# run tagger
|
66 |
+
accelerate launch --num_cpu_threads_per_process=8 "./sd-scripts/finetune/tag_images_by_wd14_tagger.py" `
|
67 |
+
$train_data_dir `
|
68 |
+
--thresh=$thresh `
|
69 |
+
--caption_extension .txt `
|
70 |
+
$ext_args
|
71 |
+
|
72 |
+
Write-Output "Tagger finished"
|
73 |
+
Read-Host | Out-Null ;
|