Skip to content

Conversation

@xiu-cs
Copy link
Contributor

@xiu-cs xiu-cs commented Nov 21, 2024

Add Functions for Visualizing COCO Predictions and Ground Truth

Summary

This PR introduces two new functions to simplify the visualization of COCO-format predictions and their comparison with ground truth (GT) annotations.

Changes

  1. visualize_coco_predictions:

    • Visualizes predictions from a COCO-format dataset.
    • Inputs:
      • predictions: An object in the same format as returned by evaluate(*).
      • test_file_json: Path to the COCO-format test set JSON file with GT annotations.
      • num_samples: Number of samples to visualize.
      • output_dir: Directory to save visualization outputs.
      • draw_skeleton: Option to draw skeleton connections between keypoints.
    • Functionality:
      • Matches predictions to corresponding ground truth annotations.
      • Utilizes the plot_gt_and_predictions function for visualization.
  2. plot_gt_and_predictions:

    • Handles detailed plotting of ground truth and predictions on a single image.
    • Inputs:
      • image_path: Path to the image
      • gt_bodyparts, pred_bodyparts: Keypoint arrays for ground truth and predictions.
      • output_dir: Directory to save the labeled images.
      • Additional customization options like dot_size, colormap, and confidence thresholds.
    • Functionality:
      • Supports various visualization modes (bodypart or individual coloring).
      • Plot the gt and predictions on the given image.

Motivation

  • Improves debugging and performance analysis by offering a clear visual comparison between predictions and ground truth.
  • Simplifies workflows for analyzing COCO-format datasets.

Testing

  • The functions were tested on sample datasets and worked as expected.
    Test-images-oms_batch11_000116960_18260983
    Test-images-oms_batch7_000021520_18260986

Acknowledgments

Special thanks to @n-poulsen for his valuable guidance and support!

@n-poulsen n-poulsen self-requested a review November 22, 2024 10:19
@xiu-cs xiu-cs requested a review from n-poulsen November 25, 2024 11:20
Copy link
Contributor

@n-poulsen n-poulsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some small comments to address, but this looks good! Thank you @xiu-cs!

@xiu-cs xiu-cs requested a review from n-poulsen November 26, 2024 21:21
Copy link
Contributor

@n-poulsen n-poulsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few last tweaks, but otherwise this looks good to me!

@xiu-cs xiu-cs requested a review from n-poulsen December 2, 2024 13:21
Copy link
Contributor

@n-poulsen n-poulsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Thanks @xiu-cs!

@n-poulsen n-poulsen merged commit d940483 into DeepLabCut:pytorch_dlc Dec 2, 2024
@xiu-cs xiu-cs deleted the ti/coco_plotting branch June 19, 2025 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants