Upload lora-scripts/tagger.sh with huggingface_hub
Browse files- lora-scripts/tagger.sh +70 -0
lora-scripts/tagger.sh
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# tagger script by @bdsqlsz
|
| 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=12 # 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 |
+
# ============= DO NOT MODIFY CONTENTS BELOW | 请勿修改下方内容 =====================
|
| 19 |
+
|
| 20 |
+
export HF_HOME="huggingface"
|
| 21 |
+
export TF_CPP_MIN_LOG_LEVEL=3
|
| 22 |
+
extArgs=()
|
| 23 |
+
|
| 24 |
+
if [ -n "$repo_id" ]; then
|
| 25 |
+
extArgs+=( "--repo_id=$repo_id" )
|
| 26 |
+
fi
|
| 27 |
+
|
| 28 |
+
if [ -n "$model_dir" ]; then
|
| 29 |
+
extArgs+=( "--model_dir=$model_dir" )
|
| 30 |
+
fi
|
| 31 |
+
|
| 32 |
+
if [[ $batch_size -ne 0 ]]; then
|
| 33 |
+
extArgs+=( "--batch_size=$batch_size" )
|
| 34 |
+
fi
|
| 35 |
+
|
| 36 |
+
if [ -n "$max_data_loader_n_workers" ]; then
|
| 37 |
+
extArgs+=( "--max_data_loader_n_workers=$max_data_loader_n_workers" )
|
| 38 |
+
fi
|
| 39 |
+
|
| 40 |
+
if [ -n "$general_threshold" ]; then
|
| 41 |
+
extArgs+=( "--general_threshold=$general_threshold" )
|
| 42 |
+
fi
|
| 43 |
+
|
| 44 |
+
if [ -n "$character_threshold" ]; then
|
| 45 |
+
extArgs+=( "--character_threshold=$character_threshold" )
|
| 46 |
+
fi
|
| 47 |
+
|
| 48 |
+
if [ "$remove_underscore" -eq 1 ]; then
|
| 49 |
+
extArgs+=( "--remove_underscore" )
|
| 50 |
+
fi
|
| 51 |
+
|
| 52 |
+
if [ -n "$undesired_tags" ]; then
|
| 53 |
+
extArgs+=( "--undesired_tags=$undesired_tags" )
|
| 54 |
+
fi
|
| 55 |
+
|
| 56 |
+
if [ "$recursive" -eq 1 ]; then
|
| 57 |
+
extArgs+=( "--recursive" )
|
| 58 |
+
fi
|
| 59 |
+
|
| 60 |
+
if [ "$frequency_tags" -eq 1 ]; then
|
| 61 |
+
extArgs+=( "--frequency_tags" )
|
| 62 |
+
fi
|
| 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 |
+
${extArgs[@]}
|