nailong-dataset / tar.sh
XiC1's picture
Upload folder using huggingface_hub
5d2e8bb verified
#!/usr/bin/env sh
######################################################################
# @author : xic (zeexoc@outlook.com)
# @file : tar
# @created : Saturday Nov 02, 2024 18:06:32 CST
#
# @description : tar datas
######################################################################
subdirs=("train" "test")
source_dir='source' # 源目录
data_dir='data' # data目录
rm -r $data_dir
mkdir $data_dir
# 遍历 train 和 test 目录
for subdir in "${subdirs[@]}"; do
# 获取子目录下的所有文件夹
cp -r $source_dir/$subdir $data_dir/$subdir
folders=$(find "$data_dir/$subdir" -mindepth 1 -maxdepth 1 -type d)
for folder in $folders; do
folder_name=$(basename "$folder")
# 设置标签
if [ "$folder_name" == "nailong" ]; then
label=1
else
label=0
fi
echo "处理文件夹: $folder_name, 标签: $label"
# 执行 Python 脚本
#python ./convert2PNG.py "$folder"/*
python ./generate_info.py "label=$label" "$folder"/*
# 压缩文件夹并删除原文件夹
tar -cf "$data_dir/$subdir/$folder_name.tar" -C "$folder" . && rm -rf "$folder"
done
done