# hide
from nbdev.showdoc import *
Plotting
Utilities for plotting various things
Plotting object detection datasets
COCO
plot_coco_instance
plot_coco_instance (coco_data:dict, image_id:int, image_dir:pathlib.Path, ax:matplotlib.axes._axes.Axes, plot_bbox:bool=True, plot_segmentation:bool=True, show_labels:bool=True, show_title:bool=True)
import json
with open('example_data/tiles/coco_norm.json') as f:
= json.load(f) coco_data
= plt.subplots(1,1)
fig, ax 1, Path('example_data/tiles/images/'), ax, plot_bbox=True)
plot_coco_instance(coco_data, plt.show()
Also works with oriented bounding boxes
with open('example_data/tiles/coco_rot.json') as f:
= json.load(f)
coco_rot_data = plt.subplots(1,1)
fig, ax 3, Path('example_data/tiles/images/'), ax, plot_bbox=True)
plot_coco_instance(coco_rot_data, plt.show()
YOLO
plot_yolo_instance
plot_yolo_instance (annotation_fname:pathlib.Path, image_fname:pathlib.Path, ax:matplotlib.axes._axes.Axes, ann_type:str='box', show_title:bool=True, classes:list[str]=None)
Plot yolo format instance to ax
and return it. If classes
are provided show them in legend
= plt.subplots(1,1)
fig, ax = ['standing', 'fallen']
classes 'example_data/tiles/labels/R0C3.txt'), Path('example_data/tiles/images/R0C3.tif'), ax, ann_type='polygon',
plot_yolo_instance(Path(=classes) classes