Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add flag to omit timestamp in output directory #253

Merged
merged 10 commits into from
Nov 20, 2024
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ To track crabs in a new video, using a trained detector and a tracker, run the f
detect-and-track-video --trained_model_path <path-to-ckpt-file> --video_path <path-to-input-video>
```

This will produce a `tracking_output_<timestamp>` directory with the output from tracking under the current working directory.
This will produce a `tracking_output_<timestamp>` directory with the output from tracking under the current working directory. To avoid adding the `<timestamp>` suffix to the directory name, run the command with the `--output_dir_no_timestamp` flag. To see the full list of possible arguments to the `detect-and-track-video` command, run it with the `--help` flag.

The tracking output consists of:
- a .csv file named `<video-name>_tracks.csv`, with the tracked bounding boxes data;
Expand All @@ -153,8 +153,6 @@ If a file with ground-truth annotations is passed to the command (with the `--an

<!-- When used in combination with the `--save_video` flag, the tracked video will contain predicted bounding boxes in red, and ground-truth bounding boxes in green. -- PR 216-->

To see the full list of possible arguments to the `evaluate-detector` command, run it with the `--help` flag.

## Task-specific guides
For further information on specific tasks, such as launching a training job or evaluating a set of models in the HPC cluster, please see [our guides](guides).

Expand Down
28 changes: 21 additions & 7 deletions crabs/tracker/track_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def __init__(self, args: argparse.Namespace) -> None:

# input video data
self.input_video_path = args.video_path
self.input_video_file_root = f"{Path(self.input_video_path).stem}"
self.input_video_file_root = Path(self.input_video_path).stem

# tracking output directory root name
self.tracking_output_dir_root = args.output_dir
Expand All @@ -92,15 +92,19 @@ def prep_outputs(self):

This method:
- creates a timestamped directory to store the tracking output.
Optionally the timestamp can be omitted.
- sets the name of the output csv file for the tracked bounding boxes.
- sets up the output video path if required.
- sets up the frames subdirectory path if required.
"""
# Create output directory
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
self.tracking_output_dir = Path(
self.tracking_output_dir_root + f"_{timestamp}"
)
if self.args.output_dir_no_timestamp:
self.tracking_output_dir = Path(self.tracking_output_dir_root)
else:
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
self.tracking_output_dir = Path(
self.tracking_output_dir_root + f"_{timestamp}"
)
self.tracking_output_dir.mkdir(parents=True, exist_ok=True)

# Set name of output csv file
Expand Down Expand Up @@ -366,13 +370,23 @@ def tracking_parse_args(args):
default="tracking_output",
help=(
"Root name of the directory to save the tracking output. "
"The name of the output directory is appended with a timestamp. "
"By default, the name of the output directory is appended with "
"a timestamp. The timestamp can be omitted with the "
"--output_dir_no_timestamp flag. "
"The tracking output consist of a .csv. file named "
"<video-name>_tracks.csv with the tracked bounding boxes. "
"Optionally, it can include a video file named "
"<video-name>_tracks.mp4, and all frames from the video "
"under a <video-name>_frames subdirectory. "
"Default: ./tracking_output_<timestamp>. "
"Default: tracking_output_<timestamp>. "
),
)
parser.add_argument(
"--output_dir_no_timestamp",
action="store_true",
help=(
"Flag to disable appending a timestamp to the output "
"directory name. "
),
)
parser.add_argument(
Expand Down
Loading