Created
May 30, 2023 10:21
-
-
Save rekalantar/37f9380ec44cc27f63ba17967bd8769b to your computer and use it in GitHub Desktop.
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
| example = train_dataset[50] | |
| for k,v in example.items(): | |
| print(k,v.shape) | |
| xmin, ymin, xmax, ymax = get_bounding_box(example['ground_truth_mask']) | |
| fig, axs = plt.subplots(1, 2) | |
| axs[0].imshow(example['pixel_values'][1], cmap='gray') | |
| axs[0].axis('off') | |
| axs[1].imshow(example['ground_truth_mask'], cmap='copper') | |
| # create a Rectangle patch for the bounding box | |
| rect = patches.Rectangle((xmin, ymin), xmax-xmin, ymax-ymin, linewidth=1, edgecolor='r', facecolor='none') | |
| # add the patch to the second Axes | |
| axs[1].add_patch(rect) | |
| axs[1].axis('off') | |
| plt.tight_layout() | |
| plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment