Created
November 1, 2024 09:05
-
-
Save JujuDel/8d09c8658e0f125d4451155c860b0e1e to your computer and use it in GitHub Desktop.
Copy CrowdHuman dataset with `person head` label changed to 80
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Copies the dataset | |
# Changes the person head label of the CrowdHuman to 80. | |
# Initial CrowdHuman dataset can be obtained from | |
# - https://gist.github.com/adujardin/62653118466962264aa0c6339c3e9cf5#file-crowdhuman_to_yolo-py-L144 | |
datasets="/home/user/code/datasets" | |
newFolder="NewCrowdHuman" | |
# If it exists, delete the new folder | |
if [ -d ${datasets}/${newFolder} ]; then | |
rm -rf ${datasets}/${newFolder} | |
fi | |
# Create a new folder | |
mkdir -p ${datasets}/${newFolder} | |
mkdir -p ${datasets}/${newFolder}/images | |
mkdir -p ${datasets}/${newFolder}/labels | |
# Copy the CrowdHuman labels and images | |
cp -r ${datasets}/CrowdHuman/images/train ${datasets}/${newFolder}/images/ | |
cp -r ${datasets}/CrowdHuman/labels/train ${datasets}/${newFolder}/labels/ | |
cp -r ${datasets}/CrowdHuman/images/val ${datasets}/${newFolder}/images/ | |
cp -r ${datasets}/CrowdHuman/labels/val ${datasets}/${newFolder}/labels/ | |
# Modify the copied labels | |
# Every CrowdHuman label has the form "id x y w h", replace all IDs 1 with 80 | |
for file in ${datasets}/${newFolder}/labels/train/*; do | |
awk '{if ($1 == 1) $1 = 80; print}' "$file" > tmp && mv tmp "$file" | |
done | |
for file in ${datasets}/${newFolder}/labels/val/*; do | |
awk '{if ($1 == 1) $1 = 80; print}' "$file" > tmp && mv tmp "$file" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment