diff --git a/models/.placeholder b/models/.placeholder new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/models/.placeholder @@ -0,0 +1 @@ + diff --git a/run_tracking.sh b/run_tracking.sh new file mode 100644 index 00000000..fbd2c1e0 --- /dev/null +++ b/run_tracking.sh @@ -0,0 +1,52 @@ +#!/bin/bash +# usage: +# 0. modify the path parameter and check every step carefully +# 1. chmod+x run_tracking.sh +# 2. ./run_tracking.sh +# Set the path to the videos and the tracking script +VIDEOS_PATH="./videos/bdd/" +SCRIPT_PATH="./tools/demo_track.py" +# Set this to the directory where the .txt files are saved +OUTPUT_PATH="./YOLOX_outputs/yolox_s_mix_det/track_vis/" + +# Iterate through all .mov videos in the directory +for video in $VIDEOS_PATH/*.mov; do + video_name=$(basename "$video" .mov) + output_file="${OUTPUT_PATH}/${video_name}.txt" + + # Check if the output file already exists + if [[ -f "$output_file" ]]; then + echo "Output for $video_name already exists. Skipping..." + continue + fi + + # Run the tracking script for the current video + python $SCRIPT_PATH video -f exps/example/mot/yolox_s_mix_det.py --path "$video" --ckpt './models/bytetrack_s_mot17.pth.tar' --fp16 --fuse --save_result + echo "Processed video: $video_name" + + #python tools/demo_track.py video -f exps/example/mot/yolox_s_mix_det.py -c ./models/bytetrack_s_mot17.pth.tar --path ./videos/BDD/b1f4491b-9958bd99.mov --fp16 --fuse --save_result + + # Optionally, rename the output (assuming the original script produces a timestamped output) + # mv "path_to_original_output" "${video_name}.txt" +done + +# Post-process renaming +python tools/post_rename.py + +# store txt +zip -r txt_archive.zip $OUTPUT_PATH/*.txt +# Create archives of .mov videos using zip + +DATE=$(date +"%Y_%m_%d") +NEW_FOLDER="$OUTPUT_PATH/$DATE" + +mkdir -p "$NEW_FOLDER" +find "$OUTPUT_PATH" -type f -name "*.mp4" -exec mv {} "$NEW_FOLDER/" \; + +# zip -r video_archive.zip $OUTPUT_PATH/*/*.mp4 +zip -r video_archive.zip "$NEW_FOLDER" + +echo "Archiving completed!" + + + diff --git a/tools/post_rename.py b/tools/post_rename.py new file mode 100644 index 00000000..dd3fdc77 --- /dev/null +++ b/tools/post_rename.py @@ -0,0 +1,28 @@ +import os + +def rename_txt_files(output_folder): + # Traverse the ByteTrack output directory + for subdir in os.listdir(output_folder): + subdir_path = os.path.join(output_folder, subdir) + + # Ensure it's a directory + if os.path.isdir(subdir_path): + # Get the BDD video name from the .mov file + mov_files = [f for f in os.listdir(subdir_path) if f.endswith('.mov')] + if mov_files: + bdd_video_name = mov_files[0].replace('.mov', '') + + # Construct old and new txt file paths + old_txt_path = os.path.join(output_folder, f"{subdir}.txt") + new_txt_path = os.path.join(output_folder, f"{bdd_video_name}.txt") + + # Rename the txt file + if os.path.exists(old_txt_path): + os.rename(old_txt_path, new_txt_path) + print(f"Renamed {old_txt_path} to {new_txt_path}") + else: + print(f"File {old_txt_path} does not exist!") + +# Example usage +output_folder = 'YOLOX_outputs/yolox_s_mix_det/track_vis' +rename_txt_files(output_folder)