Graduation-Project/federated_learning/GenerateTestdata.sh
2025-04-20 15:20:40 +08:00

16 lines
654 B
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 创建测试目录结构
mkdir -p ./test_data/{client1,client2}/{train,val}/images
mkdir -p ./test_data/{client1,client2}/{train,val}/labels
# 生成虚拟数据各客户端仅需2张图片
for client in client1 client2; do
for split in train val; do
# 创建空图片128x128 RGB
magick -size 128x128 xc:white test_data/${client}/${split}/images/img1.jpg
magick -size 128x128 xc:black test_data/${client}/${split}/images/img2.jpg
# 创建示例标签文件
echo "0 0.5 0.5 0.2 0.2" > test_data/${client}/${split}/labels/img1.txt
echo "1 0.3 0.3 0.4 0.4" > test_data/${client}/${split}/labels/img2.txt
done
done